Exemplo n.º 1
0
	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

MeshWriter.writeObject3D(mesh, outDir, String())