Combine Models(difference operation) sometimes result empty mesh?

@lassoan , I have searched surface cut for some time.
I loaded a liver stl model, then I created a closed curve in Markups module, and generate a Baffle model in Baffle Planner module(in SlicerHeart extension), then I switch to Combine Models(in Sandbox extension).
First, I set liver model as input model A, set baffle model as input model B, operation set “Intersection(A&B)”, set “create new model” as Output model. And I can quickly get the intersection result model, named Model_1 about 5 seconds.
Finally, I want to get the result by liver model subtract Model_1, so I choose liver as input model A, Model_1 as input model B, operation set Difference(A-B), set “create new model” as Output model. After click Apply button, the process is running and for a long time, about 1200 seconds, compute finished, Model_2 generated, but it is empty mesh.
I searched from community, and find some related link:

Above link mentioned some ideas to solve this problem, such as " Remove non-manifold edges", vtkCleanPolyData.
But when I read CombineModels.py source code, there exist not related class, only use vtkPolyDataBooleanFilter to cut models. So, perhaps I have to add some postprocessed beftore Difference compute, to avoid empty mesh result?
Expect to your reply and appreciate your help in the past.

Above link is the mrml file and model files.

You cannot subtract the Model_1 part from the original liver, as most of the points are coincident. If you want to get the other half of the liver then you can probably flip the baffle surface, or ask vtkbool developer about it.

You can also use Dynamic Modeler tool to partition the liver. If you just need planar cuts then you can use the fast and accurate “Plane cut” tool, but if you want to cut along an arbitrary curve then you can use “Curve cut” tool.

For simulating liver resection, there is a tool specifically designed for this, which is currently being refactored and improved by the Alive project (see Slicer extension here). @RafaelPalomar can give you more information on the status of this.

1 Like

Thanks for your reply.
As you mentioned, after intersection operation finished first time, I flip the Baffle surface, by switch to Surface Toolbox module, select the “Normals” or “Compute Normals” option in windows/linux slicer version, checked the “Flip normals” and “Splitting” checkbox, then click Apply button, a flipped surface will computed.
Finally, I switch to Combine models module again, use the flipped surface to intersect the liver stl model second time, after click Apply button and wait for 4~5 seconds, upper part of liver will be cut success by flipped surface.

Followed img is liver been segmented into two parts, by baffle surface and flipped baffle surface.

1 Like