Skip to content
Snippets Groups Projects
Commit bb3c0c27 authored by Jean-Marie Favreau's avatar Jean-Marie Favreau
Browse files

Add a parameter for a simple output version

parent 8547f7c8
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@
Options:
-n, --name Object name
-s, --simple Simple version, without description of the new points
-o, --output=FILE Save the mesh using the file FILE
-h, --help Print this message and exit.
......@@ -43,7 +44,7 @@ def usage():
def main():
try:
opts, args = my_getopt(sys.argv[1:], "no:h", ["name", "help", "output="])
opts, args = my_getopt(sys.argv[1:], "no:hs", ["name", "help", "output=", "simple"])
except getopt.GetoptError as msg:
# print help information and exit:
print("Error: " + msg)
......@@ -51,9 +52,12 @@ def main():
sys.exit(2)
outputFile = ""
simple = False
for o, a in opts:
if o in ("-n", "--name"):
name = a
if o in ("-s", "--simple"):
simple = True
if o in ("-o", "--output"):
outputFile = a
if o in ("-h", "--help"):
......@@ -85,15 +89,17 @@ def main():
filout.write("# This file contains a set of paths between two vertices on a given mesh (" + inputFile + ")\n")
filout.write("# Each path is described as following:\n")
filout.write("# * the first line contains 5 number\n")
if not simple:
filout.write("# * the first line contains 5 number\n")
filout.write("# * the ID of the first vertex\n")
filout.write("# * the ID of the last vertex\n")
filout.write("# * the length of the path\n")
filout.write("# * the number of points between the two vertices\n")
filout.write("# * a line per new point between the two vertices, described as following:\n")
filout.write("# * 3 values (x, y, z) for the coordinates\n")
filout.write("# * 2 vertex IDs (may be equal in case of point on an existing vertex)\n")
filout.write("# corresponding to the edge where the point is located.\n")
if not simple:
filout.write("# * a line per new point between the two vertices, described as following:\n")
filout.write("# * 3 values (x, y, z) for the coordinates\n")
filout.write("# * 2 vertex IDs (may be equal in case of point on an existing vertex)\n")
filout.write("# corresponding to the edge where the point is located.\n")
filout.write("# Note: the ID of the first vertex is 1.\n")
......@@ -106,11 +112,12 @@ def main():
path = taglut.PLPath(taglut.PointOnEdge(m.point(bpoint2)), False, m, mMap, vf)
if path.size() >= 2:
filout.write(str(bpoint + 1) + " " + str(bpoint2 + 1) + " " + str(path.length()) + " " + str(path.size() - 2) + "\n")
plist = list(path.getPoints())
del plist[0]
del plist[-1]
for p in plist:
filout.write(str(p.getX()) + " " + str(p.getY()) + " " + str(p.getZ()) + " " + str(p.getFirstVertex() + 1) + " " + str(p.getSecondVertex() + 1) + "\n")
if not simple:
plist = list(path.getPoints())
del plist[0]
del plist[-1]
for p in plist:
filout.write(str(p.getX()) + " " + str(p.getY()) + " " + str(p.getZ()) + " " + str(p.getFirstVertex() + 1) + " " + str(p.getSecondVertex() + 1) + "\n")
except taglut.Exception as msg:
print("Error: " + msg.getMessage())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment