In VTK, points are only 3D coordinates. They serve as a support for cells.
To have a valid point cloud, you need:
- a
vtkDataSet
that support explicit points, here we will use avtkPolyData
- the
vtkPoints
containing the points, which you already have - the
vtkCellArray
containing the cells so you have a valid VTK data set
We can construct one like that:
// vtk data set to fill
vtkNew<vtkPolyData> myPolyData;
// compute a vtkIdList that contains ids of each points
vtkIdType numPoints = myVtkPoints->GetNumberOfPoints();
vtkSmartPointer<vtkIdList> pointIds = vtkSmartPointer<vtkIdList>::New();
pointIds->SetNumberOfIds(numPoints);
for (vtkIdType i = 0; i < numPoints; ++i)
{
pointIds->SetId(i, i);
}
// create a vtkCellArray from this list
vtkSmartPointer<vtkCellArray> polyPoint = vtkSmartPointer<vtkCellArray>::New();
polyPoint->InsertNextCell(pointIds);
// give the points and cells to the final poly data
myPolyData->SetPoints(myVtkPoints);
myPolyData->SetVerts(polyPoint);
In this code, I assume you have myVtkPoints
that is the vtkPoints
containing the positions of points in your point cloud