[vtk-developers] Which class to derive from for filter with input: PolyData, output: Graph
David Doria
daviddoria+vtk at gmail.com
Wed Nov 11 16:06:28 EST 2009
On Wed, Nov 11, 2009 at 3:58 PM, David E DeMarle
<dave.demarle at kitware.com> wrote:
> That specific error message means that some filter in your program is
> expecting something on one of its inputs, but doesn't have anything
> connected there.
>
> To fix that, find out why nothing is connected to that input in your
> application and fix it.
>
> If the algorithm never takes an input, like for a source, set the
> number of inputs to zero (see vtkConeSource for example.)
>
> If the algorithm can take a source, but doesn't have to, mark the
> input as optional. Search for INPUT_IS_OPTIONAL for examples.
>
> David E DeMarle
This is the simplest case: 1 required input. I know that is the
default for vtkPolyDataAlgorithm so I guess I just assumed it would be
the same for vtkGraphAlgorithm - is it not?
The test code is very simple:
vtkSmartPointer<vtkXMLPolyDataReader> Reader =
vtkSmartPointer<vtkXMLPolyDataReader>::New();
Reader->SetFileName("SpherePoints.vtp");
Reader->Update();
vtkSmartPointer<vtkNearestNeighborGraph> NearestNeighborGraphFilter
= vtkSmartPointer<vtkNearestNeighborGraph>::New();
NearestNeighborGraphFilter->SetInput(Reader->GetOutput());
NearestNeighborGraphFilter->Update();
//convert the graph to a polydata
vtkSmartPointer<vtkGraphToPolyData> GraphToPolyData =
vtkSmartPointer<vtkGraphToPolyData>::New();
GraphToPolyData->SetInput(NearestNeighborGraphFilter->GetOutput());
GraphToPolyData->Update();
//write the result to a vtp file
vtkSmartPointer<vtkXMLPolyDataWriter> Writer =
vtkSmartPointer<vtkXMLPolyDataWriter>::New();
Writer->SetInput(GraphToPolyData->GetOutput());
Writer->SetFileName("GraphPolyData.vtp");
Writer->Write();
As you can see, I have called SetInput on all of the filters except the Reader.
Any more ideas?
Thanks,
David
More information about the vtk-developers
mailing list