[vtkusers] Converting code to a vtk filter

David Doria daviddoria+vtk at gmail.com
Tue Aug 11 10:29:40 EDT 2009


I had some code whose input and output was like this:

Scanner->SetScene(vtkPolyData*);
vtkPolyData* output = Scanner->GetOutputPolyData();

I changed my class to inherit from public vtkPolyDataAlgorithm, and I added
this function (the "information" bits were stolen from
vtkTransformPolyDataFilter)

int vtkLidarScanner::RequestData(vtkInformation *vtkNotUsed(request),
        vtkInformationVector **inputVector,
  vtkInformationVector *outputVector)
{
  // get the info objects
    vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
    vtkInformation *outInfo = outputVector->GetInformationObject(0);

  // get the input and ouptut
    vtkPolyData *input = vtkPolyData::SafeDownCast(
            inInfo->Get(vtkDataObject::DATA_OBJECT()));
    vtkPolyData *output = vtkPolyData::SafeDownCast(
            outInfo->Get(vtkDataObject::DATA_OBJECT()));

    this->SetScene(input);
    std::cout << *input << std::endl;

    this->PerformScan();

    output = this->GetOutputPolyData();

    return 1;
}

The cout of the input seems that it was received correctly, and the cout of
the output seems that it was built correctly. I am then trying to use the
class with:

    Scanner->SetInput(reader->GetOutput());
    vtkSmartPointer<vtkXMLPolyDataWriter> writer =
vtkSmartPointer<vtkXMLPolyDataWriter>::New();
    writer->SetFileName(OutputFilename.c_str());
    writer->SetInput(Scanner->GetOutput());
    writer->Write();

But the file that is written is empty. Is there anything else I have to do
to get this to work as an algorithm filter?

Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090811/97e04b93/attachment.htm>


More information about the vtkusers mailing list