Next Step When Boolean Cut Operations Fail?

I'm experiening unexpected BRepAlgoAPI_Cut failures on very simple shapes. The shapes involved are all extrusions of flat faces. The wires used to build the faces are 2D outlines from a Visio like 2D canvas and consist of simple lines and bezier curves segments. The extruded shapes (components) are arranged into a 3D assembly and where one component intersects another, the user may specify one solid shape can "cut" into another.

These simple boolean operations succeed 99% of the time. However, 99% isn't good enough -- especially when small, seemingly insignficant, changes to the outline of the extruded shape make the difference between cut success and failure. Changes on either the cutting or cut shape can make the difference.

When the cut fails, a call to ShapeAnalysis_Shell::HasBadEdges() returns true. I've tried various "stab in the dark" attempts at discovering the underlying problem and using ShapeFix_* classes. I'm pretty sure there must be a more step-wise approach than what I've been doing. It's important to realized that the solids involved in the cut operations are built in OCC -- they are not being imported from another application.

Can anyone share general thoughts on the best way to approach an analysis of boolean cuts failure on simple shapes? Is there a good example anywhere of error analysis and remediation of shapes when boolean operations fail? Is there a top ten list of things to try when boolean operations fail?

The public OCC docs and examples are incomplete and too brief to be of help to someone doing anything more than "playing" with the library. I have read every post in this forum having anything to do with Boolean operations - thanks to all who have contributed as there is a lot of good material here but there is very little on this subject. I have also read Roman's excellent blog but he has not gotten into boolean operations in any detail.

Has anyone succeeded in building a generalized commercial grade application that depends on succesfull boolean cut operations (using the open source library)?

Anyone wishing to see the application I am building, that uses OCC, can see a quick movie demo of it here:
or soon on

BTW, I using 6.3.0 on Windows.


Evgeny Lodyzhehsky's picture

Dear Timothy May.

It's too hard to help you without real examples.
Could you upload shapes (A anb B) that produce wrong result R=Cut(A,B).

tmay's picture

I don't currently store the 3D objects to disk as they are intermediate in nature for my applicaiton. However, I am adding an exporter for the 3D assembly, for use in a light weight viewer application, so my users can share their models and design ideas with folks that don't have the full application. I'll move that up in the schedule so I can provide models that demonstrate the problem. Either that or I'll just write an application that generates the shape from static data.

Thanks for your interest in helping out.

Bearloga's picture

Boolean operations are very sensitive to such error in shapes like small edges. If your shape has an edge which length is less than the tolerance of one of its vertices, and the intersection goes inside this edge, the operation will be failed.
Some where in ShapeFix package, there is a tool that allows to catenate a series of small edges in a bigger one. That can solve the problem.

tmay's picture

I have been working with the ShapeFix package quite a bit. I'll track the edge concatenation facility down and let you know if it helps.


zgesi's picture

This is an always topic on OPENCASCADE and we are very difficult to find any useful information and answer on that. I also face the same problems many years and finially I found some information from Rhino website maybe can provide some suggestion.

The following information I copy from

Boolean operations can be great time saving procedures for constructing objects in Rhino. But, for the beginner, they seem to often mysteriously fail, and it is difficult to understand why. Hopefully this FAQ explanation will help clarify things a bit. If you don't want to wade through all the following info, you can also try John Brock's short How I fix Boolean Problems

To understand why Booleans fail, first you must understand how they work. They are not some sort of magic tool for putting objects together. They are simply semi-automatic operations that combine several ¡°manual¡± commands into one process. The Boolean operations basically do 4 things: Intersect two or more objects, Split them at the intersection(s) found, Delete (discard) the parts not wanted, and Join everything back together. Everything you can do with Boolean operations you can also do by ¡°manually¡± successively using the above four commands. Using a Boolean operation only speeds things up by making it one procedure ¨C when it works¡­

So, the first thing to keep in mind here is that a solid understanding of how the ¡°component¡± operations of Booleans work is necessary. When all else fails, you can get the job done with these commands ¨C Intersect, Split, Join and Delete. Try undoing a successful Boolean operation and re-doing it manually using those commands. Get comfortable with the fact that this procedure will always get you where you want to go even if your Boolean attempts fail.

Boolean operation failed...
OK, why do Booleans fail? First and foremost, it is the intersection operation that will determine the success or failure of a Boolean operation. If a correct intersection can be found, the rest is easy. However if Rhino has problems finding the intersection, the Boolean operation is guaranteed to fail. So the whole key is to help Rhino find a good and complete intersection. You can do this by setting up your model and file correctly, and also by understanding some of Rhino¡¯s quirks and limitations.

