I want to draw a polyon on the vtkImageViewer2 and colored it ?
A good start to see how to draw a polygon can be found here: https://github.com/Kitware/VTK/blob/8b08cf7a0523d88a5602a98c0456f7e397560698/Common/DataModel/Testing/Cxx/TestPolygon.cxx
I draw 2d wireframe overlays of 3d geometry in my own program on a slice viewer using vtkImageViewer2.
I do this by using vtkCutter to cut the polygon. If I want to fill it I then use vtkContourTriangulator. Then simply give it to a vtkPolyDataMapper and then to a vtkActor as normal. Lastly add the vtkActor to the renderer of vtkImageViewer2.
The only other trick here is that the polygon should be bumped slightly in front of the image slice plane so that the image doesn’t cover the polygon. I actually do this by just using a cutting plane slightly in front of the actual slice plane.
yes ,the trick is useful.