For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

boolean operations.... BRepAlgo_Cut bug?

Michele Fiorentino's picture

Dear developers,

I am experimenting Opencascade booleans, whith a simple example i can call "the swiss cheese": take a box and perform a series of holes ;)

her eis the full code in c++


const bool mydebug = false;

BRepPrimAPI_MakeBox B( 10,10.,10.);

const Standard_Real spacing =3.5f;
const Standard_Real m_radius =1.0f;
TopoDS_Shape finalshape = B.Shape();
int k =0;
// remmed because 2 cycles is sufficent to create the bug
//for(float k=0;k //{
for(float j=0;j {
for(float i=0;i {

TopoDS_Shape tempSphere = BRepPrimAPI_MakeSphere(gp_Pnt(i*spacing,j*spacing,k*spacing), m_radius);
if (!mydebug)
BRepAlgo_Cut S1(finalshape,tempSphere);
if (S1.IsDone() && !S1.Shape().IsNull()) finalshape = S1.Shape();
//Handle(Standard_Failure) error = Failure::Caught();
cerr }

} else // Show the spheres only - not necessary code
Handle(AIS_Shape) AIStempsphere=new AIS_Shape(tempSphere);
theContext->Display(AIStempsphere, Standard_False);
theContext->Display(AIStempsphere, Standard_False);
Handle(AIS_Shape) AISBottle=new AIS_Shape(finalshape);
theContext->SetColor(AISBottle, Quantity_NOC_RED);
if (mydebug) theContext->SetDisplayMode(AISBottle,AIS_WireFrame,true);
else theContext->SetDisplayMode(AISBottle,AIS_Shaded,true);
theContext->Display(AISBottle, Standard_False);


I added the flag debug to see how are spatially located the spheres.
The code works for 1 row but give me a fault when I add a row (as in the example above)
Feel free to play with it..;)

So my question:
1) is the code right?(i.e. some faults because the resulting shape is temp?)
2) The geometry i want to build is tecnically feseabel in Opencascade? (the cheese?)
3) this 3D is very similar to this
and another one where it was suggested to create a compound of objects and teh perform the boolean operation one time. This is the way I'll test..
4) if it's a bug i already sent a mail to the bugmaster but in my account i cannot open new issues.


Michele Fiorentino's picture

Autoanswer: I did a quick test and using BRepAlgoAPI_Cut works for this example. It's pretty confusing having two functions doing the same thing!

Forum supervisor's picture

Dear Michele,
BRepAlgoAPI contains a new version of Boolean operations algorithm.
BRepAlgo package contains old algorithm of Boolean operations. It is kept for compatibility and not maintained more.