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

Related pages

Boolean Operations very slow

Saya Aldo's picture
Forums: 

Hi,
I've a problem about opencascade boolean operations performance optimization

I need to display a box panel with about 100 cylindrical holes.

The code doing the job looks like :
___

TopoDS_Shape pannello = BRepPrimAPI_MakeBox(700.,-600.,+20.);

TopoDS_Shape *sottratta = new TopoDS_Shape(pannello);

//numero dei fori per direzione //numbers of holes
int nForix = 10;
int nForiy = 10;
//dist tra fori per direzione // gap distance
double distx = 10.;
double disty = 10.;
//raggio foro circolare //radius
double rag = 20.;

//gap
double gapx = distx + rag;
double gapy = disty + rag;
// ----
for (int j = 0; j for (int i = 0; i //a new hole
TopoDS_Shape* foro = new TopoDS_Shape(BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(gapx*(2*i + 1),-gapy*(2*j + 1),0.),gp_Dir(0.,0.,1.)),20.,100.).Shape());

sottratta = new TopoDS_Shape(BRepAlgo_Cut(*sottratta,*foro).Shape());
}
// ----
Handle(AIS_Shape) aShape;
aShape = new AIS_Shape(*sottratta);
myAISContext->Display(aShape,1,0,Standard_True,Standard_True);
___
It works correctly but the resulting time to render it is very high.
It's about 124 seconds in my (quite new) machine.

Does exist any faster way to do this job?

If I change strategy:
// ----
for (int j = 0; j for (int i = 0; i TopoDS_Shape foro = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(gapx*(2*i + 1),-gapy*(2*j + 1),0.),gp_Dir(0.,0.,1.)),20.,100.).Shape();
*fusioneFori = BRepAlgo_Fuse(*fusioneFori,foro).Shape();
}
*sottratta = BRepAlgo_Cut(pannello,*fusioneFori).Shape();
// ----

fusing all holes in a single shape, before doing a single cut I cane save more than 40 seconds,
but 82 seconds are still not acceptable for my application. The goal is rendering the holed panel using less than 10 secs.

Does Anyone know a faster solution? Am I following a wrong sequence? Any suggestion?
Thanks in Advance.
Giovanni

Davide Canalia's picture

Have you tried to create a Compound shape and not a union?
I mean:
1) create a compound shape (it is built with 100 shapes, the hole)
2) perform the cut between the main shape and the compound.

I haven't tried this option..it is just an idea.

Svetlozar Kostadinov's picture

I am also interested to know the solution for this problem.

Jane Hu's picture

I just tried to make all into a compound,it seems subtraction won't work correctly. Has any one found any solutions?

Jane

Lodyzhensky's picture

Dear Saya Aldo.

The classes:
BRepAlgo_Fuse, BRepAlgo_Cut, BRepAlgo_Common, BRepAlgo_Section
are out of maintenance by more than 10 years. I do not know why these classes
are still are among the sources of Open Cascade.
So it will be wise to not use them.
Use the classes BRepAlgoAPI_* instead.

I've made compound from 100 cylinders (arg2) and cut it from the box (arg1)
using BRepAlgoAPI_Cut. It took about 2 sec "...in my (quite new) machine".
I use Open Cascade 6.6.0.

Try to use the following commands to check it:
#
restore arg1
restore arg2
#
bop arg1 arg2
bopcut r

Best wishes.

Forum supervisor's picture

Dear Evgeny Nicolaich,
The mentioned classes (BRepAlgo_***) are kept for compatibility purpose only. For sure some day they will be removed.
Best regards

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.