I want to display a surface which is textured. I want the triangles boundaries to be visible over the surface in a different color (lets say red). I have found the following code from the vtk code samples but it does not display the triangle boundaries but the filled triangles.
import vtk
# create a rendering window and renderer
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
# create a renderwindowinteractor
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# create points
points = vtk.vtkPoints()
points.InsertNextPoint(1.0,0.0,0.0)
points.InsertNextPoint(0.0,0.0,0.0)
points.InsertNextPoint(0.0,1.0,0.0)
triangle = vtk.vtkTriangle()
triangle.GetPointIds().SetId(0,0)
triangle.GetPointIds().SetId(1,1)
triangle.GetPointIds().SetId(2,2)
triangles = vtk.vtkCellArray()
triangles.InsertNextCell(triangle)
# polydata object
trianglePolyData = vtk.vtkPolyData()
trianglePolyData.SetPoints( points )
trianglePolyData.SetPolys( triangles )
# mapper
mapper = vtk.vtkPolyDataMapper()
mapper.SetInput(trianglePolyData)
# actor
actor = vtk.vtkActor()
actor.SetMapper(mapper)
# assign actor to the renderer
ren.AddActor(actor)
# enable user interface interactor
iren.Initialize()
renWin.Render()
iren.Start()
Can anybody please let me know that how to display triangle only with the boundaries with a specific color.
I ideally i want to display triangles on a textured surface. My data consist of triangles. It might also be possible that the vertices of the triangles which are given to vtk can be made visible.
I am coding in python.
Thanks a lot
You need to extract the edges from your
vtkPolyDataobject:First you must extract the edges via a
vtkExtractEdgesfilter. You map the results of that filter to avtkPolyDataobject and construct an actor for that data. We then set the color of the mesh to red by modifying the actor directly.The call to
vtk.vtkPolyDataMapper().SetResolveCoincidentTopologyToPolygonOffset()prevents the edges from fighting with the surfaces (the two geometric objects are coincident and tear through each other due to z-buffer precision issues).For completeness sake, here’s the whole code: