[vtkusers] Voxelize a point cloud (vtkVoxelModeller?)

David Doria daviddoria+vtk at gmail.com
Sat Oct 31 15:56:11 EDT 2009


I am trying to take a set of points and insert it into a voxelized 3d grid.
That is, the input is an unstructured point set (vtkPoints or similar) and
the output would be a structure that you can do something like the following
after voxelizing the points into a 10x10x10 grid:

for(int x = 0; x < 10; x++)
  for(int y = 0; y < 10; y++)
   for(int z = 0; z < 10; z++)
     cout << "Grid cell " << x << " " << y << " " << z << " has " <<
Grid->GetNumberOfPointsInVoxel(x,y,z) << " points.";

I saw vtkVoxelModeller, but I tried this: (compilable example here:
http://rpi.edu/~doriad/VTK_List/vtkVoxelModeller/)

    vtkSmartPointer<vtkXMLPolyDataReader> Reader =
vtkSmartPointer<vtkXMLPolyDataReader>::New();
    Reader->SetFileName(InputFilename.c_str());
    Reader->Update();

    vtkSmartPointer<vtkVoxelModeller> voxelModel =
vtkSmartPointer<vtkVoxelModeller>::New();
    voxelModel->SetInput(Reader->GetOutput());
    voxelModel->SetSampleDimensions(10, 10, 10);
    voxelModel->SetModelBounds(-1.5, 1.5, -1.5, 1.5, -1.5, 1.5);

    vtkSmartPointer<vtkXMLImageDataWriter> Writer =
vtkSmartPointer<vtkXMLImageDataWriter>::New();
    Writer->SetFileName(OutputFilename.c_str());
    Writer->SetInput(voxelModel->GetOutput());
    Writer->Write();

but I get a whole bunch of unsupported data type errors:

vtkXMLImageDataWriter (0x86a53d8): Unsupported data type: 1
vtkXMLImageDataWriter (0x86a53d8): Data type size 0 not supported by VTK XML
format.

Am I expecting the correct thing from this filter? Where have I messed up
the data types?

Thanks,

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


More information about the vtkusers mailing list