Performance improvement when using multiple Cut boolean operation on the same solid

I just want to reiterate that if you are in a situation where you need to make multiple Cut operations against a single solid (simulating CAM operations) you may want to first combine all of your cut operations into a single compound and then subtract that compound from your starting shape:

TopoDS_Compound cutOpCompound;
BRep_Builder cutOpBuilder;
TopoDS_Shape shapeOperationSolid;

// Make the compound by adding all the solids that will need to be cut out
// of a single shape (in my case a starting workpiece - CAM application)
cutOpBuilder.MakeCompound(cutOpCompound);
for(int i=0;i {
// Get the solid describing this cut operation
GetOperationShape(i, shapeOperationSolid);
// Add it to the compound we are building
cutOpBuilder.Add(cutOpCompound, shapeOperationSolid);
}

// Cut the combined compound from the model shape (created elsewhere)
shapeModel = BRepAlgoAPI_Cut(shapeModel, cutOpCompound);

The performance improvement is huge, for cutting out 96 cylinders out of a rectangular shape it took 120 sec to cut out piece by piece and 14 seconds to cut out when combining all operations into a single compound.

If anyone has any ideas on how to improve the performance even more I would really like to hear about it. For my application (CAM) all I need is to cut various shapes from one face of a solid.

Hans Knoll's picture

This algorithm fails unfortunately when the solids in the compound intersect one another. I fear you have to fuse them before the operation which slows it down again. Maybe you found an improved way of doing it yourself. If so i would be really interested in hearing about it.