From 5ecbc89f30f9a792b9a114c23214da565845858a Mon Sep 17 00:00:00 2001 From: Eric Trombly Date: Mon, 6 Apr 2020 06:34:30 -0500 Subject: [PATCH] change isOnLine to isOnLineSegment --- src/Base/Vector3D.cpp | 4 ++-- src/Base/Vector3D.h | 4 ++-- src/Base/VectorPy.xml | 6 +++--- src/Base/VectorPyImp.cpp | 4 ++-- src/Mod/Path/PathScripts/PathSurface.py | 14 +++++++------- src/Mod/Path/PathScripts/PathWaterline.py | 6 +++--- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Base/Vector3D.cpp b/src/Base/Vector3D.cpp index a5d34a7259..a0c67d690d 100644 --- a/src/Base/Vector3D.cpp +++ b/src/Base/Vector3D.cpp @@ -193,7 +193,7 @@ Vector3<_Precision> Vector3<_Precision>::Cross(const Vector3<_Precision>& rcVct) } template -bool Vector3<_Precision>::IsOnLine (const Vector3<_Precision>& startVct, const Vector3<_Precision>& endVct) const +bool Vector3<_Precision>::IsOnLineSegment (const Vector3<_Precision>& startVct, const Vector3<_Precision>& endVct) const { Vector3<_Precision> vectorAB = endVct - startVct; Vector3<_Precision> vectorAC = *this - startVct; @@ -206,7 +206,7 @@ bool Vector3<_Precision>::IsOnLine (const Vector3<_Precision>& startVct, const V if (dotproduct < 0) return false; - if (dotproduct > vectorAB.Length() * vectorAB.Length()) + if (dotproduct > vectorAB.Sqr()) return false; return true; diff --git a/src/Base/Vector3D.h b/src/Base/Vector3D.h index b0f7e2ebbb..13651fc49a 100644 --- a/src/Base/Vector3D.h +++ b/src/Base/Vector3D.h @@ -133,8 +133,8 @@ public: bool operator == (const Vector3<_Precision>& rcVct) const; //@} - /// Check if Vector is on a line - bool IsOnLine (const Vector3<_Precision>& startVct, const Vector3<_Precision>& endVct) const; + /// Check if Vector is on a line segment + bool IsOnLineSegment (const Vector3<_Precision>& startVct, const Vector3<_Precision>& endVct) const; /** @name Modification */ //@{ diff --git a/src/Base/VectorPy.xml b/src/Base/VectorPy.xml index 2f5a8486f0..cd1ce5b710 100644 --- a/src/Base/VectorPy.xml +++ b/src/Base/VectorPy.xml @@ -74,10 +74,10 @@ - + - isOnLine(Vector, Vector) - checks if Vector is on a line + isOnLineSegment(Vector, Vector) + checks if Vector is on a line segment diff --git a/src/Base/VectorPyImp.cpp b/src/Base/VectorPyImp.cpp index 96328aab97..778e9907f4 100644 --- a/src/Base/VectorPyImp.cpp +++ b/src/Base/VectorPyImp.cpp @@ -435,7 +435,7 @@ PyObject* VectorPy::cross(PyObject *args) return new VectorPy(v); } -PyObject* VectorPy::isOnLine(PyObject *args) +PyObject* VectorPy::isOnLineSegment(PyObject *args) { PyObject *start, *end; if (!PyArg_ParseTuple(args, "OO",&start, &end)) @@ -456,7 +456,7 @@ PyObject* VectorPy::isOnLine(PyObject *args) VectorPy::PointerType start_ptr = reinterpret_cast(start_vec->_pcTwinPointer); VectorPy::PointerType end_ptr = reinterpret_cast(end_vec->_pcTwinPointer); - Py::Boolean result = this_ptr->IsOnLine(*start_ptr, *end_ptr); + Py::Boolean result = this_ptr->IsOnLineSegment(*start_ptr, *end_ptr); return Py::new_reference_to(result); } diff --git a/src/Mod/Path/PathScripts/PathSurface.py b/src/Mod/Path/PathScripts/PathSurface.py index 8663b05b95..9e63b6f359 100644 --- a/src/Mod/Path/PathScripts/PathSurface.py +++ b/src/Mod/Path/PathScripts/PathSurface.py @@ -1985,7 +1985,7 @@ class ObjectSurface(PathOp.ObjectOp): for v in range(1, lenOS): nxt = OS[v + 1] if optimize is True: - iPOL = prev.isOnLine(nxt, pnt) + iPOL = prev.isOnLineSegment(nxt, pnt) if iPOL is True: pnt = nxt else: @@ -2039,7 +2039,7 @@ class ObjectSurface(PathOp.ObjectOp): ep = FreeCAD.Vector(v2[0], v2[1], 0.0) # end point cp = FreeCAD.Vector(v1[0], v1[1], 0.0) # check point (first / middle point) - iC = sp.isOnLine(ep, cp) + iC = sp.isOnLineSegment(ep, cp) if iC is True: inLine.append('BRK') chkGap = True @@ -2145,7 +2145,7 @@ class ObjectSurface(PathOp.ObjectOp): cp = FreeCAD.Vector(v1[0], v1[1], 0.0) # check point (start point of segment) ep = FreeCAD.Vector(v2[0], v2[1], 0.0) # end point - iC = sp.isOnLine(ep, cp) + iC = sp.isOnLineSegment(ep, cp) if iC is True: inLine.append('BRK') chkGap = True @@ -2564,7 +2564,7 @@ class ObjectSurface(PathOp.ObjectOp): # first item will be compared to the last point, but I think that should work output = [Path.Command('G1', {'X': PNTS[i].x, 'Y': PNTS[i].y, 'Z': PNTS[i].z, 'F': self.horizFeed}) for i in range(0, len(PNTS) - 1) - if not PNTS[i].isOnLine(PNTS[i -1],PNTS[i + 1])] + if not PNTS[i].isOnLineSegment(PNTS[i -1],PNTS[i + 1])] output.append(Path.Command('G1', {'X': PNTS[-1].x, 'Y': PNTS[-1].y, 'Z': PNTS[-1].z, 'F': self.horizFeed})) else: output = [Path.Command('G1', {'X': pnt.x, 'Y': pnt.y, 'Z': pnt.z, 'F': self.horizFeed}) for pnt in PNTS] @@ -2844,7 +2844,7 @@ class ObjectSurface(PathOp.ObjectOp): # Process point if prcs is True: if optimize is True: - iPOL = prev.isOnLine(nxt, pnt) + iPOL = prev.isOnLineSegment(nxt, pnt) if iPOL is True: onLine = True else: @@ -3418,7 +3418,7 @@ class ObjectSurface(PathOp.ObjectOp): self.holdPoint = ocl.Point(float("inf"), float("inf"), float("inf")) if self.onHold is False: - if not optimize or not FreeCAD.Vector(prev.x, prev.y, prev.z).isOnLine(FreeCAD.Vector(nxt.x, nxt.y, nxt.z), FreeCAD.Vector(pnt.x, pnt.y, pnt.z)): + if not optimize or not FreeCAD.Vector(prev.x, prev.y, prev.z).isOnLineSegment(FreeCAD.Vector(nxt.x, nxt.y, nxt.z), FreeCAD.Vector(pnt.x, pnt.y, pnt.z)): output.append(Path.Command('G1', {'X': pnt.x, 'Y': pnt.y, 'Z': pnt.z, 'F': self.horizFeed})) # elif i == lastCLP: # output.append(Path.Command('G1', {'X': pnt.x, 'Y': pnt.y, 'Z': pnt.z, 'F': self.horizFeed})) @@ -3539,7 +3539,7 @@ class ObjectSurface(PathOp.ObjectOp): else: optimize = False - if not optimize or not FreeCAD.Vector(prev.x, prev.y, prev.z).isOnLine(FreeCAD.Vector(nxt.x, nxt.y, nxt.z), FreeCAD.Vector(pnt.x, pnt.y, pnt.z)): + if not optimize or not FreeCAD.Vector(prev.x, prev.y, prev.z).isOnLineSegment(FreeCAD.Vector(nxt.x, nxt.y, nxt.z), FreeCAD.Vector(pnt.x, pnt.y, pnt.z)): output.append(Path.Command('G1', {'X': pnt.x, 'Y': pnt.y, 'F': self.horizFeed})) # Rotate point data diff --git a/src/Mod/Path/PathScripts/PathWaterline.py b/src/Mod/Path/PathScripts/PathWaterline.py index 969c8c7478..0362680580 100644 --- a/src/Mod/Path/PathScripts/PathWaterline.py +++ b/src/Mod/Path/PathScripts/PathWaterline.py @@ -1783,7 +1783,7 @@ class ObjectWaterline(PathOp.ObjectOp): ep = FreeCAD.Vector(v2[0], v2[1], 0.0) # end point cp = FreeCAD.Vector(v1[0], v1[1], 0.0) # check point (first / middle point) - iC = sp.isOnLine(ep, cp) + iC = sp.isOnLineSegment(ep, cp) if iC is True: inLine.append('BRK') chkGap = True @@ -1889,7 +1889,7 @@ class ObjectWaterline(PathOp.ObjectOp): cp = FreeCAD.Vector(v1[0], v1[1], 0.0) # check point (start point of segment) ep = FreeCAD.Vector(v2[0], v2[1], 0.0) # end point - iC = sp.isOnLine(ep, cp) + iC = sp.isOnLineSegment(ep, cp) if iC is True: inLine.append('BRK') chkGap = True @@ -2696,7 +2696,7 @@ class ObjectWaterline(PathOp.ObjectOp): else: optimize = False - if not optimize or not FreeCAD.Vector(prev.x, prev.y, prev.z).isOnLine(FreeCAD.Vector(nxt.x, nxt.y, nxt.z), FreeCAD.Vector(pnt.x, pnt.y, pnt.z)): + if not optimize or not FreeCAD.Vector(prev.x, prev.y, prev.z).isOnLineSegment(FreeCAD.Vector(nxt.x, nxt.y, nxt.z), FreeCAD.Vector(pnt.x, pnt.y, pnt.z)): output.append(Path.Command('G1', {'X': pnt.x, 'Y': pnt.y, 'F': self.horizFeed})) # Rotate point data