[vtkusers] Extract color information per vertex

Bing Jian bing.jian at gmail.com
Thu May 9 19:38:24 EDT 2019


Hi vtkusers,

I have a quick question about reading the color information stored in a ply
file.

The following code extracts the xyz coordinate of a given vertex, but how
to read the RGB value associated to each vertex?

vtkSmartPointer<vtkPLYReader> reader = vtkSmartPointer<vtkPLYReader>::New();
reader->SetFileName("input_with_color.ply");
reader->Update();

vtkSmartPointer<vtkPolyData> polyData = reader->GetOutput();
vtkSmartPointer<vtkPoints> vertices = polyData->GetPoints();
double xyz[3];
vertices->GetPoint(idx, xyz);

I guess we can use
polyData->GetPointData()->GetArray("???")
but not sure how to do that.  Would appreciate any pointers or examples!

Thanks,
Bing
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20190509/82055865/attachment.html>


More information about the vtkusers mailing list