diff --git a/src/libs/vgeometry/vabstractcurve.cpp b/src/libs/vgeometry/vabstractcurve.cpp index 962a7f6b6..8a4cd9468 100644 --- a/src/libs/vgeometry/vabstractcurve.cpp +++ b/src/libs/vgeometry/vabstractcurve.cpp @@ -76,7 +76,7 @@ QVector VAbstractCurve::FromBegin(const QVector &points, const { if (theBegin == false) { - if (IsPointOnLineSegment(begin.toPoint(), points.at(i).toPoint(), points.at(i+1).toPoint())) + if (IsPointOnLineSegment(begin, points.at(i), points.at(i+1))) { theBegin = true; segment.append(begin); diff --git a/src/libs/vgeometry/vgobject.cpp b/src/libs/vgeometry/vgobject.cpp index 7f75206d5..e13d0fc89 100644 --- a/src/libs/vgeometry/vgobject.cpp +++ b/src/libs/vgeometry/vgobject.cpp @@ -418,7 +418,7 @@ void VGObject::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c * * Original idea http://www.sunshine2k.de/coding/java/PointOnLine/PointOnLine.html */ -bool VGObject::IsPointOnLineSegment(const QPoint &t, const QPoint &p1, const QPoint &p2) +bool VGObject::IsPointOnLineSegment(const QPointF &t, const QPointF &p1, const QPointF &p2) { // The test point must lie inside the bounding box spanned by the two line points. if (not ( (p1.x() <= t.x() && t.x() <= p2.x()) || (p2.x() <= t.x() && t.x() <= p1.x()) )) @@ -443,7 +443,7 @@ bool VGObject::IsPointOnLineSegment(const QPoint &t, const QPoint &p1, const QPo * * The pdp is zero only if the t lies on the line e1 = vector from p1 to p2. */ -bool VGObject::IsPointOnLineviaPDP(const QPoint &t, const QPoint &p1, const QPoint &p2) +bool VGObject::IsPointOnLineviaPDP(const QPointF &t, const QPointF &p1, const QPointF &p2) { return ( qAbs(PerpDotProduct(p1, p2, t) < GetEpsilon(p1, p2)) ); } @@ -454,7 +454,7 @@ bool VGObject::IsPointOnLineviaPDP(const QPoint &t, const QPoint &p1, const QPoi * This is actually the same as the area of the triangle defined by the three points, multiplied by 2. * @return 2 * triangleArea(a,b,c) */ -double VGObject::PerpDotProduct(const QPoint &t, const QPoint &p1, const QPoint &p2) +double VGObject::PerpDotProduct(const QPointF &t, const QPointF &p1, const QPointF &p2) { return (p1.x() - t.x()) * (p2.y() - t.y()) - (p1.y() - t.y()) * (p2.x() - t.x()); } @@ -470,8 +470,8 @@ double VGObject::PerpDotProduct(const QPoint &t, const QPoint &p1, const QPoint */ double VGObject::GetEpsilon(const QPointF &p1, const QPointF &p2) { - const int dx1 = p2.toPoint().x() - p1.toPoint().x(); - const int dy1 = p2.toPoint().y() - p1.toPoint().y(); + const double dx1 = p2.x() - p1.x(); + const double dy1 = p2.y() - p1.y(); const double epsilon = 0.003 * (dx1 * dx1 + dy1 * dy1); //-V636 return epsilon; } diff --git a/src/libs/vgeometry/vgobject.h b/src/libs/vgeometry/vgobject.h index 41e608e8d..58d6a3b1d 100644 --- a/src/libs/vgeometry/vgobject.h +++ b/src/libs/vgeometry/vgobject.h @@ -82,15 +82,15 @@ public: static QPointF ClosestPoint(const QLineF &line, const QPointF &point); static QPointF addVector (const QPointF &p, const QPointF &p1, const QPointF &p2, qreal k); static void LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c); - static bool IsPointOnLineSegment (const QPoint &t, const QPoint &p1, const QPoint &p2); + static bool IsPointOnLineSegment (const QPointF &t, const QPointF &p1, const QPointF &p2); static QVector GetReversePoints(const QVector &points); static int GetLengthContour(const QVector &contour, const QVector &newPoints); private: QSharedDataPointer d; - static bool IsPointOnLineviaPDP(const QPoint &t, const QPoint &p1, const QPoint &p2); - static double PerpDotProduct(const QPoint &t, const QPoint &p1, const QPoint &p2); + static bool IsPointOnLineviaPDP(const QPointF &t, const QPointF &p1, const QPointF &p2); + static double PerpDotProduct(const QPointF &t, const QPointF &p1, const QPointF &p2); static double GetEpsilon(const QPointF &p1, const QPointF &p2); static int PointInCircle (const QPointF &p, const QPointF ¢er, qreal radius); diff --git a/src/libs/vpatterndb/vdetail.cpp b/src/libs/vpatterndb/vdetail.cpp index 137b8dff3..5dc511d55 100644 --- a/src/libs/vpatterndb/vdetail.cpp +++ b/src/libs/vpatterndb/vdetail.cpp @@ -418,7 +418,7 @@ QVector VDetail::SeamAllowancePoints(const VContainer *data) const const QPointF begin = StartSegment(data, i); const QPointF end = EndSegment(data, i); - QVector nodePoints = curve->GetSegmentPoints(begin, end, at(i).getReverse()); + const QVector nodePoints = curve->GetSegmentPoints(begin, end, at(i).getReverse()); pointsEkv << biasPoints(nodePoints, at(i).getMx(), at(i).getMy()); } break; @@ -520,7 +520,14 @@ int VDetail::indexOfNode(const QVector &list, const quint32 &id) //--------------------------------------------------------------------------------------------------------------------- QPointF VDetail::StartSegment(const VContainer *data, const int &i) const { - QPointF begin; + if (i < 0 && i > CountNode()-1) + { + return QPointF(); + } + + const QSharedPointer curve = data->GeometricObject(at(i).getId()); + + QPointF begin = curve->GetPoints().first(); if (CountNode() > 1) { if (i == 0) @@ -544,7 +551,14 @@ QPointF VDetail::StartSegment(const VContainer *data, const int &i) const //--------------------------------------------------------------------------------------------------------------------- QPointF VDetail::EndSegment(const VContainer *data, const int &i) const { - QPointF end; + if (i < 0 && i > CountNode()-1) + { + return QPointF(); + } + + const QSharedPointer curve = data->GeometricObject(at(i).getId()); + + QPointF end = curve->GetPoints().last(); if (CountNode() > 2) { if (i == CountNode() - 1) diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp index cd441496f..c4153c436 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp @@ -101,10 +101,8 @@ QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF ¢e break; case 2: { - const bool flagP1 = VGObject::IsPointOnLineSegment (p1.toPoint(), firstPoint.toPoint(), - secondPoint.toPoint()); - const bool flagP2 = VGObject::IsPointOnLineSegment (p2.toPoint(), firstPoint.toPoint(), - secondPoint.toPoint()); + const bool flagP1 = VGObject::IsPointOnLineSegment (p1, firstPoint, secondPoint); + const bool flagP2 = VGObject::IsPointOnLineSegment (p2, firstPoint, secondPoint); if ((flagP1 == true && flagP2 == true) || (flagP1 == false && flagP2 == false)/*In case we have something wrong*/) {