Changing shape transformation and performing boolean operations
I'm seeing some strange behavior when setting the location of a shape, then applying a boolean operation.
Here is some example code:
TopoDS_Shape box = BRepPrimAPI_MakeBox(150, 60, 10);
TopoDS_Shape cylinder = BRepPrimAPI_MakeCylinder(3, 12);
transformation.SetTranslation(gp_Vec(100, 30, 5));
TopoDS_Shape shape = BRepAlgoAPI_Cut(box, cylinder);
This code is supposed to get the boolean intersection of a rectangular prism and a cylinder.
However, after triangulating the shape and iterating over the faces, the result shape triangulation includes the bottom faces of the cylinder as if they hadn't been translated.
There's similar behavior when applying a boolean union operation via BRepAlgoAPI_Fuse.
Is this a bug?
The only way I can get the desired result of the boolean operation is to use BRepBuilderAPI_Transform or BRepBuilderAPI_GTransform.
trans.SetTranslationPart(gp_XYZ(100, 30, 5));
cylinder = BRepBuilderAPI_GTransform(cylinder, trans);
This gives me the desired result except that I'd like to retain the location information in the shape. I.e. when applying this way, the result cylinder has location at (0, 0, 0) instead of (100, 30, 5).
Perhaps I'm doing something wrong.
Is there a different way to achieve this?