From ed87ce0af089c1a2a4c917c63535fa66915a615b Mon Sep 17 00:00:00 2001 From: Florian Foinant-Willig Date: Thu, 28 Sep 2023 22:51:28 +0200 Subject: [PATCH] TechDraw: Implements projected Length dimension --- src/Mod/TechDraw/App/DrawViewDimension.cpp | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/Mod/TechDraw/App/DrawViewDimension.cpp b/src/Mod/TechDraw/App/DrawViewDimension.cpp index 0bd68aeb84..a1429776e9 100644 --- a/src/Mod/TechDraw/App/DrawViewDimension.cpp +++ b/src/Mod/TechDraw/App/DrawViewDimension.cpp @@ -42,6 +42,10 @@ # include # include # include +# include +# include +# include +# include # include # include # include @@ -745,7 +749,29 @@ pointPair DrawViewDimension::getPointsEdgeVert(ReferenceVector references) if (!vertex || !edge) { throw Base::RuntimeError("Missing geometry for dimension (4)"); } - return closestPoints(edge->getOCCEdge(), vertex->getOCCVertex()); + + //get curve from edge + double start, end; // curve parameters + const Handle(Geom_Surface) hplane = new Geom_Plane(gp_Ax3()); + auto const occCurve = BRep_Tool::CurveOnPlane(edge->getOCCEdge() + , hplane + , TopLoc_Location() + , start + , end); + auto const occPoint = gp_Pnt2d(vertex->x(), vertex->y()); + //project point on curve + auto projector = Geom2dAPI_ProjectPointOnCurve(occPoint, occCurve); + if (projector.NbPoints() > 0) { + auto p1 = Base::Vector3d(vertex->x(), vertex->y(), 0.0); + auto p2 = Base::Vector3d(projector.NearestPoint().X() + , projector.NearestPoint().Y() + , 0.0); + return pointPair(p1, p2); + } + else { + // unable to project + return closestPoints(edge->getOCCEdge(), vertex->getOCCVertex()); + } } //this is a 3d object