From cc320aa80263718f781a2728ebd3c401f1486207 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Mon, 1 Oct 2018 15:12:32 -0400 Subject: [PATCH] Handle Straight Line BSplines --- src/Mod/TechDraw/App/Geometry.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/Mod/TechDraw/App/Geometry.cpp b/src/Mod/TechDraw/App/Geometry.cpp index a868464b51..bca84bf340 100644 --- a/src/Mod/TechDraw/App/Geometry.cpp +++ b/src/Mod/TechDraw/App/Geometry.cpp @@ -33,12 +33,15 @@ #include #include #include +#include +#include #include #include #include #include #include #include +#include #include #include #include @@ -512,7 +515,6 @@ BSpline::BSpline(const TopoDS_Edge &e) endAngle += 2.0 * M_PI; } - Standard_Real tol3D = 0.001; //1/1000 of a mm? screen can't resolve this Standard_Integer maxDegree = 3, maxSegment = 100; Handle(BRepAdaptor_HCurve) hCurve = new BRepAdaptor_HCurve(c); @@ -566,9 +568,27 @@ bool BSpline::isLine() { bool result = false; BRepAdaptor_Curve c(occEdge); + Handle(Geom_BSplineCurve) spline = c.BSpline(); - if (spline->NbPoles() == 2) { - result = true; + if (spline->Degree() == 1) { + //TODO: this test is a bit sketchy + // proper test would be to test each pole for collinearity. + + double splineLength = GCPnts_AbscissaPoint::Length (c); + double f = c.FirstParameter(); + double l = c.LastParameter(); + gp_Pnt s = c.Value(f); + gp_Pnt e = c.Value(l); + + bool samePnt = s.IsEqual(e,FLT_EPSILON); + if (!samePnt) { + Base::Vector3d startPnt(s.X(), s.Y(), 0.0); + Base::Vector3d endPnt(e.X(), e.Y(), 0.0); + double endLength = (startPnt - endPnt).Length(); + if (DrawUtil::fpCompare(splineLength,endLength)) { + result = true; + } + } } return result; }