corrected output extension of vtk files to reflect binary format
This commit is contained in:
parent
e401c21266
commit
2089726800
|
@ -53,19 +53,22 @@ parser.set_defaults(data = [],
|
|||
if not options.vtk: parser.error('No VTK file specified.')
|
||||
if not os.path.exists(options.vtk): parser.error('VTK file does not exist.')
|
||||
|
||||
if os.path.splitext(options.vtk)[1] == '.vtr':
|
||||
vtk_file,vtk_ext = os.path.splitext(options.vtk)
|
||||
|
||||
if vtk_ext == '.vtr':
|
||||
reader = vtk.vtkXMLRectilinearGridReader()
|
||||
reader.SetFileName(options.vtk)
|
||||
reader.Update()
|
||||
rGrid = reader.GetOutput()
|
||||
writer = vtk.vtkXMLRectilinearGridWriter()
|
||||
elif os.path.splitext(options.vtk)[1] == '.vtk':
|
||||
elif vtk_ext == '.vtk':
|
||||
reader = vtk.vtkGenericDataObjectReader()
|
||||
reader.SetFileName(options.vtk)
|
||||
reader.Update()
|
||||
rGrid = reader.GetRectilinearGridOutput()
|
||||
writer = vtk.vtkXMLRectilinearGridWriter()
|
||||
elif os.path.splitext(options.vtk)[1] == '.vtu':
|
||||
vtk_ext = '.vtr'
|
||||
elif vtk_ext == '.vtu':
|
||||
reader = vtk.vtkXMLUnstructuredGridReader()
|
||||
reader.SetFileName(options.vtk)
|
||||
reader.Update()
|
||||
|
@ -74,7 +77,7 @@ elif os.path.splitext(options.vtk)[1] == '.vtu':
|
|||
else:
|
||||
parser.error('Unsupported VTK file type extension.')
|
||||
|
||||
writer.SetFileName(options.vtk)
|
||||
writer.SetFileName(vtk_file+vtk_ext)
|
||||
|
||||
Npoints = rGrid.GetNumberOfPoints()
|
||||
Ncells = rGrid.GetNumberOfCells()
|
||||
|
|
|
@ -49,16 +49,19 @@ parser.set_defaults(data = [],
|
|||
if not options.vtk: parser.error('no VTK file specified.')
|
||||
if not os.path.exists(options.vtk): parser.error('VTK file does not exist.')
|
||||
|
||||
if os.path.splitext(options.vtk)[1] == '.vtp':
|
||||
vtk_file,vtk_ext = os.path.splitext(options.vtk)
|
||||
|
||||
if vtk_ext == '.vtp':
|
||||
reader = vtk.vtkXMLPolyDataReader()
|
||||
reader.SetFileName(options.vtk)
|
||||
reader.Update()
|
||||
Polydata = reader.GetOutput()
|
||||
elif os.path.splitext(options.vtk)[1] == '.vtk':
|
||||
elif vtk_ext == '.vtk':
|
||||
reader = vtk.vtkGenericDataObjectReader()
|
||||
reader.SetFileName(options.vtk)
|
||||
reader.Update()
|
||||
Polydata = reader.GetPolyDataOutput()
|
||||
vtk_ext = '.vtp'
|
||||
else:
|
||||
parser.error('unsupported VTK file type extension.')
|
||||
|
||||
|
@ -149,7 +152,7 @@ for name in filenames:
|
|||
writer = vtk.vtkXMLPolyDataWriter()
|
||||
writer.SetDataModeToBinary()
|
||||
writer.SetCompressorTypeToZLib()
|
||||
writer.SetFileName(options.vtk)
|
||||
writer.SetFileName(vtk_file+vtk_ext)
|
||||
writer.SetInputData(Polydata)
|
||||
writer.Write()
|
||||
|
||||
|
|
|
@ -53,16 +53,18 @@ parser.set_defaults(data = [],
|
|||
if not options.vtk: parser.error('no VTK file specified.')
|
||||
if not os.path.exists(options.vtk): parser.error('VTK file does not exist.')
|
||||
|
||||
if os.path.splitext(options.vtk)[1] == '.vtr':
|
||||
vtk_file,vtk_ext = os.path.splitext(options.vtk)
|
||||
if vtk_ext == '.vtr':
|
||||
reader = vtk.vtkXMLRectilinearGridReader()
|
||||
reader.SetFileName(options.vtk)
|
||||
reader.Update()
|
||||
rGrid = reader.GetOutput()
|
||||
elif os.path.splitext(options.vtk)[1] == '.vtk':
|
||||
elif vtk_ext == '.vtk':
|
||||
reader = vtk.vtkGenericDataObjectReader()
|
||||
reader.SetFileName(options.vtk)
|
||||
reader.Update()
|
||||
rGrid = reader.GetRectilinearGridOutput()
|
||||
vtk_ext = '.vtr'
|
||||
else:
|
||||
parser.error('unsupported VTK file type extension.')
|
||||
|
||||
|
@ -159,7 +161,7 @@ for name in filenames:
|
|||
writer = vtk.vtkXMLRectilinearGridWriter()
|
||||
writer.SetDataModeToBinary()
|
||||
writer.SetCompressorTypeToZLib()
|
||||
writer.SetFileName(options.vtk)
|
||||
writer.SetFileName(vtk_file+vtk_ext)
|
||||
writer.SetInputData(rGrid)
|
||||
writer.Write()
|
||||
|
||||
|
|
Loading…
Reference in New Issue