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

David Doria daviddoria+vtk at gmail.com
Wed Nov 11 15:47:49 EST 2009


On Wed, Nov 11, 2009 at 1:41 PM, David Doria <daviddoria+vtk at gmail.com> wrote:
> What are the differences between deriving from vtkPolyDataAlgorithm vs
> deriving from vtkGraphAlgorithm? I've seen that you are supposed to
> derive from the algorithm class that matches the type of your output.
> However, it seems that you can change the input to an arbitrary data
> type using:
>
> int vtkYourilter::FillInputPortInformation( int port, vtkInformation* info )
> {
>  if (!this->Superclass::FillInputPortInformation(port, info))
>    {
>    return 0;
>    }
>
>  if ( port == 0)
>    {
>    info->Set( vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPolyData" );
>    return 1;
>    }
> }
>
> Is this correct then? Should I derive from vtkGraphAlgorithm and set
> the input to expect a vtkPolyData using the above method?
>
> Thanks,
>
> David
>

Here is my attempt at deriving from vtkGraphAlgorithm and setting the
input port type to vtkPolyData:
http://rpi.edu/~doriad/VTK_List/vtkNearestNeighborGraph/

I get a bunch of these:
vtkStreamingDemandDrivenPipeline (0x89d60a0): Input port 0 of
algorithm vtkGraphToPolyData(0x89d5ac8) has 0 connections but is not
optional.

I changed the input port to expect a vtkPolyData with:
  if (port == 0)
  {
    info->Set( vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPolyData" );
    return 1;
  }

and I changed the cast of the output information:
  vtkGraph *output = vtkGraph::SafeDownCast(
      outInfo->Get(vtkDataObject::DATA_OBJECT()));

Is there anything else I need to do?

Thanks,

David



More information about the vtk-developers mailing list