TechDraw - Add edge midpoint cosmetic vertex fix - added comments

This commit is contained in:
Tomas Pavlicek
2021-06-24 20:47:10 +02:00
parent 505a12cb5a
commit f31988b010

View File

@@ -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();