[vtk-developers] Which class to derive from for filter with input: PolyData, output: Graph

Jeff Baumes jeff.baumes at kitware.com
Fri Nov 20 09:47:53 EST 2009


>
> Does vtkGraphAlgorithm not work basically the same as vtkPolyDataAlgorithm?
>

Yes, basically. All that most of these algorithm superclasses do are
set the default algorithm properties to have one input and one output,
both a specific type (e.g. graph or polydata). All this behavior can
be overridden in subclasses, so they are really just a convenience.
With a few extra lines of code you could directly inherit from
vtkAlgorithm. Generally speaking, people use the type of algorithm
superclass corresponding to the type of the output of the filter, then
override input connection settings as necessary.

The one other convenience is that the GetOutput() method returns the
specific type, so you don't have to use SafeDownCast. There are a
couple other tiny things these superclasses do, but conceptually that
is it.

It is unsafe to use the legacy GetOutput() / SetInput() methods to
connect pipeline objects. They were supported for backwards
compatibility when VTK's pipeline went through an overhaul, but newer
stuff added after that (e.g. infovis/graph stuff) do not provide
testing that this works in all cases. Do you still get your errors if
you use the correct way to do things now: GetOutputPort() /
SetInputConnection()?

Jeff



More information about the vtk-developers mailing list