[vtk-developers] Image multiple input filters, VTK 5 vs VTK 4

Berk Geveci berk.geveci at gmail.com
Wed Apr 5 16:55:45 EDT 2006


> As a side note, I would like to move the protected function to the
> public ones:
>
> vtkAlgorithm:
> virtual void SetNthInputConnection(int port, int index,
>                    vtkAlgorithmOutput* input);
>
>
> So that VTK44 code:
>
> vtkImageBlend blend
> blend SetInput 0 background
> blend SetInput 1 foreground
>
> becomes:
>
> vtkImageBlend blend
> blend SetNthInputConnection 0 0 background
> blend SetNthInputConnection 0 1 foreground
>
> Comments ?

I had a chat with Brad about this. We don't think you should do this.
>From the documentation of vtkAlgorithm:

  // Replace the Nth connection on the given input port.  For use only
  // by this class and subclasses.  If this is used to store a NULL
  // input then the subclass must be able to handle NULL inputs in its
  // ProcessRequest method.
  virtual void SetNthInputConnection(int port, int index,
                                     vtkAlgorithmOutput* input);

It is clearly not intended to be public. The reason behind this is the
fact that it is NOT allowed to have NULL connections unless the
algorithm has special code to handle them. Making this function public
would allow everybody to create empty connections and potentially
introduce bugs. AddInputConnection does not. If a filter has multiple
input connections, the order things are added should not matter. If
the order matters, the filter should have multiple input ports
instead. Therefore, AddInputConnection() is the only method that is
necessary to add connections.

Maybe we should introduce a RemoveInputConnection() method instead?
Obviously, this would have to move things around so that there is no
NULL input connection. Would this help David? You could simply remove
a connection and replace it with AddConnection.

-Berk



More information about the vtk-developers mailing list