I found an example where the filter seems to fail (but not clear to me why) - I wonder if there is a fix…:
from vedo import *
pts = np.array([
[1.96, 2.48, -1.34],
[1.89, 2.34, -1.33],
[1.74, 2.41, -1.35],
[1.68, 2.26, -1.35],
[1.52, 2.32, -1.34],
[1.59, 2.48, -1.34],
[1.66, 2.63, -1.33],
[1.81, 2.56, -1.34],
])
# pts[:,2] = -1.33 # this fixes it
# pts[:, [1,2]] = pts[:, [2,1]] # no effect in any case
line = Line(pts)
# line.write("line.vtk", binary=False)
mesh = line.clone().triangulate().lw(1).c("blue4")
labels = line.labels2d(c="yellow4", scale=2)
show(line, mesh, labels, bg="gray1", axes=1).close()
works fine if:
pts[:,2] = -1.33
fails without it (non-planar):
with error message:
2023-04-04 14:07:57.010 ( 0.124s) [ C1F89180]vtkContourTriangulator.:91 ERR| vtkContourTriangulator (0x26bc1a0): Triangulation failed, output might have holes.
Pure VTK to reproduce the issue:
import vtk
reader = vtk.vtkPolyDataReader()
reader.SetFileName("line_bad.vtk")
reader.Update()
polydata = reader.GetOutput()
tf = vtk.vtkContourTriangulator()
tf.TriangulationErrorDisplayOn()
tf.SetInputData(polydata)
tf.Update()
tfpolydata = tf.GetOutput()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputData(tfpolydata)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().EdgeVisibilityOn()
ren = vtk.vtkRenderer()
ren.AddActor(actor)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.Start()
lines.zip (699 Bytes)
Related to: