I’m new to VTK and I try to use VTK9.1 + QT6 to display points cloud.
I found tutorials and examples for displaying points cloud with different color by calling SetScalar().
Here’s the code:
vtkSmartPointer points = vtkSmartPointer::New();
vtkSmartPointer colors = vtkSmartPointer::New();
colors->SetNumberOfComponents(3); // RGB
colors->SetName(“Colors”);
//Here’s code to read points cloud
points->InsertNextPoint(x,y,z);
//here’s code for color
…
unsigned char color[3] = {r, g, b};
colors->InsertNextTypedTuple(color);
//
// display
vtkSmartPointer polyData = vtkSmartPointer::New();
polyData->SetPoints(points);
// basically this is the typical way to add colors to points, but I cannot call SetScalars(colors) after “polyData->GetPointData()”. I don’t know how to fix this.
polyData->GetPointData()->SetScalars(colors);
can anyone help me ? I want a colorful points cloud model in the window.