Boolean Operation Fail

Boolean Operation Fail

marcelo_quevedo
Contributor Contributor
24,411 Views
62 Replies
Message 1 of 63

Boolean Operation Fail

marcelo_quevedo
Contributor
Contributor

Hello,

The core of our application works with solid operations between solids, and we constantly faced Boolean operation issues by using the ExecuteBooleanOperation() API method. It throws the next exception that doesn’t allow to do the Boolean operation.

 

“Failed to perform the Boolean operation for the two solids. This may be due to geometric inaccuracies in the solids, such as slightly misaligned faces or edges. If so, eliminating the inaccuracies by making sure the solids are accurately aligned may solve the problem. This also may be due to one or both solids having complexities such as more than two faces geometrically meeting along a single edge, or two coincident edges, etc. Eliminating such conditions, or performing a sequence of Boolean operations in an order that avoids such conditions, may solve the problem.”

 

I created a simple C# sample with a command that allows to do a Boolean operation between two solids. Also, I have attached two Revit files. Each file contains two intersected directShape objects. Using the C# sample and those files you could reproduce the issue by trying to do a Boolean operation between the two objects.

 

We will be very grateful if you could help us with some directions to solve the issue, and it would be great if you take into consideration this API issue for the future Revit APIs.

 

Thanks a lot, in advance!

Marcelo

 

24,412 Views
62 Replies
Replies (62)
Message 61 of 63

tommy.stromhaug
Contributor
Contributor

Boolean operations on B-reps (Boundary Representations) are notoriously difficult. A fundamental problem lies with floating-point arithmetic, where numerical imprecision makes it impossible to definitively know if a point is inside, outside, or exactly on another object's surface.

Beyond that, the most significant challenges are the degenerate cases, which even robust algorithms struggle with. These include situations where:

  • A vertex from one object lies exactly on an edge or face of the other.

  • An edge from one object is collinear with an edge from the other.

  • A face from one object is perfectly coplanar with a face from the other.

Handling these special conditions is what separates a truly robust geometry kernel from one that fails frequently, which is a challenge for many software packages, including Revit.

The problem is still an important field in research.
One way to solve some of these problems inside Revit, was to rotate and/or translate one of the objects a tiny tiny bit. It worked up to a limit but not enough to use it in ship industry. They demand 100 percent accuracy and robust solutions. My solution was to store views of the objects to step, then do the operation in OpenCascade for then importing the result back into Revit. Like the solution presented by fujiwara-revit-1.




 

0 Likes
Message 62 of 63

ankofl
Advocate
Advocate

I think I ran into exactly this problem about a year ago using CGAL.

Then I needed to combine all the structures of the building in order to get the correct internal volumes of the premisesThen I found a solution in that I iteratively combined all the constructions that could be combined, and then with the final one those that could not. And in the most recent case, when it was necessary to combine objects that could not combine with anything earlier, it was necessary to perform an extrusion of such an object in all directions in order to completely displace each face, so that there would be no edges of two objects lying exactly on top of each other.

In that case, it was acceptable, because I needed to get the interior volume of the room, not the weld seam of the aircraft wing) I think the problem with Revit is that it doesn't have a built-in function, by type (I can't perform this Boolean operation accurately, but I can with a slight simplification/offset. Should I continue?). I think such a function would close most of the issues with Boolean operations in the context of BIM for buildings.

0 Likes
Message 63 of 63

tommy.stromhaug
Contributor
Contributor

I just have to add that you were partly right about NefPolyhedra. It is CGALs answer to Breps. The big problem with this structure is that it can not contain curved elements. Only flat ones.
For breps with only flat faces this is the one to use :

 

Pros:

Extreme Robustness: Booleans are guaranteed to work.

Mathematically Correct: No floating-point errors.

Handles Degenerate Cases: No failures on tricky alignments

 

Cons:

Slower Performance: Exact math is computationally expensive.

Higher Memory Usage: More data needs to be stored.

Approximation for Curves: Perfect NURBS surfaces are lost.