I want to render a concave polygon with the use of a vtkDelaunay2D. I've read that it should work with a vtkDelaunay2D, but it doesn't. Why?
Here is the my code:
import vtk
points = vtk.vtkPoints()
ls = [
[5, 5], [-5, 5], [-8, 0], [-5, -5], [5, -5], [2, 0]
]
for x, y in ls:
points.InsertNextPoint(x, y, 0)
aPolyData = vtk.vtkPolyData()
aPolyData.SetPoints(points)
delaunay = vtk.vtkDelaunay2D()
delaunay.SetInputData(aPolyData)
meshMapper = vtk.vtkPolyDataMapper()
meshMapper.SetInputConnection(delaunay.GetOutputPort())
colors = vtk.vtkNamedColors()
meshActor = vtk.vtkActor()
meshActor.SetMapper(meshMapper)
meshActor.GetProperty().EdgeVisibilityOn()
meshActor.GetProperty().SetEdgeColor(colors.GetColor3d("Peacock"))
meshActor.GetProperty().SetInterpolationToFlat()
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
renderer.AddActor(meshActor)
renderer.SetBackground(colors.GetColor3d("Mint"))
renderWindow.SetSize(640, 480)
renderWindow.Render()
renderWindowInteractor.Start()
The result looks like this:
The triangle on the right side shouldn't be there.
So why does this happen? And what do I have to do so this doesn't happen?
question from:
https://stackoverflow.com/questions/65891622/vtk-render-concave-polygon-with-vtkdelaunay2d 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…