VTK using VoxelModeller to build Voxel Space of Point Cloud

1.8k Views Asked by At

Here's what I'd like to do: I have a .pcd (PCL standard format) file in which it's stored a Point Cloud, I would like to build a voxel representation of it and then extract an isosurface. If I'm not wrong, I should follow this example http://www.vtk.org/Wiki/VTK/Examples/Cxx/Modelling/MarchingCubes, where I should set my pcd as input to vtkVoxelModeller instead of the sphere.

So I tried in this way:

//-------------------------------------------------------------------------
// loading Point Cloud
//-------------------------------------------------------------------------
pcl::PointCloud<PointType>::Ptr cloud (new pcl::PointCloud<PointType>);
std::string inputFilename = "GiraffeHead_2.pcd";
if (pcl::io::loadPCDFile<PointType> (inputFilename.c_str(), *cloud) == -1)
{
    PCL_ERROR ("Couldn't read file test_pcd.pcd \n");
    return (-1);
}

PointType min_pt,max_pt;
pcl::getMinMax3D(*cloud,min_pt,max_pt);
...
//-------------------------------------------------------------------------
// copying Point Cloud into PolyData
//-------------------------------------------------------------------------
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
for (size_t i = 0; i < cloud->points.size (); ++i)
    points->InsertNextPoint(cloud->points[i].x,cloud->points[i].y,cloud->points[i].z);

vtkSmartPointer<vtkPolyData> PCData = vtkSmartPointer<vtkPolyData>::New();
PCData->SetPoints(points);

the rest of the code is taken from the example and the only modifications I make is to set the bounds according to my surface and:

voxelModeller->SetInputConnection(PCData->GetProducerPort());

when I run the executable I get an empty window :(

Since I'm a newbie with VTK and I strongly need it for my research project I'd be very glad if someone could explain me what I'm doing wrong and point out a correct solution.

Thanks

1

There are 1 best solutions below

0
On

I found out that this tutorial was deprecated.

Following:

http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/ImplicitModeller

and

http://www.paraview.org/Wiki/ParaView/PCL_Plugin

made the trick!