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

How to Increase Boolean Operation Performance

AP's picture
Forums: 

Hello There,

Does anyone know a way of increasing the Performance of:

BRepAlgoAPI_Fuse
BRepAlgoAPI_Cut
BRepAlgoAPI_Common

Attached is a Step file and images showing how the common shape of this object and 100 vertical planar rectangular surfaces, should look like.

intersecting the model attached, with 100 planar surfaces takes 3.5 minutes in OPenCascade and only 7 seconds in Catia:

Within OpenCascade:
hours:0.0586056
minutes: 3.51633
seconds 210.98
milliseconds: 210980

Catia:
seconds 7

Best,

AlexP

Attachments: 
jelle's picture

hello Alex,

PythonOCC has a really nice parallel slicer, see:
https://github.com/tpaviot/pythonocc/blob/master/src/examples/Level2/Concurrency/parallel_slicer.py
>>> 27.6783349514 seconds necessary to perform slice with 8 processor(s), for 200 slices...

Btw, I think the 1st program I wrote on pythonocc was "emmenthaler" , I think we share a fascination for cheesy things ;)
http://www.youtube.com/watch?v=7vCevxXoMFY

jelle's picture

it might be fast, but unfortunately BRepAlgoAPI_Section fails to compute the proper sections.
as you can see, on the outside facing faces of the original domain, all sections are computed, not so on the inner domain.
there are even curves on the trimmed areas...
mehhhh...

Forum Supervisor, perhaps a useful regression test case?

jelle's picture

i really shouldnt be talking to myself like that...
here's a screencap of the pythonocc example, the exact same code is ran, but with really decent results...
admittedly, I'm on OCC 6.3, but I'm not aware of any major fixes wrt boolops...

Forum supervisor's picture

Dear jelle,
Could you provide the initial shapes which would allowed to reproduce the problem?
Regards

jelle's picture

hello FSV,

I'm sure Alex will be able to provide you with a small program.
However, I think its just a number of random cylinders substracted from a cube.

Forum supervisor's picture

Hi jelle,
In any case we need initial shapes and short scenario/script (any symbolic language may be used) to reproduce the problem.
We would be pleased to get it from Alex if possible.
Regards

AP's picture

Dear Forum Supervisor, Jelle

I made the file in Catia, attached is the Catpart.
in tsthis file there is also the 100 surfaces to test the BrepAlgoApi_common.

In any case Ill followup with the step files.

Best AlexP.

The code could also be generated like this: http://www.opencascade.org/org/forum/thread_21523/

Attachments: 
AP's picture

here are the step files:
Cheese.step ---> step export of body from catia
planes.step ---> generated from the code in the thread link above
slices.png ---> result of opencascade Brep_AlgoApi_common
solidshape.png --> view of cheese.step

Best AlexP

Attachments: 
Forum supervisor's picture

Alex,
Thanks for the provided data.
So, as I understood your algorithm makes sequentially intersection between shape from cheese.stp and each plane from planes.stp in loop.
It takes more than 210 seconds ==> performance problem.
Right?
regards

AP's picture

Dear Forum Supervisor,

I am avoiding doing 100 boolean operations, instead im just executing a single boolean common operation.

I load the cheese file, i load the planes file
then i do a common between them.

that common is taking 3.5 minutes.

annexed is the code im using to visualize, the Misc functions are in the thread:
http://www.opencascade.org/org/forum/thread_21523/

Best,

AlexP

///***************** code begins here

// macros for capturing whats going to be displayed.

#define INITPART\
UnitsAPI::SetLocalSystem(UnitsAPI_MDTV);\
Handle_AIS_InteractiveContext ic = ui::getInstance()->getWindowContext();\
int viscount=0;\
TopoDS_Compound folder;\
BRep_Builder B;\
B.MakeCompound(folder);\

/* create shape and add to compound */
#define vis(name)\
if (!name.IsNull()){\
B.Add(folder,name);\
viscount++;}\

/* visualize shape */
#define ENDPART\
if (viscount>0){\
HSF::updateUserAIS(folder,aisp,ic);}\
//Standard::purgememory();\

void slicer::update()
{

INITPART

if(EOS.IsNull())

{
QoccInputOutput* io_man = new QoccInputOutput();
QString filename = QFileDialog::getOpenFileName ( this,
tr("Import File"),"");
QString filename2 = QFileDialog::getOpenFileName ( this,
tr("Import File"),"");

if (!(filename.length() > 0)) return;
if (!(filename2.length() > 0)) return;

Handle(TopTools_HSequenceOfShape) famshape1 = io_man->importSTEP(filename);
EOS = famshape1->Value(1);

Handle(TopTools_HSequenceOfShape) famshape2 = io_man->importSTEP(filename2);
EOS2 = famshape2->Value(1);

}

//vis(EOS);

double Xmin, Ymin, Zmin, Xmax, Ymax, Zmax;
Bnd_Box Bnd;
BRepBndLib::Add(EOS, Bnd);
Bnd.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);

double width = abs(Xmax -Xmin);
double height = abs(Ymax -Ymin);
double depth = abs(Zmax -Zmin);

double slicecount = 100;

double sliceheight =(double) depth / slicecount;
gp_Pnt centerp((Xmin+Xmax)/2,(Ymin+Ymax)/2,(Zmin+Zmax)/2);

