added support for legacy VTK format
This commit is contained in:
parent
0bc7f36ee5
commit
13e214fe18
|
@ -51,13 +51,22 @@ parser.set_defaults(scalar = [],
|
||||||
if not options.vtk: parser.error('No VTK file specified.')
|
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 not os.path.exists(options.vtk): parser.error('VTK file does not exist.')
|
||||||
|
|
||||||
reader = vtk.vtkXMLPolyDataReader()
|
if os.path.splitext(options.vtk)[1] == '.vtp':
|
||||||
reader.SetFileName(options.vtk)
|
reader = vtk.vtkXMLPolyDataReader()
|
||||||
reader.Update()
|
reader.SetFileName(options.vtk)
|
||||||
Npoints = reader.GetNumberOfPoints()
|
reader.Update()
|
||||||
Ncells = reader.GetNumberOfCells()
|
Polydata = reader.GetOutput()
|
||||||
Nvertices = reader.GetNumberOfVerts()
|
elif os.path.splitext(options.vtk)[1] == '.vtk':
|
||||||
Polydata = reader.GetOutput()
|
reader = vtk.vtkGenericDataObjectReader()
|
||||||
|
reader.SetFileName(options.vtk)
|
||||||
|
reader.Update()
|
||||||
|
Polydata = reader.GetPolyDataOutput()
|
||||||
|
else:
|
||||||
|
parser.error('Unsupported VTK file type extension.')
|
||||||
|
|
||||||
|
Npoints = Polydata.GetNumberOfPoints()
|
||||||
|
Ncells = Polydata.GetNumberOfCells()
|
||||||
|
Nvertices = Polydata.GetNumberOfVerts()
|
||||||
|
|
||||||
if Npoints != Ncells or Npoints != Nvertices:
|
if Npoints != Ncells or Npoints != Nvertices:
|
||||||
parser.error('Number of points, cells, and vertices in VTK differ from each other.')
|
parser.error('Number of points, cells, and vertices in VTK differ from each other.')
|
||||||
|
|
Loading…
Reference in New Issue