[vtk-developers] Intersecting tables, documentation, and me

Jeff Baumes jeff.baumes at kitware.com
Tue Oct 12 15:37:18 EDT 2010


On Tue, Oct 12, 2010 at 3:09 PM, Kerr, Robert <rakerr at sandia.gov> wrote:

> Recently I've been working on something that involves
> vtkExtractSelectedRows.  I finally got my issues (well, at least my
> programming ones) worked out, and everything is peachy-keen.  But it was
> harder than I'd expected.  Here's a description of some of my frustration.
>
>
> Here's what I read about vtkExtractSelectedRows:
>
> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
> Detailed Description
>
> return selected rows of a table
>
> The first input is a vtkTable to extract rows from. The second input is a
> vtkSelection containing the selected indices. The third input is a
> vtkAnnotationLayers containing selected indices. The field type of the input
> selection is ignored when converted to row indices.
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> And yet, the first input isn't a vtkTable, rather it's a
> vtkAlgorithmOutput.  The second input is not a vtkSelection, rather it also
> is a vtkAlgorithmOutput.
>

You can use a vtkTable and vtkSelection as the inputs by doing the
following:

alg->SetInput(0, table);
alg->SetInput(1, selection);

These are convenience methods, and behind the scenes they do indeed call
GetProducerPort() internally. The indices are also only needed when
specifying a port other than the first port (port zero), which is the
default. These methods should not be used when making true pipeline
connections between one algorithm and another. In that case you generally do

alg->SetInputConnection(upstream_alg->GetOutputPort());

Notice that in all these cases, type checking is not explicit at compile
time. SetInput and SetInputConnection take vtkDataObject and
vtkAlgorithmOutput, respectively. This is to allow general API in the
algorithm superclass and also to give algorithms flexibility to input and
produce different types of data objects in different scenarios at runtime.

Scrabbling around through the docs, I found a link to a test case for
> vtkExtractSelectedRows, and was able to figure out the correct voodoo to
> make it work, but it certainly wasn't clear from the documentation.
>
> Is it just "understood" that when we say an input is a vtkTable we instead
> mean vtkTable->GetProducerPort() and so on?  Is this written anywhere in the
> docs?  I know I'm probably exposing my abysmal ignorance of all things VTK
> by speaking out here, but neither would I want to contribute to the VTK
> Conspiracy of 1492, which (I imagine) states that "knowing how to convert
> from a vtkTable to a vtkAlgorithmOutput is implicitly required for anyone
> using VTK".
>
>
The bulk of VTK documentation uses this language of "the first input is
such-and-such type", and you are right that this underlying knowledge of the
pipeline is often inferred. The VTK books do a good job of explaining the
pipeline model, is there perhaps no equivalent "VTK primer" on the wiki?

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


More information about the vtk-developers mailing list