I want to add colour to the vtkTetra itself, not its points. Could anyone give me a example?
This example is add color to the points vtk-examples/Cube.py at aa1716a165150f338f6182ce1ac174334f3b9003 · Kitware/vtk-examples · GitHub.
Just add the scalars to the cells instead of the points, see line 84:
cube.GetPointData().SetScalars(scalars)
should become
cube.GetCellData().SetScalars(scalars2)
where scalars2
has the appropriate size (the number of cells in cube
) which is 6 for this example.
Thanks for your reply. I have another question is how to change the colour in real-time? I want to change the scalar and then make the cube color change in real-time? Are there any similar cases? Thanks !