I want to initialize a vtkPolyData
instance using a vtkFloatArray
whose three components describe the Cartesian coordinates of the points of a point cloud.
Currently, I create a vtkPoints
instance and do the following:
vtkNew<vtkPoints> points;
for (unsigned int i = 0; i < 1000; i++)
points->InsertNextPoint(i, 2*i, 3*i); // arbitrarily chosen
vtkNew<vtkPolyData> polyData;
polyData->SetPoints(points);
However, I want to use a vtkFloatArray
to store the coordinates as the coordinates are already stored in memory at float *coordPtr
.
vtkNew<vtkFloatArray> coords;
coords->SetNumberOfComponents(3); // x, y, and z in Cartesian space
coords->SetNumberOfTuples(1000);
coords->SetArray(coordPtr, 1000, 1);
How can I link the vtkPoints
instance to coords
or can I set the coordinates of polyData
directly using coords
? The overall goal is to visualize a 3D point cloud.