[TD]fix regression on Links with scale

This commit is contained in:
wandererfan
2023-11-13 08:28:00 -05:00
committed by WandererFan
parent b998ea29bd
commit 69761e72d2

View File

@@ -30,6 +30,7 @@
# include <TopoDS.hxx>
# include <TopoDS_Iterator.hxx>
# include <TopoDS_Vertex.hxx>
# include <BRepBuilderAPI_Copy.hxx>
#endif
#include <App/Document.h>
@@ -203,7 +204,16 @@ std::vector<TopoDS_Shape> ShapeExtractor::getXShapes(const App::Link* xLink)
} else {
// link points to a regular object, not another link? no sublinks?
TopoDS_Shape xLinkShape = getShapeFromXLink(xLink);
xSourceShapes.push_back(xLinkShape);
if (!xLinkShape.IsNull()) {
// make the "located, oriented" version of the shape.
netTransform = xLinkPlacement.toMatrix() * linkScale;
// copying the shape prevents "non-orthogonal GTrsf" errors in some versions
// of OCC. Something to do with triangulation of shape??
BRepBuilderAPI_Copy copier(xLinkShape);
auto ts = Part::TopoShape(copier.Shape());
ts.transformGeometry(netTransform);
xSourceShapes.push_back(ts.getShape());
}
}
return xSourceShapes;
}
@@ -215,6 +225,10 @@ TopoDS_Shape ShapeExtractor::getShapeFromXLink(const App::Link* xLink)
if (xLink->hasPlacement()) {
xLinkPlacement = xLink->getLinkPlacementProperty()->getValue();
}
Base::Matrix4D linkScale; // default constructor is an identity matrix, possibly scale it with link's scale
if(xLink->getScaleProperty() || xLink->getScaleVectorProperty()) {
linkScale.scale(xLink->getScaleVector());
}
int depth = 0; //0 is default value, related to recursion of Links???
App::DocumentObject* linkedObject = xLink->getLink(depth);
if (linkedObject) {
@@ -229,6 +243,8 @@ TopoDS_Shape ShapeExtractor::getShapeFromXLink(const App::Link* xLink)
Part::TopoShape ts(shape);
if (ts.isInfinite()) {
shape = stripInfiniteShapes(shape);
// the shape must have a triangulation or it will cause a failure
// when later transforms are applied
ts = Part::TopoShape(shape);
}
//ts might be garbage now, better check