reusing the already computed interference in boolean operations

Dear supervisor and everybody,

on "BRepAlgoAPI Class Reference" I read
"the new API of the Boolean Operations allows to reuse the already computed interference between arguments in different types of Boolean Operations"

This is very good for performance.
For instance, I need A - B, B - A and the intersection of A and B (three operations with the same input shapes).

How can it be done?
Maybe by declaring a BOPAlgo_PaveFiller and then calling the constructors of BRepAlgoAPI_Cut and BRepAlgoAPI_Common which have an input BOPAlgo_PaveFiller, but the argument is const &, so it looks input only.

Thanks.
Mauro

Evgeny Lodyzhehsky's picture

Dear Mauro Mariotti.

The magic sequence you are looking for is in the file: BOPTest_BOPCommands.cxx

Here is some summarizing code:
{
//...
const Standard_Integer aNbOps=5;
Standard_Integer i, iErr;
TopoDS_Shape aS1, aS2, aResult[aNbOps];
BOPCol_ListOfShape aLC;
BOPAlgo_PaveFiller* pPF;
Handle(NCollection_BaseAllocator)aAL=new NCollection_IncAllocator;

pPF=new BOPAlgo_PaveFiller(aAL);

aS1=...;
aS2=...;

aLC.Append(aS1);
aLC.Append(aS2);

pPF->SetArguments(aLC);

pPF->Perform();
iErr=pPF->ErrorStatus();
if (iErr) {
// Error...
return 0;
}
//---------------------------------
BOPAlgo_BOP aBOP;
BOPAlgo_Operation aOps[aNbOps]={
BOPAlgo_COMMON,
BOPAlgo_FUSE,
BOPAlgo_CUT,
BOPAlgo_CUT21,
BOPAlgo_SECTION
};

aBOP.AddArgument(aS1);
aBOP.AddTool(aS2);

for (i=0; i!=aNbOps; ++i) {
aOp=aOps[i];
aBOP.SetOperation(aOp);

aBOP.PerformWithFiller(*pPF);
iErr=aBOP.ErrorStatus();
if (iErr) {
// Error ...
return 0;
}
// the results
aResult[i]=aBOP.Shape();
}
//...
}

Mauro Mariotti's picture

Thank you, Evgeny Nicolaich,
this is very useful.
I suggest to put it in the user guide and maybe a hint in the BRepAlgoAPI reference documentation too. I see the classes to use are not really in BRepAlgoAPI, but deeper in BOPAlgo.

Mauro