removed "legacy" option. STDOUT reports most modern format available (ASCII XML for point cloud, VTK for rectilinear grid).

This commit is contained in:
Philip Eisenlohr 2016-04-24 12:34:01 -05:00
parent f1b5d40bac
commit 94933514a1
2 changed files with 14 additions and 31 deletions

View File

@ -23,14 +23,8 @@ parser.add_option('-p',
dest = 'pos',
type = 'string', metavar = 'string',
help = 'label of coordinates [%default]')
parser.add_option('-l',
'--legacy',
dest = 'legacy',
action = 'store_true',
help = 'legacy VTK output')
parser.set_defaults(pos = 'pos',
legacy = False,
)
(options, filenames) = parser.parse_args()
@ -88,19 +82,16 @@ for name in filenames:
# ------------------------------------------ output result ---------------------------------------
if options.legacy:
writer = vtk.vtkDataSetWriter()
writer.SetHeader('# powered by '+scriptID)
else:
writer = vtk.vtkXMLPolyDataWriter()
writer.SetDataModeToBinary()
writer.SetCompressorTypeToZLib()
writer = vtk.vtkXMLPolyDataWriter()
writer.SetCompressorTypeToZLib()
if name:
writer.SetDataModeToBinary()
writer.SetFileName(os.path.join(os.path.split(name)[0],
os.path.splitext(os.path.split(name)[1])[0] +
'.' + ('vtk' if options.legacy else writer.GetDefaultFileExtension())))
'.' + writer.GetDefaultFileExtension()))
else:
writer.SetDataModeToAscii()
writer.WriteToOutputStringOn()
if vtk.VTK_MAJOR_VERSION <= 5: writer.SetInput(Polydata)
@ -108,6 +99,6 @@ for name in filenames:
writer.Write()
if name is None: sys.stdout.write(writer.GetOutputString()) #[0:writer.GetOutputStringLength()]
if name is None: sys.stdout.write(writer.GetOutputString())
table.close()

View File

@ -34,16 +34,10 @@ parser.add_option('-g',
dest = 'geom',
action = 'store_true',
help = 'geom input format')
parser.add_option('-l',
'--legacy',
dest = 'legacy',
action = 'store_true',
help = 'legacy VTK output')
parser.set_defaults(mode = 'cell',
pos = 'pos',
geom = False,
legacy = False,
)
(options, filenames) = parser.parse_args()
@ -132,20 +126,17 @@ for name in filenames:
# ------------------------------------------ output result ---------------------------------------
if options.legacy:
writer = vtk.vtkDataSetWriter()
writer.SetHeader('# powered by '+scriptID)
else:
writer = vtk.vtkXMLRectilinearGridWriter()
writer.SetDataModeToBinary()
writer.SetCompressorTypeToZLib()
if name:
writer = vtk.vtkXMLPolyDataWriter()
writer.SetCompressorTypeToZLib()
writer.SetDataModeToBinary()
writer.SetFileName(os.path.join(os.path.split(name)[0],
os.path.splitext(os.path.split(name)[1])[0] +
('' if isGeom else '_{}({})'.format(options.pos, options.mode)) +
'.' + ('vtk' if options.legacy else writer.GetDefaultFileExtension())))
'.' + writer.GetDefaultFileExtension()))
else:
writer = vtk.vtkDataSetWriter()
writer.SetHeader('# powered by '+scriptID)
writer.WriteToOutputStringOn()
if vtk.VTK_MAJOR_VERSION <= 5: writer.SetInput(rGrid)
@ -153,6 +144,7 @@ for name in filenames:
writer.Write()
if name is None: sys.stdout.write(writer.GetOutputString())
if name is None: sys.stdout.write(writer.GetOutputString() if name else
writer.GetOutputString()[0:writer.GetOutputStringLength()])
table.close()