[vtk-developers] RE: vtkAlgorithm suggestion

Miller, James V (Research) millerjv at crd.ge.com
Tue Mar 9 11:08:02 EST 2004

I wouldn't think speed would be an issue.  It's not like you set/get
inputs and outputs in an inner loop.

I imagine the issue with typos (people mispelling a input/output) still
exists with indices. You also have to be careful with indices in 
vtkProcessObject because a user could call
which could, for instance, "move" input #3 to be input #2.

-----Original Message-----
From: Brad King [mailto:brad.king at kitware.com]
Sent: Tuesday, March 09, 2004 10:45 AM
To: Miller, James V (Research)
Cc: Vtk Developers (E-mail)
Subject: Re: vtkAlgorithm suggestion

Miller, James V (Research) wrote:

> I just saw the vtkAlgorithm classes in the respository.  I have a 
> suggestion. I noticed the "inputs" and "outputs" are indexed based 
> (inputs are specified via a numeric id).  I think implementing 
> subclasses of Algorithm will be cleaner if the inputs and outputs are 
> specified via strings.  The developer can indicate whatever string names 
> they want to associate with their inputs and outputs.  If none are 
> specified, a default like "Input0" could be used.

This was the approach used in one of our earlier design iterations. 
However, the implementation of the algorithms and executives is much 
simpler and faster when an index is used.  Also if there is a typo in 
the string we do not know until runtime.  There are other and safer ways 
to provide a name-based connection interface.

> The code may look like:
> someAlgorithm->SetInputConnection("gradient", 
> someOtherAlgorithm->GetOutputConnection("gradient"));
> or something like that.

My idea is that one of these approaches can be used:




or a string-based interface could still be added by particular 
algorithms with code like:

void vtkSomeAlgorithm::SetInputConnection(const char* name, /*...*/)
   if(strcmp(name, "gradient") == 0)
     this->Superclass::SetInputConnection(0, /*...*/);

All of these approaches allow the internal implementation to continue to 
use indices.  The second one is probably the best because it may easily 
be used from the wrapping languages and provides a compile-time check 
for valid input/output port names.


More information about the vtk-developers mailing list