def __init__(self, module_manager): SimpleVTKClassModuleBase.__init__( self, module_manager, vtk.vtkIVWriter(), 'Writing vtkIV.', ('vtkIV',), (), replaceDoc=True, inputFunctions=None, outputFunctions=None)
def vtk_export(polydata, filename, method='vtk'): """Export VTK polyData object to different file formats. polydata (vtk.vtkPolyData): ytk object containing vertices and simplices filename (string): path and filename without extension method (string): one of the following options vtk: VTK legacy file version 4.2 (e.g. for import into ParaView) ply: Stanford University ".ply" file (e.g. for import into MeshLab) iv: OpenInventor 2.0 file (e.g. for import into METRO) """ # TODO: Binary ASCII stuff if method == 'vtk': export = vtkPolyDataWriter() export.SetInputDataObject(polydata) export.SetFileName(filename + '.vtk') export.Write() elif method == 'ply': export = vtkPLYWriter() export.SetInputDataObject(polydata) export.SetFileName(filename + '.ply') export.Write() elif method == 'iv': export = vtkIVWriter() export.SetInputDataObject(polydata) export.SetFileName(filename + '.iv') export.Write() else: print('File format unknown!')
def __init__(self, module_manager): # call parent constructor ModuleBase.__init__(self, module_manager) self._writer = vtk.vtkIVWriter() # sorry about this, but the files get REALLY big if we write them # in ASCII - I'll make this a gui option later. #self._writer.SetFileTypeToBinary() # following is the standard way of connecting up the devide progress # callback to a VTK object; you should do this for all objects in module_utils.setup_vtk_object_progress( self, self._writer, 'Writing polydata to Inventor Viewer format') # ctor for this specific mixin FilenameViewModuleMixin.__init__( self, 'Select a filename', 'InventorViewer data (*.iv)|*.iv|All files (*)|*', {'vtkIVWriter': self._writer}, fileOpen=False) # set up some defaults self._config.filename = '' self.sync_module_logic_with_config()
def __init__(self, module_manager): SimpleVTKClassModuleBase.__init__(self, module_manager, vtk.vtkIVWriter(), 'Writing vtkIV.', ('vtkIV', ), (), replaceDoc=True, inputFunctions=None, outputFunctions=None)
file.delete("-force", "test.tmp") # # # test the writers dsw = vtk.vtkDataSetWriter() dsw.SetInputConnection(smooth.GetOutputPort()) dsw.SetFileName("brain.dsw") dsw.Write() file.delete("-force", "brain.dsw") pdw = vtk.vtkPolyDataWriter() pdw.SetInputConnection(smooth.GetOutputPort()) pdw.SetFileName("brain.pdw") pdw.Write() file.delete("-force", "brain.pdw") if (info.command(globals(), locals(), "vtkIVWriter") != ""): iv = vtk.vtkIVWriter() iv.SetInputConnection(smooth.GetOutputPort()) iv.SetFileName("brain.iv") iv.Write() file.delete("-force", "brain.iv") pass # # the next writers only handle triangles triangles = vtk.vtkTriangleFilter() triangles.SetInputConnection(smooth.GetOutputPort()) if (info.command(globals(), locals(), "vtkIVWriter") != ""): iv2 = vtk.vtkIVWriter() iv2.SetInputConnection(triangles.GetOutputPort()) iv2.SetFileName("brain2.iv") iv2.Write() file.delete("-force", "brain2.iv")