if len(args) != 2: parser.print_usage() sys.exit(1) vtpFile = args[0] outDir = args[1] Utils.loadVTKLibraries() reader = vtkXMLPolyDataReader() reader.SetFileName(vtpFile) reader.Update() polydata = reader.GetOutput() mesh = Mesh(MeshTraitsBuilder()) vertices = jarray.zeros(polydata.GetNumberOfPoints(), Vertex) coord = jarray.zeros(3, "d") for i in xrange(len(vertices)): polydata.GetPoint(i, coord) vertices[i] = mesh.createVertex(coord) indices = Utils.getValues(polydata.GetPolys()) i = 0 while i < len(indices): if (indices[i] == 3): mesh.add(mesh.createTriangle( vertices[indices[i+1]], vertices[indices[i+2]], vertices[indices[i+3]])) i += indices[i] + 1
parser.print_usage() sys.exit(1) xmlDir = args[0] outDir = args[1] # Original mesh will be treated as a background mesh background_mtb = MeshTraitsBuilder.getDefault3D() background_mtb.addNodeSet() background_mesh = Mesh(background_mtb) MeshReader.readObject3D(background_mesh, xmlDir) if options.coplanarity: background_mesh.buildRidges(options.coplanarity) # New mesh must not have connectivity new_mtb = MeshTraitsBuilder() new_mtb.addTriangleList() new_mtb.addNodeList() new_mesh = Mesh(new_mtb) for point in background_mesh.getNodes(): new_mesh.add(point) # Split triangles into 4 new triangles mapSeenTriangles = {} for triangle in background_mesh.getTriangles(): if triangle.hasAttributes(AbstractHalfEdge.OUTER): continue edge = triangle.getAbstractHalfEdge() newVertices = [None, None, None] for i in xrange(3): edge = edge.next()