From 2089726800645babc2ec7f84e9928ca04841d0c6 Mon Sep 17 00:00:00 2001 From: Eureka Pai Date: Mon, 25 Feb 2019 18:48:40 -0500 Subject: [PATCH] corrected output extension of vtk files to reflect binary format --- processing/post/vtk_addGridData.py | 11 +++++++---- processing/post/vtk_addPointCloudData.py | 9 ++++++--- processing/post/vtk_addRectilinearGridData.py | 8 +++++--- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/processing/post/vtk_addGridData.py b/processing/post/vtk_addGridData.py index c458b1f07..34f01e7bf 100755 --- a/processing/post/vtk_addGridData.py +++ b/processing/post/vtk_addGridData.py @@ -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() diff --git a/processing/post/vtk_addPointCloudData.py b/processing/post/vtk_addPointCloudData.py index 5ab1d419e..0a1cb1231 100755 --- a/processing/post/vtk_addPointCloudData.py +++ b/processing/post/vtk_addPointCloudData.py @@ -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() diff --git a/processing/post/vtk_addRectilinearGridData.py b/processing/post/vtk_addRectilinearGridData.py index e445214fd..868fdc387 100755 --- a/processing/post/vtk_addRectilinearGridData.py +++ b/processing/post/vtk_addRectilinearGridData.py @@ -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()