
Wed, 12/01/2021 - 20:47
I have a picture containing many elements generated using TopoDS_Shape for each element and XCAFDoc_ShapeTool::AddShape to add them to my collection of top level shapes.
I also have a potentially large set of holes that I need to 'punch through' (or 'subtract from') the generated picture, so I am looking for suggestions about the best (most efficient) way to do this.
I thought that maybe BRepFeat_MakeCylindricalHole would do this for me, but the documentation is so minimal that it is far from obvious how it works!
I can see how you create an instance of BRepFeat_MakeCylindricalHole, then call Init to pass in the TopoDS_Shape to be cut, but nowhere can I find how you then specify the position and size of the drill holes.
Alternatively, is there a way to construct a shape for my set of holes, then subtract that from the generated visual items? Like cutting the holes in a big piece of Swiss cheese?!
TIA
David.
Wed, 12/01/2021 - 23:23
Hi,
The best way is to use Boolean operations. For each hole you create a cylindrical shape of the needed size and position. Then call the BO BRepAlgoAPI_Cut:
- Use empty constructor.
- Call SetArguments() for the list of objects to cut from.
- Call SetTools() for the list of cutting tools.
- Call Build().
- Get result with Shape(). It will be a compound of shapes.