let vtk decide on the file extension

This commit is contained in:
Martin Diehl 2019-03-09 00:40:50 +01:00
parent 2394880741
commit 60feb96afd
3 changed files with 3 additions and 6 deletions

View File

@ -67,7 +67,6 @@ elif vtk_ext == '.vtk':
reader.Update() reader.Update()
rGrid = reader.GetRectilinearGridOutput() rGrid = reader.GetRectilinearGridOutput()
writer = vtk.vtkXMLRectilinearGridWriter() writer = vtk.vtkXMLRectilinearGridWriter()
vtk_ext = '.vtr'
elif vtk_ext == '.vtu': elif vtk_ext == '.vtu':
reader = vtk.vtkXMLUnstructuredGridReader() reader = vtk.vtkXMLUnstructuredGridReader()
reader.SetFileName(options.vtk) reader.SetFileName(options.vtk)
@ -77,7 +76,7 @@ elif vtk_ext == '.vtu':
else: else:
parser.error('Unsupported VTK file type extension.') parser.error('Unsupported VTK file type extension.')
writer.SetFileName(vtk_file+vtk_ext) writer.SetFileName(vtk_file+'.'+writer.GetDefaultFileExtension())
Npoints = rGrid.GetNumberOfPoints() Npoints = rGrid.GetNumberOfPoints()
Ncells = rGrid.GetNumberOfCells() Ncells = rGrid.GetNumberOfCells()

View File

@ -61,7 +61,6 @@ elif vtk_ext == '.vtk':
reader.SetFileName(options.vtk) reader.SetFileName(options.vtk)
reader.Update() reader.Update()
Polydata = reader.GetPolyDataOutput() Polydata = reader.GetPolyDataOutput()
vtk_ext = '.vtp'
else: else:
parser.error('unsupported VTK file type extension.') parser.error('unsupported VTK file type extension.')
@ -152,7 +151,7 @@ for name in filenames:
writer = vtk.vtkXMLPolyDataWriter() writer = vtk.vtkXMLPolyDataWriter()
writer.SetDataModeToBinary() writer.SetDataModeToBinary()
writer.SetCompressorTypeToZLib() writer.SetCompressorTypeToZLib()
writer.SetFileName(vtk_file+vtk_ext) writer.SetFileName(vtk_file+'.'+writer.GetDefaultFileExtension())
writer.SetInputData(Polydata) writer.SetInputData(Polydata)
writer.Write() writer.Write()

View File

@ -64,7 +64,6 @@ elif vtk_ext == '.vtk':
reader.SetFileName(options.vtk) reader.SetFileName(options.vtk)
reader.Update() reader.Update()
rGrid = reader.GetRectilinearGridOutput() rGrid = reader.GetRectilinearGridOutput()
vtk_ext = '.vtr'
else: else:
parser.error('unsupported VTK file type extension.') parser.error('unsupported VTK file type extension.')
@ -161,7 +160,7 @@ for name in filenames:
writer = vtk.vtkXMLRectilinearGridWriter() writer = vtk.vtkXMLRectilinearGridWriter()
writer.SetDataModeToBinary() writer.SetDataModeToBinary()
writer.SetCompressorTypeToZLib() writer.SetCompressorTypeToZLib()
writer.SetFileName(vtk_file+vtk_ext) writer.SetFileName(vtk_file+'.'+writer.GetDefaultFileExtension())
writer.SetInputData(rGrid) writer.SetInputData(rGrid)
writer.Write() writer.Write()