Merge commit 'v2.0.2-1939-ge5b65ede'

This commit is contained in:
Test User 2019-02-26 04:41:05 +00:00
commit 753fc6cf9a
3 changed files with 18 additions and 10 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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()