Part: Add bakeInTransform method for TopoShape

This method can be used to bake in transform directly into geometry.
Normally the setTransform or setPlacement methods only store additional
positional data within the shape without changing the actual geometry.
So if we have some geometry placed at 0,0,0 and we want to have few
copies of that shape the goemetry stays intact but additional transform
is stored. This method can be used to alter the gometry and reset the
transform to identity. It helps with model stability, as not every
method correctly handles that additional transform metadata.
This commit is contained in:
Kacper Donat
2025-11-23 23:05:46 +01:00
parent 1555f65075
commit 4cbf10f045
2 changed files with 25 additions and 0 deletions

View File

@@ -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<TopoShape> 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()) {

View File

@@ -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;