vtkmodules.util.execution_model#

Utility classes to help with the simpler Python interface for connecting and executing pipelines.

Module Contents#

Classes#

select_ports

Helper class for selecting input and output ports when connecting pipeline objects with the >> operator. Example uses:

Pipeline

Pipeline objects are created when 2 or more algorithms are connected with the >> operator. They store the first and last algorithms in the pipeline and enable connecting more algorithms and executing the pipeline. One should not have to create Pipeline objects directly. They are created by the use of the >> operator.

Output

Helper object to represent the output of an algorithms as returned by the update() method. Implements the output property enabling calling update().output.

Functions#

_call

Set the input of the first filter, update the pipeline and return the output.

Data#

API#

vtkmodules.util.execution_model.__all__#

[‘select_ports’, ‘Pipeline’, ‘Output’]

vtkmodules.util.execution_model._call(first, last, inp=None, port=0)#

Set the input of the first filter, update the pipeline and return the output.

class vtkmodules.util.execution_model.select_ports(*args)#

Bases: object

Helper class for selecting input and output ports when connecting pipeline objects with the >> operator. Example uses:

Connect a source to the second input of a filter.

source >> select_ports(1, filter)

Connect the second output of a source to a filter.

select_ports(source, 1) >> filter

Combination of both: Connect source to second

input of the filter, then connect the second

output of that filter to another one.

source >>> select_ports(1, filter, 1) >> filter2

Initialization

This constructor takes 2 or 3 arguments. The possibilities are: select_ports(input_port, algorithm) select_ports(algorithm, output_port) select_ports(input_port, algorithm, output_port)

SetInputConnection(inp)#

Forwards to underlying algorithm and port.

AddInputConnection(inp)#

Forwards to underlying algorithm and port.

GetOutputPort()#

Returns the output port of the underlying algorithm.

GetInputPortInformation(port)#
update()#

Execute the algorithm and return the output from the selected output port.

__rshift__(rhs)#

Creates a pipeline between the underlying port and an algorithm.

__rrshift__(lhs)#

Creates a pipeline between the underlying port and an algorithm. This is to handle sequence >> select_ports where the port can accept multiple connections.

__call__(inp=None)#

Executes the underlying algorithm by passing input data to the selected input port. Returns a single output or a tuple if there are multiple outputs.

class vtkmodules.util.execution_model.Pipeline(lhs, rhs)#

Bases: object

Pipeline objects are created when 2 or more algorithms are connected with the >> operator. They store the first and last algorithms in the pipeline and enable connecting more algorithms and executing the pipeline. One should not have to create Pipeline objects directly. They are created by the use of the >> operator.

Initialization

Create a pipeline object that connects two objects of the following type: data object, pipeline object, algorithm object.

PIPELINE#

0

ALGORITHM#

1

DATA#

2

UNKNOWN#

3

_connect(lhs, rhs, rhs_alg, connect_method)#
_determine_type(arg)#
update(**kwargs)#

Update the pipeline and return the last algorithm’s output.

__call__(inp=None)#

Sets the input of the first filter, update the pipeline and returns the output. A single data object or a tuple of data objects (when there are multiple outputs) are returned.

__rshift__(rhs)#

Used to connect two pipeline items. The left side can be a data object, an algorithm or a pipeline. The right side can be an algorithm or a pipeline.

__rrshift__(lhs)#

Creates a pipeline between a sequence input and a pipeline.

class vtkmodules.util.execution_model.Output(algorithm, **kwargs)#

Bases: object

Helper object to represent the output of an algorithms as returned by the update() method. Implements the output property enabling calling update().output.

Initialization

property output#

Returns a single data object or a tuple of data objects if there are multiple outputs.