I have a ply file, which is generated from Solidworks
: cube.PLY (137 KB). This ply file is colored.
I want to load it, and display it with vtk. My code is:
import vtkmodules.all as vtk
reader = vtk.vtkPLYReader()
reader.SetFileName('.\\cube.PLY')
reader.Update()
polyData = reader.GetOutput()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputData(polyData)
mapper.SetScalarModeToUseCellData()
mapper.ScalarVisibilityOn()
actor = vtk.vtkActor()
actor.SetMapper(mapper)
renderer = vtk.vtkRenderer()
renderer.AddActor(actor)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(renderer)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
iren.Initialize()
iren.Start()
However, it do not show with color. How can I load a ply file with color?