diff --git a/src/Mod/TechDraw/App/ShapeExtractor.cpp b/src/Mod/TechDraw/App/ShapeExtractor.cpp index b71765cfac..e981826e7d 100644 --- a/src/Mod/TechDraw/App/ShapeExtractor.cpp +++ b/src/Mod/TechDraw/App/ShapeExtractor.cpp @@ -30,6 +30,7 @@ # include # include # include +# include #endif #include @@ -203,7 +204,16 @@ std::vector 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