Created
June 1, 2018 08:12
-
-
Save 1f0/7a878ffa58e76d0b4ecfb8d2f2236c00 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
if(len(sys.argv)!=3): | |
print('Usage: ', sys.argv[0], 'input.vtk output.obj') | |
sys.exit() | |
import vtk | |
reader = vtk.vtkUnstructuredGridReader() | |
reader.SetFileName(sys.argv[1]) | |
reader.Update() | |
output = reader.GetOutput() | |
out_obj_file = sys.argv[2] | |
with open(out_obj_file, 'w') as f: | |
for i in range(output.GetNumberOfPoints()): | |
pt = output.GetPoint(i) | |
f.write('v %.5f %.5f %.5f\n' % (pt[0], pt[1], pt[2])) | |
for i in range(output.GetNumberOfCells()): | |
cell = output.GetCell(i) | |
f.write('f %d %d %d\n'% (cell.GetPointId(0)+1, cell.GetPointId(1)+1, cell.GetPointId(2)+1) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment