[vtk-developers] SetStencilConnection() in vtkImageAlgorithm

David Gobbi david.gobbi at gmail.com
Fri Nov 19 16:55:17 EST 2010


Hi Berk,

Since I've caught your ear, I might as well get your opinion on one
other matter.  It also has to do with image stencils.

Right now some filters have a SetStencil() method that takes a
vtkImageStencilData object directly.  I'm converting these to
SetStencilConnection() methods.  But I'm thinking of adding the
SetStencilConnection() method directly to vtkImageAlgorithm, and
here is why: I want to be able to probe any ImageAlgorithm to see
if that algorithm accepts a stencil as an input (and I want to make
more of the existing image filters use stencils, I've written an iterator
to simplify this.)

In my proposal, an image algorithm that uses a stencil will do this in
its constructor:

vtkSomeFilter::vtkSomeFilter()
{
  this->SetNumberOfInputs(2);
  this->SetStencilPortNumber(1);
}

The default value of StencilPortNumber set to -1 by vtkImageAlgorithm
(i.e. no stencil input), so the existence of a stencil port can be
checked.  The vtkImageAlgorithm::SetStencilConnection() method
will connect its argument to the port, or do nothing if the port is -1.
You can see the new vtkImageAlgorithm code on Gerrit:

http://review.source.kitware.com/388

If you think that SetStencilConnection() belongs in the individual
filters (e.g. like SetSelectionConnection()) then that is fine. The
only answer I will not accept is "derive a new base class from
vtkImageAlgorithm". ;)

  David



More information about the vtk-developers mailing list