[vtk-developers] question about vtkAlgorithm and pipeline operations

Brad King brad.king at kitware.com
Wed Aug 24 17:01:43 EDT 2005


Simon Warfield wrote:
> When a vtkImageAlgorithm attempts to set the input at an index, it gets 
> forwarded up the class hierarchy to a method which sets the input for a 
> port, rather than on the default input port at a particular index.  Of 
> course, a port and an index are both just integers so there is no type 
> problem in doing this, but I think it is not what was intended based on 
> the variable naming and the inability for me to find any way to set a 
> particular input connection at a given index on a specific port.
> 
> Could somebody who knows more than me about the vtk pipeline mechanism 
> and the intended operation of this take a look at it ?

Old-pipeline VTK filters had only an input index and no notion of a 
port.  Some filters used each index for an input with a specific purpose 
(like glyph).  Others used each index for multiple connections with the 
same purpose (like append).  This led to a few filters in which inputs 0 
and 2..N were used for one purpose and input 1 was used for another 
purpose.  To solve this problem the idea of each port having a specific 
purpose was introduced.

For backward-compatibility vtkImageAlgorithm tries to translate old 
SetInput calls into SetInputConnection calls.  This works well because 
most image algorithms used each index for a specific purpose, so the 
old-pipeline index becomes a new-pipeline port.  The few algorithms for 
which this was not the case were converted to know about the ports.

The reason SetNthInputConnection is not public is that new-pipeline 
filters are not supposed to have to worry about NULL connections.  They 
can simply get the number of connections on a port and loop through 
them.  Use of SetNthInputConnection makes it easy to introduce NULL 
connections.  Therefore it is available only for filters (subclasses) 
that know how to deal with NULL connections.

Typical usage of multiple connections to one port was expected to mean 
SetInputConnection(port, 0) followed by N calls to 
AddInputConnection(port, ...) for all the desired connections in order.

-Brad



More information about the vtk-developers mailing list