[vtkusers] Empty output of vtkImageAlgorithm subclass

David Doria daviddoria+vtk at gmail.com
Wed Jan 20 08:28:32 EST 2010


I have created a class derived from vtkImageAlgorithm called
vtkVoxelizePolyData.

To set the output of the new filter, in RequestData (as usual) I did:

vtkInformation *outInfo = outputVector->GetInformationObject(0);
 vtkImageData *output = vtkImageData::SafeDownCast(
                 outInfo->Get(vtkDataObject::DATA_OBJECT()));

vtkSmartPointer<vtkImageData> grid = vtkSmartPointer<vtkImageData>::New();

.... fill grid....

output->ShallowCopy(grid);

I know 'grid' is valid at this point because just before the end of
RequestData I did:

 vtkSmartPointer<vtkXMLImageDataWriter> writer =
     vtkSmartPointer<vtkXMLImageDataWriter>::New();
 writer->SetFileName("insideFilter.vti");
 writer->SetInput(grid);
 writer->Write();

 output->ShallowCopy(grid);

and it looks correct in paraview.

However, if I run the filter and write the file of the filter output,
it is empty!

 vtkSmartPointer<vtkVoxelizePolyData> voxelize =
vtkSmartPointer<vtkVoxelizePolyData>::New();
 voxelize->SetInput(reader->GetOutput());
 voxelize->Update();

 vtkImageData* voxelized = voxelize->GetOutput();

 vtkSmartPointer<vtkXMLImageDataWriter> writer =
vtkSmartPointer<vtkXMLImageDataWriter>::New();
 writer->SetFileName(outputFilename.c_str());
 writer->SetInput(voxelized);
 writer->Write();

Any thoughts on what could be going wrong here??

Thanks,

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


More information about the vtkusers mailing list