UnstructuredGrid edge display issue
When displaying both vtkTriangle and vtkLine on the same plot with SetEdgeVisibility(True)
, edges for some of the triangles do not appear. Here is a MWE:
import vtk
vtk_points = vtk.vtkPoints()
vtk_points.InsertNextPoint([0.0, 0.0, -0.5])
vtk_points.InsertNextPoint([-0.5, 0.0, 0.0])
vtk_points.InsertNextPoint([0.25, 0.43, 0.0])
vtk_points.InsertNextPoint([0.25, -0.43, 0.0])
cells = vtk.vtkCellArray()
triangle1 = vtk.vtkTriangle()
triangle1.GetPointIds().SetId(0, 1)
triangle1.GetPointIds().SetId(1, 2)
triangle1.GetPointIds().SetId(2, 0)
cells.InsertNextCell(triangle1)
triangle2 = vtk.vtkTriangle()
triangle2.GetPointIds().SetId(0, 3)
triangle2.GetPointIds().SetId(1, 1)
triangle2.GetPointIds().SetId(2, 0)
cells.InsertNextCell(triangle2)
line = vtk.vtkLine()
line.GetPointIds().SetId(0, 2)
line.GetPointIds().SetId(1, 3)
cells.InsertNextCell(line)
ugrid = vtk.vtkUnstructuredGrid()
ugrid.SetPoints(vtk_points)
ugrid.SetCells([5, 5, 3], cells)
mapper = vtk.vtkDataSetMapper()
mapper.SetInputData(ugrid)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetLineWidth(5)
actor.GetProperty().SetEdgeVisibility(True)
renderer = vtk.vtkRenderer()
renderer.AddActor(actor)
renderer.SetBackground(0.3, 0.3, 0.3)
render_window = vtk.vtkRenderWindow()
render_window.AddRenderer(renderer)
interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(render_window)
interactor.Initialize()
interactor.Start()
Is there a workround for this issue?
Edited by Alex Kaszynski