change isOnLine to isOnLineSegment
This commit is contained in:
@@ -193,7 +193,7 @@ Vector3<_Precision> Vector3<_Precision>::Cross(const Vector3<_Precision>& rcVct)
|
||||
}
|
||||
|
||||
template <class _Precision>
|
||||
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;
|
||||
|
||||
@@ -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 */
|
||||
//@{
|
||||
|
||||
@@ -74,10 +74,10 @@
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="isOnLine" Const="true">
|
||||
<Methode Name="isOnLineSegment" Const="true">
|
||||
<Documentation>
|
||||
<UserDocu>isOnLine(Vector, Vector)
|
||||
checks if Vector is on a line
|
||||
<UserDocu>isOnLineSegment(Vector, Vector)
|
||||
checks if Vector is on a line segment
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
|
||||
@@ -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<VectorPy::PointerType>(start_vec->_pcTwinPointer);
|
||||
VectorPy::PointerType end_ptr = reinterpret_cast<VectorPy::PointerType>(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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user