def get_output_dataset(self): """ Return the output dataset of this object. """ if self.outputs: return get_new_output(self.outputs[0]) else: return None
def convert_to_poly_data(obj): """Given a VTK dataset object, this returns the data as PolyData. This is primarily used to convert the data suitably for filters that only work for PolyData. """ data = get_new_output(obj) if obj.is_a('vtkPolyData') or data.is_a('vtkPolyData'): return obj conv = { 'vtkStructuredPoints': tvtk.ImageDataGeometryFilter, 'vtkImageData': tvtk.ImageDataGeometryFilter, 'vtkRectilinearGrid': tvtk.RectilinearGridGeometryFilter, 'vtkStructuredGrid': tvtk.StructuredGridGeometryFilter, 'vtkUnstructuredGrid': tvtk.GeometryFilter, 'vtkCompositeDataSet': tvtk.CompositeDataGeometryFilter } fil = None for name, fil_class in conv.items(): if data.is_a(name): fil = fil_class() break if fil is not None: configure_input(fil, obj) fil.update() return fil else: error('Given object is not a VTK dataset: %s' % data.__class__.__name__)
def convert_to_poly_data(obj): """Given a VTK dataset object, this returns the data as PolyData. This is primarily used to convert the data suitably for filters that only work for PolyData. """ data = get_new_output(obj) if obj.is_a('vtkPolyData') or data.is_a('vtkPolyData'): return obj conv = {'vtkStructuredPoints': tvtk.ImageDataGeometryFilter, 'vtkImageData': tvtk.ImageDataGeometryFilter, 'vtkRectilinearGrid': tvtk.RectilinearGridGeometryFilter, 'vtkStructuredGrid': tvtk.StructuredGridGeometryFilter, 'vtkUnstructuredGrid': tvtk.GeometryFilter, 'vtkCompositeDataSet': tvtk.CompositeDataGeometryFilter} fil = None for name, fil_class in conv.items(): if data.is_a(name): fil = fil_class() break if fil is not None: configure_input(fil, obj) fil.update() return fil else: error('Given object is not a VTK dataset: %s' % data.__class__.__name__)
def _get_correct_input(self, input): do = get_new_output(input) if do.is_a('vtkCompositeDataSet'): cdgf = self.comp_data_geom_filter cdgf.input_connection = input.output_port return cdgf else: return input
def update_pipeline(self): # Do nothing if there is no input. inputs = self.inputs if len(inputs) == 0: return # Set the maximum index. obj = get_new_output(inputs[0].outputs[0]) self._my_input = obj if hasattr(obj, 'number_of_blocks'): self._max_index = obj.number_of_blocks - 1 else: self._max_index = len(inputs[0].outputs) - 1 self._output_index_changed(self.output_index)
def has_attributes(dataset): """Returns `True` when the given TVTK `dataset` has any attribute arrays in point and cell data and `False` otherwise. """ if dataset is None: return False obj = dsa.WrapDataObject(tvtk.to_vtk(get_new_output(dataset))) if obj.PointData and len(obj.PointData.keys()) > 0: return True if obj.CellData and len(obj.CellData.keys()) > 0: return True return False