diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index b706dae74e..a3852749d7 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -3267,6 +3267,30 @@ void TopoShape::transformGeometry(const Base::Matrix4D& rclMat) } } +void TopoShape::bakeInTransform() +{ + if (getShape().IsNull()) { + return; + } + + if (shapeType() != TopAbs_COMPOUND) { + transformGeometry(getTransform()); + setTransform(Base::Matrix4D {}); + return; + } + + TopoShape result; + std::vector shapes; + + for (auto& subshape : getSubTopoShapes()) { + subshape.bakeInTransform(); + shapes.push_back(subshape); + } + + result.makeCompound(shapes); + *this = result; +} + TopoDS_Shape TopoShape::transformGShape(const Base::Matrix4D& rclTrf, bool copy) const { if (this->_Shape.IsNull()) { diff --git a/src/Mod/Part/App/TopoShape.h b/src/Mod/Part/App/TopoShape.h index 3f716f4640..f5733222f2 100644 --- a/src/Mod/Part/App/TopoShape.h +++ b/src/Mod/Part/App/TopoShape.h @@ -668,6 +668,7 @@ public: /** @name Manipulation*/ //@{ void transformGeometry(const Base::Matrix4D& rclMat) override; + void bakeInTransform(); TopoDS_Shape transformGShape(const Base::Matrix4D&, bool copy = false) const; bool transformShape(const Base::Matrix4D&, bool copy, bool checkScale = false); TopoDS_Shape mirror(const gp_Ax2&) const;