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

About boolean operations

Wei Zhang's picture
Forums: 

Hello there,

I need to get both the common and cut boolean operation result of two shapes,
Do I have to do the boolean operation twice as the following code?
Is there any way that can do this faster?
Is there a way to get two results in one boolean operation?

Any help is much appreciated.

// TopoDS_Shape aS1=?
// TopoDS_Shape aS2=?
TopoDS_Shape commonResult;
TopoDS_Shape cutResult;

BRepAlgoAPI_Common aCommonOperation(aS1, aS2);

if(!aCommonOperation.IsDone())
{
commonResult = aCommonOperation.Shape();
}

BRepAlgoAPI_Cut aCutOperation(aS1, aS2);

if(!aCutOperation.IsDone())
{
cutResult = aCutOperation.Shape();
}

Rob Bachrach's picture

I do not know of any way to perform the operations simultaneously. However, there is a second constructor that takes a reference to a BOPTools_DSFiller object. This contains the intersections between the two shapes and can be passed to both computations so it will not need to be computed separately by both. See the help on the BRepAlgoAPI_BooleanOperation constructor for more details and an example.