How to draw division lines between colors on the surface of the grid?

I use vtkUnstructuredGrid to display a grid and display relevant cloud images. There is a clear division between cloud image colors. How to draw division lines between colors on the surface of the grid.

image

import vtk


grid = vtk.vtkUnstructuredGrid()


points = vtk.vtkPoints()
points.InsertNextPoint(0, 0, 0)
points.InsertNextPoint(1, 0, 0)
points.InsertNextPoint(1, 1, 0)
points.InsertNextPoint(0, 1, 0)
grid.SetPoints(points)


cellArray = vtk.vtkCellArray()
cellArray.InsertNextCell(4)
cellArray.InsertCellPoint(0)
cellArray.InsertCellPoint(1)
cellArray.InsertCellPoint(2)
cellArray.InsertCellPoint(3)
grid.SetCells(vtk.VTK_QUAD, cellArray)


scalars = vtk.vtkFloatArray()
scalars.SetNumberOfComponents(1)
scalars.InsertNextValue(0)
scalars.InsertNextValue(1)
scalars.InsertNextValue(2)
scalars.InsertNextValue(3)
# grid.GetCellData().SetScalars(scalars)
grid.GetPointData().SetScalars(scalars)


lut = vtk.vtkLookupTable()
lut.SetNumberOfColors(9)
lut.SetHueRange(0.688, 1.0)


mapper = vtk.vtkDataSetMapper()
mapper.SetInputData(grid)
mapper.SetScalarRange(0, 3)
mapper.SetLookupTable(lut)
mapper.SetInterpolateScalarsBeforeMapping(1)


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



renderer = vtk.vtkRenderer()
renderer.AddActor(actor)

renderer.SetBackground(1.0, 1.0, 1.0)
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)

interactor = vtk.vtkRenderWindowInteractor()
style = vtk.vtkInteractorStyleTrackballCamera()
interactor.SetInteractorStyle(style)
interactor.SetRenderWindow(renderWindow)


renderWindow.Render()
interactor.Start()


Hello,

I believe you need something like this: Unity mesh shader for outlining colour changes - Game Development Stack Exchange . There, the accepted solution has a shader code that you can use in your mapper to achieve the effect you want. If you don’t know how to set shaders for your mapper, please take a look at this: https://gitlab.kitware.com/vtk/vtk/blob/v7.0.0.rc2/Rendering/OpenGL2/Testing/Cxx/TestUserShader2.cxx .

regards,

PC