Combine Models vtkbool error

Hello, I’ve been trying to use the new “Combine Models” module from the Sandbox extension, but have run into errors. Specifically, the error is “Contact ends suddenly at point 2.” from VTK, and the created union model is empty. Searching, I found that @lassoan reported a similar error to the developer in March 2021 (Difference of meshes sometimes an empty mesh · Issue #40 · zippy84/vtkbool · GitHub) and had some back and forth. I don’t fully understand what the issue is, or how to resolve it. I am trying to combine a model derived from a segmentation with a portion of a rectangular solid. The overlap volume is deliberately small (but should be present) and the overlap volume includes two almost parallel faces, which I gather from reading the github issue might be part of the problem? I am trying to set up a workflow which will work the same way without failing across multiple cases. I don’t really understand how to identify or fix “non-manifold edges” in my meshes, or how to tell if that is what is causing the problem. I can share the meshes which lead to the error if that would be helpful. Thanks!

vtkBool has worked quite well for BoneReconstructionPlanner project to make surgical guides.

In the past if the result was an empty model it was because there was no-contact between the input objects or some of the input models had non-manifold edges or the input models meshes were not made of triangles

Here is a way to check if a model has non-manifold edges:

myModel = getNode('myModel')
featureEdges = vtk.vtkFeatureEdges()
featureEdges.SetInputData(myModel.GetPolyData())
featureEdges.BoundaryEdgesOff()
featureEdges.FeatureEdgesOff()
featureEdges.ManifoldEdgesOff()
featureEdges.NonManifoldEdgesOn()
featureEdges.Update()
areNonManifoldEdges = featureEdges.GetOutput().GetNumberOfPoints()

Hope it helps you

1 Like

Thanks for the helpful code, I really appreciate it. It did not identify any non-manifold edges in my models, but after reading a bit more about them (helpful link), I understand better what they are and why they might cause problems. While neither model individually has non-manifold edges, the two models might just barely touch in places and end up sharing an edge or vertex when finding the union of the two. Empirically, it was not a problem for me to just increase the degree of overlap by 1 mm, and this resolved the error. This is an OK workaround for me.