vtkmodules.util.vtkAlgorithm#

Module Contents#

Classes#

VTKAlgorithm

This is a superclass which can be derived to implement Python classes that work with vtkPythonAlgorithm. It implements Initialize(), ProcessRequest(), FillInputPortInformation() and FillOutputPortInformation().

VTKPythonAlgorithmBase

This is a superclass which can be derived to implement Python classes that act as VTK algorithms in a VTK pipeline. It implements ProcessRequest(), FillInputPortInformation() and FillOutputPortInformation().

API#

class vtkmodules.util.vtkAlgorithm.VTKAlgorithm(nInputPorts=1, inputType='vtkDataSet', nOutputPorts=1, outputType='vtkPolyData')#

Bases: object

This is a superclass which can be derived to implement Python classes that work with vtkPythonAlgorithm. It implements Initialize(), ProcessRequest(), FillInputPortInformation() and FillOutputPortInformation().

Initialize() sets the input and output ports based on data members.

ProcessRequest() calls RequestXXX() methods to implement various pipeline passes.

FillInputPortInformation() and FillOutputPortInformation() set the input and output types based on data members.

Initialization

Sets up default NumberOfInputPorts, NumberOfOutputPorts, InputType and OutputType that are used by various initialization methods.

Initialize(vtkself)#

Sets up number of input and output ports based on NumberOfInputPorts and NumberOfOutputPorts.

GetInputData(inInfo, i, j)#

Convenience method that returns an input data object given a vector of information objects and two indices.

GetOutputData(outInfo, i)#

Convenience method that returns an output data object given an information object and an index.

RequestDataObject(vtkself, request, inInfo, outInfo)#

Overwritten by subclass to manage data object creation. There is not need to overwrite this class if the output can be created based on the OutputType data member.

RequestInformation(vtkself, request, inInfo, outInfo)#

Overwritten by subclass to provide meta-data to downstream pipeline.

RequestUpdateExtent(vtkself, request, inInfo, outInfo)#

Overwritten by subclass to modify data request going to upstream pipeline.

abstract RequestData(vtkself, request, inInfo, outInfo)#

Overwritten by subclass to execute the algorithm.

ProcessRequest(vtkself, request, inInfo, outInfo)#

Splits a request to RequestXXX() methods.

FillInputPortInformation(vtkself, port, info)#

Sets the required input type to InputType.

FillOutputPortInformation(vtkself, port, info)#

Sets the default output type to OutputType.

class vtkmodules.util.vtkAlgorithm.VTKPythonAlgorithmBase(nInputPorts=1, inputType='vtkDataSet', nOutputPorts=1, outputType='vtkPolyData')#

Bases: vtkmodules.vtkFiltersPython.vtkPythonAlgorithm

This is a superclass which can be derived to implement Python classes that act as VTK algorithms in a VTK pipeline. It implements ProcessRequest(), FillInputPortInformation() and FillOutputPortInformation().

ProcessRequest() calls RequestXXX() methods to implement various pipeline passes.

FillInputPortInformation() and FillOutputPortInformation() set the input and output types based on data members.

Common use is something like this:

class HDF5Source(VTKPythonAlgorithmBase): def init(self): VTKPythonAlgorithmBase.init(self, nInputPorts=0, nOutputPorts=1, outputType=’vtkImageData’)

def RequestInformation(self, request, inInfo, outInfo):
    f = h5py.File("foo.h5", 'r')
    dims = f['RTData'].shape[::-1]
    info = outInfo.GetInformationObject(0)
    info.Set(vtkmodules.vtkCommonExecutionModel.vtkStreamingDemandDrivenPipeline.WHOLE_EXTENT(),
        (0, dims[0]-1, 0, dims[1]-1, 0, dims[2]-1), 6)
    return 1

def RequestData(self, request, inInfo, outInfo):
    f = h5py.File("foo.h5", 'r')
    data = f['RTData'][:]
    output = dsa.WrapDataObject(vtkmodules.vtkCommonDataModel.vtkImageData.GetData(outInfo))
    output.SetDimensions(data.shape)
    output.PointData.append(data.flatten(), 'RTData')
    output.PointData.SetActiveScalars('RTData')
    return 1

alg = HDF5Source()

cf = vtkmodules.vtkFiltersCore.vtkContourFilter() cf.SetInputConnection(alg.GetOutputPort()) cf.Update()

Initialization

Sets up default NumberOfInputPorts, NumberOfOutputPorts, InputType and OutputType that are used by various methods. Make sure to call this method from any subclass’ init

class InternalAlgorithm#

Bases: object

Internal class. Do not use.

Initialize(vtkself)#
FillInputPortInformation(vtkself, port, info)#
FillOutputPortInformation(vtkself, port, info)#
ProcessRequest(vtkself, request, inInfo, outInfo)#
GetInputData(inInfo, i, j)#

Convenience method that returns an input data object given a vector of information objects and two indices.

GetOutputData(outInfo, i)#

Convenience method that returns an output data object given an information object and an index.

FillInputPortInformation(port, info)#

Sets the required input type to InputType.

FillOutputPortInformation(port, info)#

Sets the default output type to OutputType.

ProcessRequest(request, inInfo, outInfo)#

Splits a request to RequestXXX() methods.

RequestDataObject(request, inInfo, outInfo)#

Overwritten by subclass to manage data object creation. There is not need to overwrite this class if the output can be created based on the OutputType data member.

RequestInformation(request, inInfo, outInfo)#

Overwritten by subclass to provide meta-data to downstream pipeline.

RequestUpdateExtent(request, inInfo, outInfo)#

Overwritten by subclass to modify data request going to upstream pipeline.

abstract RequestData(request, inInfo, outInfo)#

Overwritten by subclass to execute the algorithm.