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:
@@ -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()) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user