diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 7109ad833..a7beb9057 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -268,6 +268,56 @@ bool IsPassmarksPossible(const QVector &path) return countPointNodes >= 3 || (countPointNodes >= 1 && countOthers >= 1); } + +//--------------------------------------------------------------------------------------------------------------------- +bool FixNotchPoint(const QVector &seamAllowance, const QPointF ¬chBase, QPointF *notch) +{ + bool fixed = true; + if (not VAbstractCurve::IsPointOnCurve(seamAllowance, *notch)) + { + fixed = false; + QLineF axis = QLineF(notchBase, *notch); + axis.setLength(ToPixel(50, Unit::Cm)); + const QVector points = VAbstractCurve::CurveIntersectLine(seamAllowance, axis); + + if (points.size() > 0) + { + if (points.size() == 1) + { + *notch = points.at(0); + fixed = true; + } + else + { + QMap forward; + + for ( qint32 i = 0; i < points.size(); ++i ) + { + if (points.at(i) == notchBase) + { // Always seek unique intersection + continue; + } + + const QLineF length(notchBase, points.at(i)); + if (qAbs(length.angle() - axis.angle()) < 0.1) + { + forward.insert(length.length(), i); + } + } + + + // Closest point is not always want we need. First return point in forward direction if exists. + if (not forward.isEmpty()) + { + *notch = points.at(forward.first()); + fixed = true; + } + } + } + } + + return fixed; +} } //--------------------------------------------------------------------------------------------------------------------- @@ -1257,6 +1307,11 @@ QVector VPiece::SAPassmark(const QVector &path, VSAPoint &pr return QVector(); // Something wrong } + if (not FixNotchPoint(seamAllowance, passmarkSAPoint, &seamPassmarkSAPoint)) + { + // Show warning + } + const qreal width = ToPixel(GetSAWidth(), *data->GetPatternUnit()); QVector passmarksLines;