How to read a custom formatted PLY file?

I would like to know if VTK can load a PLY file of the following format.


File header)
ply
format binary_little_endian 1.0
comment Zivid Point Cloud
element vertex 2304000
property float x
property float y
property float z
property uchar red
property uchar green
property uchar blue
end_header


Code)
vtkSmartPointer reader = vtkSmartPointer::New();

reader->SetFileName(file_path.c_str());


char* c = reader->GetFileName();

// Visualize
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(reader->GetOutputPort(0));

vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);

vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();


vtkSmartPointer<vtkRenderWindow> renderWindow = vtkSmartPointer<vtkRenderWindow>::New();

renderWindow->AddRenderer(renderer);


vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New();

renderWindowInteractor->SetRenderWindow(renderWindow);

renderer->AddActor(actor);

renderer->SetBackground(0.1804, 0.5451, 0.3412); // Sea green

renderWindow->Render();

renderWindowInteractor->Start();

please share an actual .ply file

Your reader is just a vtkSmartPointer. Have you tried vtkPLYReader?

Sorry for late reply. I’ll give you a link to the PLY file in question.

One line of code at the top of the text is missing.

vtkSmartPointer < vtkPLYReader > reader = vtkSmartPointer < vtkPLYReader > ::New();

The reader object is a vtkPLYReader.
Is there any code I can add?

vtkPLYReader can read it fine, just make sure you are displaying your single poly vertex cell correctly.

Number of points: 2304000
Number of polygons: 0
Number of lines: 0
Number of vertices: 1