TopoDS_Compound slices;
BRep_Builder sliceB;
sliceB.MakeCompound(slices);

for(int i= 0;i gp_Pnt slicecenter = centerp;
slicecenter.SetZ((double) i * sliceheight);

TopoDS_Shape rect = hsf::AddNewRectangle(slicecenter,gp::DZ(),width*2,height*2);
TopoDS_Shape rectfill = hsf::AddNewFillSurface(rect);
sliceB.Add(slices,rectfill);

}

QTime time;
time.start();

//TopoDS_Shape common = hsf::BooleanCommon(EOS,slices);
TopoDS_Shape common = hsf::BooleanCommon(EOS,EOS2);
vis(common);

double milliseconds = time.elapsed();
double seconds = (milliseconds/1000);
double minutes = seconds/60;
double hours = minutes/60;

QString timetxt;
QTextStream linestream(&timetxt);
linestream

qDebug()

ENDPART

}

Forum supervisor's picture

Dear Alex,
Thanks for your contribution. It is really good test case.
We confirm the reported performance problem with the specified shapes.
The corresponding issue with ID = 0022702 has been registered.
Later you can know if the issue is resolved by checking references to the specified ID in OCCT Release Notes. The analysis of the issue will take some time depending on our technical capability and availability of resources.
Regards

AP's picture

No Worries,

Thank you for your time.

Best,

AlexP

jelle's picture

Dear Alex, FSV,

Here's the emmentaler pythonocc version.
However, interestingly [ good news! ] enough I cannot reproduce the problem with that...

-jelle

jelle's picture

sorry, missed the script...
the slice were done in 9.7 seconds, so even more good news ;)

Attachments: 
AP's picture

Hi Jelle,

Thanks for the insights, i noticed youre using the Section tool.

I guess im wondering how to speedup a single Boolean Operation the BRepAlgoAPI_Section is part of the whole Boolean family, they all execute slow, compared to Parasolids Kernel and with Spatials Acis or Catia.

I am wondering if there is a way of boosting the speed and reduce the accuray perhaps or tolerances? Does the BrepAlgoApi family use the BrepMesh triangulation of the Tool and Stock shapes, or is it a purely analitical algorithim running on Geom_Surfaces and trickling up to Shapes.

I noticed on the news, there where some tests being run on OpenCl using CUDA, to run booleans on the graphics card, is any of that research available, could we help from the outside.

Booleans are really important as a design tool:
http://www.responsive-a-s-c.com/

on this project we where using opencascade to generate the Hyperboloids, but we had to outsource the Boolean operations to CATIA cause it took catia 3 minutes to do boolean subtract of 10,000 hyberboloids over a stock material.

I have plenty of models to Test Boolean Subtracts if the OpenCascade team would like to do some speed tests.

Best,

AlexP

jelle's picture

> Thanks for the insights, i noticed youre using the Section tool.

indeed... its meant to do this sort of operation...

> I guess im wondering how to speedup a single Boolean Operation the BRepAlgoAPI_Section is part of the whole Boolean family, they all execute slow, compared to > Parasolids Kernel and with Spatials Acis or Catia.

I wouldnt be so hasty to conclude this... the step file your working with seems to be the issue here...
Also, the problem is trivial to parallelize, when you do so, you get sufficiently close to Catia.
[ even / especially from a high level language, that's pretty impressive ;) ]

> I am wondering if there is a way of boosting the speed and reduce the accuray perhaps or tolerances?

_no_! please dont...

> Does the BrepAlgoApi family use the BrepMesh triangulation > of the Tool and Stock shapes, or is it a purely analitical algorithim running on Geom_Surfaces >and trickling up to Shapes.

good question, in fact I think so...

>I noticed on the news, there where some tests being run on OpenCl using CUDA, to run booleans on the graphics card, is any of that research available, could >we help from the outside.

that's probably work done on meshes, where bools are _way_ easier to compute

>Booleans are really important as a design tool:
>http://www.responsive-a-s-c.com/

+1

>on this project we where using opencascade to generate the Hyperboloids, but we had to outsource the Boolean operations to CATIA cause it took catia 3 >minutes to do boolean subtract of 10,000 hyberboloids over a stock material.

it would be fairly easy to do this _without_ boolean ops?
also, if you do things in parallel with a decent machine, you should see a good speedup...

>I have plenty of models to Test Boolean Subtracts if the OpenCascade team would like to do some speed tests.

perhaps it would be useful if you could help figure out with the bool op section fails with your model?

AP's picture

Thanks Jelle,

9.7 seconds, wow, im gonna start working on parallelizing with Qt Thread and see whats the performance gain.

I ran the Section Tool on it and it worked see image.

and here is the section tool code im running on it.

TopoDS_Shape HSF::AddNewIntersectSrfW(TopoDS_Shape srf1,TopoDS_Shape srf2)
{

BRepAlgoAPI_Section asect(srf1,srf2,Standard_False);
//asect.ComputePCurveOn1(Standard_True);
asect.Approximation(Standard_True);
asect.Build();
TopoDS_Shape R = asect.Shape();
qDebug() return R;
}

Best

AlexP

Attachments: 
jelle's picture

wow back at ya, my results were really crappy, i'm happy to see you got good results!
are you on OCC 6.5[.1] Alex?

AP's picture

Jelle,

I am still on 6.3

Best,

AlexP

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.