Hello.
I’m using vtk in Python to view and make screenshots of some .ply files. I’m completely new to vtk, but i have managed to load and view vertices. How do I load the face element of .ply file and view them in render window?
This is my .ply header:
ply
format ascii 1.0
comment VCGLIB generated
element vertex 178241
property float x
property float y
property float z
property uchar red
property uchar green
property uchar blue
property uchar alpha
element face 356502
property list uchar int vertex_indices
property int flags
end_header
That example reads the PLY file and give it to a vtkActor object. That actor object has all the ply file data in a vtkPolyData object. So that includes the vertices and the faces. The actor is then given to the renderer for display.
If you just want to load a PLY file and than display it, that example does exactly that.
If you are completely new to VTK and using Python, I would highly recommend trying a wrapper around VTK like PyVista: https://docs.pyvista.org - VTK can be a bit tough to get started and PyVista (or vtkplotter) will streamline a lot of the nuanced routines you have to set up
Loading and plotting a PLY file with PyVista is as simple as:
import pyvista as pv
mesh = pv.read("my_file.ply")
mesh.plot()
Ok, thank you. I think I understand my problem now. I think my problem is with the face flags. It is used in MeshLab, and I thought it was universally used. What i need is to change the color of faces according to this flag. Is there an easy way to do this? From documentation it seems the vtkPLYReader will not read this flag.