Colour Lines / Triangles etc different colours

Hello, I was wondering if anyone could share an example where something like this was performed in Python. I am looking at colouring the lines / triangles etc. different colours.

https://kitware.github.io/vtk-examples/site/Cxx/Modelling/Delaunay3DDemo/

I thought something like this would work as a starting point but the colours (all red for now) are not showing.

triangulator = vtk.vtkDelaunay2D()
triangulator.SetAlpha(alphaValue)

triangulator.SetInputDataObject(data)

cellData = vtk.vtkUnsignedCharArray()
cellData.SetName("colors")
cellData.SetNumberOfComponents(3)

for i in range(triangulator.GetOutput().GetNumberOfCells()):                
    cellData.InsertNextTypedTuple((255,0,0))

triangulator.GetOutput().GetCellData().SetScalars(cellData)

mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(triangulator.GetOutputPort())
mapper.SetScalarModeToUseCellData()

sProp = vtk.vtkProperty()
sProp.SetOpacity(1.0)
actor = vtk.vtkActor()
actor.SetProperty(sProp)
actor.SetMapper(mapper)

...

Hello,

You’re assigning three scalar values to each cell, that is, tuples valued 255,0,0. You didn’t tell VTK how to translate these into colors. You need to use a vtkLookupTable to do that:

(...)
    lut = vtkLookupTable()

    mapper = vtkPolyDataMapper()
    mapper.SetLookupTable(lut)
    mapper.SetInputConnection(triangulator.GetOutputPort())
    mapper.SetScalarRange(0, 255)

    actor = vtkActor()
    actor.SetMapper(mapper)
(...)

Based on the complete example code here: https://kitware.github.io/vtk-examples/site/Python/Rendering/Rainbow/

regards,

Paulo