[vtk-developers] naming/accessing pipeline inputs

Jeff Baumes jeff.baumes at kitware.com
Mon Nov 2 08:25:52 EST 2009


On Sun, Nov 1, 2009 at 11:35 AM, David Doria
<daviddoria+vtk at gmail.com<daviddoria%2Bvtk at gmail.com>
> wrote:

> 1) At the beginning of a RequestData function for a filter, this is
> typically the first thing:
>
>   // get the info object
>   vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
>
>   // get the input
>   vtkPolyData *input = vtkPolyData::SafeDownCast(
>
> inInfo->Get(vtkDataObject::DATA_OBJECT()));
>
> If there are multiple inputs, do I need to do:
>   vtkInformation *inInfo = inputVector[0]->GetInformationObject(1); //1
> instead of 0 here? Or should it be inputVector[1]?
>
>   // get the second input input
>   vtkPolyData *input1 = vtkPolyData::SafeDownCast(
>
> inInfo->Get(vtkDataObject::DATA_OBJECT()));
>
> to get the second input? Is there a way to access the inputs by a name
> instead of depending on the order? That is, instead of saying first input,
> second input, etc, can you say MyBigInput, MyOtherInput so the order does
> not matter?
>

They must always be accessed by index, there is no way to "name" the port.
Several classes have convenience methods for setting the input externally
(or input connection) such as

void SetGlyphInput(vtkPolyData* input);
void SetGlyphInputConnection(vtkAlgorithmOutput* connection);

These just call SetInput/Connection with the appropriate index. You can
always add even more syntactic sugar to help yourself out, like an enum in
the class:

enum {
  BIG_INPUT = 0,
  OTHER_INPUT = 1
};

so that your code looks a bit cleaner when you are referring to input
indices.


> 2) In my FillInputPortInformation function, I have been doing: (for a
> filter with 4 inputs)
>
>   if (!this->Superclass::FillInputPortInformation(port, info))
>     {
>     return 0;
>     }
>   if ( port >= 0 && port <=3 )
>     {
>     info->Set( vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPolyData" );
>     return 1;
>     }
>
> It seems that 'port' is never used anywhere - is this the correct way to
> tell the pipeline the type of the 4 inputs? Is the correct 'info' object
> automatically passed when the FillInputPortInformation function is called
> with the corresponding port number?
>

What you have looks fine. Yes, it is called with a different vtkInformation
for each port, so that's all you need to do.


>
> 3) When making a Paraview plugin for a vtk filter, in the XML I will do
> something like
>       <InputProperty
>          name="Source"
>
> to tell Paraivew to make an input connection. Since these inputs are not
> named in the vtk filter, is paraview associating the first InputProperty
> that appears in the xml with input 0 of the filter, etc?
>
>
I'd go to the paraview list for this one.

Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20091102/ead8b09c/attachment.html>


More information about the vtk-developers mailing list