From f31988b0101fe11565be4abf8d6c710718357169 Mon Sep 17 00:00:00 2001 From: Tomas Pavlicek Date: Thu, 24 Jun 2021 20:47:10 +0200 Subject: [PATCH] TechDraw - Add edge midpoint cosmetic vertex fix - added comments --- src/Mod/TechDraw/App/Geometry.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Mod/TechDraw/App/Geometry.cpp b/src/Mod/TechDraw/App/Geometry.cpp index a44013bc21..b6c3637137 100644 --- a/src/Mod/TechDraw/App/Geometry.cpp +++ b/src/Mod/TechDraw/App/Geometry.cpp @@ -326,15 +326,24 @@ Base::Vector3d BaseGeom::getEndPoint() Base::Vector3d BaseGeom::getMidPoint() { + // Midpoint calculation - additional details here: https://forum.freecadweb.org/viewtopic.php?f=35&t=59582 + BRepAdaptor_Curve curve(occEdge); + + // As default, set the midpoint curve parameter value by simply averaging start point and end point values double midParam = (curve.FirstParameter() + curve.LastParameter())/2.0; + // GCPnts_AbscissaPoint allows us to compute the parameter value depending on the distance along a curve. + // In this case we want the curve parameter value for the half of the whole curve length, + // thus GCPnts_AbscissaPoint::Length(curve)/2 is the distance to go from the start point. GCPnts_AbscissaPoint abscissa(Precision::Confusion(), curve, GCPnts_AbscissaPoint::Length(curve)/2.0, curve.FirstParameter()); if (abscissa.IsDone()) { + // The computation was successful - otherwise keep the average, it is better than nothing midParam = abscissa.Parameter(); } + // Now compute coordinates of the point on curve for curve parameter value equal to midParam BRepLProp_CLProps props(curve, midParam, 0, Precision::Confusion()); const gp_Pnt &point = props.Value();