我想使用Visualization Toolkit来绘制绘图点,每个点都会有不同的颜色。我使用了here给出的建议以灰色绘制点,但我没有理解如何为每个点赋予颜色。使用VTK绘制不同颜色的点
立方体示例的相关部分:
vtkPolyData *cube = vtkPolyData::New();
vtkPoints *points = vtkPoints::New();
vtkCellArray *polys = vtkCellArray::New();
vtkFloatArray *scalars = vtkFloatArray::New();
// Load the point, cell, and data attributes.
for (i=0; i<8; i++) points->InsertPoint(i,x[i]);
for (i=0; i<6; i++) polys->InsertNextCell(4,pts[i]);
for (i=0; i<8; i++) scalars->InsertTuple1(i,i);
// We now assign the pieces to the vtkPolyData.
cube->SetPoints(points);
points->Delete();
cube->SetVerts(polys);
polys->Delete();
cube->GetPointData()->SetScalars(scalars);
scalars->Delete();
我怎么可以给每个绿党的颜色?