def update_pipeline(self): """Override this method so that it *updates* the tvtk pipeline when data upstream is known to have changed. This method is invoked (automatically) when the input fires a `pipeline_changed` event. """ if len(self.inputs) == 0: return input = self.inputs[0].outputs[0] plane = None if input.is_a('vtkStructuredGrid'): plane = tvtk.StructuredGridGeometryFilter() elif input.is_a('vtkStructuredPoints') or input.is_a('vtkImageData'): plane = tvtk.ImageDataGeometryFilter () elif input.is_a('vtkRectilinearGrid'): plane = tvtk.RectilinearGridGeometryFilter () else: msg = "The GridPlane component does not support the %s dataset."\ %(input.class_name) error(msg) raise TypeError, msg plane.input = input self.plane = plane self.outputs = [plane.output] self._update_limits() self._update_extents() # If the data is 2D make sure that we default to the # appropriate axis. extents = list(_get_extent(input)) diff = [y-x for x, y in zip(extents[::2], extents[1::2])] if diff.count(0) > 0: self.axis = ['x', 'y', 'z'][diff.index(0)]
def update_pipeline(self): """Override this method so that it *updates* the tvtk pipeline when data upstream is known to have changed. This method is invoked (automatically) when the input fires a `pipeline_changed` event. """ if len(self.inputs) == 0: return input = self.inputs[0].get_output_dataset() plane = None if input.is_a('vtkStructuredGrid'): plane = tvtk.StructuredGridGeometryFilter() elif input.is_a('vtkStructuredPoints') or input.is_a('vtkImageData'): plane = tvtk.ImageDataGeometryFilter() elif input.is_a('vtkRectilinearGrid'): plane = tvtk.RectilinearGridGeometryFilter() else: msg = "The GridPlane component does not support the %s dataset."\ %(input.class_name) error(msg) raise TypeError(msg) self.configure_connection(plane, self.inputs[0]) self.plane = plane self._update_limits() self._update_voi() self.outputs = [plane]