Intersecting 2 closed (¡°solid¡±) objects should produce at least one completely closed intersection curve (i.e. a loop). It¡¯s possible there may be more than one loop if the object intersect in multiple spots ¨C no problem if they¡¯re all closed. If even one is open, however, the Boolean operation will fail. This is because the intersection curve does not completely cut through the objects, and Rhino doesn¡¯t know how to finish the cut, so it stops and gives you an error message.

Note: Doing Boolean operations on open objects is also possible, but a bit more complicated, so we¡¯ll assume at first that all objects are closed. Open objects will be covered later.
So, having taken the above into account, if your Boolean operation fails, the first thing you should do is check the intersection of the objects. Select your objects and call Intersect. First, look at the intersection curve(s)on the screen. Does it look correct? Are there any visible gaps or extra segments or other things that ¡°look strange¡±? If so, you need to find out why. If the intersection looks OK, but the Boolean is still failing, while the intersection curve is still selected, go into Properties > Details or just use the command What. The resulting info box should tell you all you need to know about the curve. Does it say the curve is open? That will be your problem area then. More than one curve? You need to find out why there are either gaps or overlaps in your intersection.

Intersection problems, solutions and limitations
What can cause gaps or problems in your intersection? There are many possibilities. Some are due to modeling errors or inaccuracies, some are due to Rhino¡¯s limitations. Let¡¯s look at the common errors first:

If you think your intersection should be closed, but it¡¯s not, select the curve, and call CrvStart, which will place a point at the start of the curve. Normally this will correspond with one side of the gap. Zoom in closely and see if you can see the gap on the screen. Why is there a gap there? Well, maybe you think that your objects are closed, but they¡¯re really not. The intersection may cross a gap between surfaces, and that will cause an open curve. If you have forced together your object using JoinEdge, that may also happen, even though the object says closed. The other thing to check is your modeling tolerances (see Tolerances FAQ), if they are too large, this may prevent the intersector function from finding a complete intersection, even though all else is well. Try tightening your tolerances and running the Boolean again. Once you get a full closed intersection, your operation should work¡­

If you can¡¯t get Rhino to automatically produce a closed intersection curve even after you have fixed your object the best you can, it may be time to go back to ¡°manual¡±. Get the best intersection curve you can and try editing it until you have a closed object. You may need to add or modify a segment, do some point editing, take out overlapping segments, or something like that. Once you have this curve, you can try trimming your objects individually. You will need to explode your polysurfaces to trim with the intersection curve. Trim out the parts you don¡¯t want and join all back up.

Known Rhino limitations:

Coincident seams ¨C all objects have seams, sometimes when the seams on two objects are at exactly the same place, Rhino will have trouble with the intersection. Solution ¨C either try to move the seam, or try moving one object just a tiny, tiny bit (if you can without making your model inaccurate). Or try to do the operation ¡°manually¡±.

Coplanar faces ¨C if two faces of an object are on the same plane, Rhino may not be able to calculate the intersection. This is a fairly common occurrence, try to avoid building your model this way if you can. Solution ¨C as above, you may move the object slightly if possible, if not, you may have to do this operation ¡°manually¡±.

Nearly tangent surfaces ¨C like the intersection of two equal diameter pipes at an angle. The intersection often fails at the point where the surfaces are tangent. There is no easy fix currently for this problem.

Invalid objects ¨C If one of the objects you're trying to work with is invalid, Boolean operations will often fail. Check for invalid objects by using the command SelBadObjects. If one highlights, you will need to fix it first before proceeding. It is also recommended that you turn on automatic object checking, if invalid objects are created in the course of your work (or imported), Rhino will tell you immediately. To do this, simply type CheckNewObjects. This is a toggle, running the command again turns it off.

Non-Manifold Polysurfaces ¨C Although Rhino doesn't currently flag these objects as bad, they can cause failure. Rhino shouldn't create these types of structures, but under certain conditions it does, especially with V4. The only way to find them currently is to check the properties of the object.

"Manual" construction and editing is sometimes needed
Animated illustrations showing manual surface construction and editing when Boolean operations fail.

How to Manually Edit Surfaces with Coplanar Faces and Nearly Tagent Surfaces

How to Manually Edit Surfaces with Coplanar Faces II

This is an example of a solid that can not be constructed with solid primitives and surface editing techniques are required.

I believe this is a technical issue for all CAD's, so I hope this is useful to you.


Evgeny Lodyzhehsky's picture

Dear zgesi

It is very useful information.
Thanks a lot for the reference.

tmay's picture

Thanks for the background information. I'm writing a simple program to reproduce my issue and will share the results with the forum when it is complete. FWIW, I hope I find some simple smoking guy when I do that.