vtkCollisionDetectionFilter segfault
When running this script in Python, I get a segmentation fault (core dumped)
import itertools
from stl import mesh
import vedo
import vtk
fpath = vedo.download("https://ozeki.hu/attachments/116/Eiffel_tower_sample.STL")
your_mesh = mesh.Mesh.from_file(fpath)
verts = list(itertools.chain(*(your_mesh.vectors)))
faces = [[i*3, i*3+1, i*3+2] for i in range(len(verts)//3)]
vpoly = vedo.Mesh([verts, faces]).clean().polydata()
vpoly2 = vpoly
collide = vtk.vtkCollisionDetectionFilter()
collide.SetInputData(0, vpoly)
collide.SetInputData(1, vpoly2)
collide.SetBoxTolerance(0.1)
collide.SetCellTolerance(0.1)
collide.SetNumberOfCellsPerNode(2)
collide.SetCollisionModeToFirstContact()
collide.GenerateScalarsOn()
#collide.Update()
print(collide.GetNumberOfContacts())
If I uncomment collide.Update()
, then it doesn't crash. In my opinion, a warning or exception should be thrown if Update was not called, to prevent your program from crashing.
This has also been mentioned in https://discourse.slicer.org/t/collision-detection-capabilities-in-3d-slicer/14854/13