[vtk-developers] Image multiple input filters, VTK 5 vs VTK 4
David Gobbi
dgobbi at atamai.com
Wed Apr 5 17:49:18 EDT 2006
Mathieu Malaterre wrote:
>> 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.
There already is a RemoveInputConnection, but the problem
is that it isn't possible to remove a connection from a specific
location in the list. Also, there would have to be a method to
insert a connection at a specific position in the list:
DeleteInputConnection(int port, int idx);
InsertInputConnection(int port, int idx, vtkAlgorithmOutput *);
I called the first method "Delete" instead of "Remove" because
overloading the "Remove" method would just lead to confusion.
Of course "Delete" isn't a good name... anyone know of a better
synonym for remove?
In any case, I do not strongly advocate the above methods.
I understand the concerns with SetNthInputConnection and
think that the best solution would be to make it public only
in the few filters that properly check for null inputs. That
would be a 100% solution for me.
> As David says all I need is a way to set *either* connection. You
> don't always have access to the other input.
>
> So maybe something like -in python ;)-
>
> blend = vtk.vtkImageBlend()
> blend.GetInputConnection(0).Set(0 ,background)
> blend.GetInputConnection(0).Set(1, foreground)
That would look really funny in Tcl:
[blend GetInputConnection 0] Set 0 background
I vote no ;)
- David
More information about the vtk-developers
mailing list