diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index d339e2dc2..6601067ed 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -1441,7 +1441,16 @@ QVector VPiece::SAPassmark(const VPiecePassmarkData &passmarkData, const line = QLineF(intersections.last(), passmarkData.passmarkSAPoint); if (not passmarkData.passmarkSAPoint.IsManualPasskmarkLength()) { - line.setLength(qMin(width * VSAPoint::passmarkFactor, VSAPoint::maxPassmarkLength)); + const qreal length = qMin(width * VSAPoint::passmarkFactor, VSAPoint::maxPassmarkLength); + if (length <= accuracyPointOnLine) + { + const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is " + "less than minimal allowed.") + .arg(passmarkData.nodeName, passmarkData.pieceName); + qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg; + return; + } + line.setLength(length); } else { @@ -1469,10 +1478,21 @@ QVector VPiece::SAPassmark(const VPiecePassmarkData &passmarkData, const if (passmarkData.passmarkAngleType == PassmarkAngleType::Straightforward) { - QLineF line = QLineF(seamPassmarkSAPoint, passmarkData.passmarkSAPoint); - line.setLength(passmarkData.passmarkSAPoint.PassmarkLength(passmarkData.saWidth)); - passmarksLines += CreatePassmarkLines(passmarkData.passmarkLineType, passmarkData.passmarkAngleType, line, - seamAllowance); + const qreal length = passmarkData.passmarkSAPoint.PassmarkLength(passmarkData.saWidth); + if (not passmarkData.passmarkSAPoint.IsManualPasskmarkLength() && length <= accuracyPointOnLine) + { + const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less " + "than minimal allowed.") + .arg(passmarkData.nodeName, passmarkData.pieceName); + qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg; + } + else + { + QLineF line = QLineF(seamPassmarkSAPoint, passmarkData.passmarkSAPoint); + line.setLength(length); + passmarksLines += CreatePassmarkLines(passmarkData.passmarkLineType, passmarkData.passmarkAngleType, line, + seamAllowance); + } } else if (passmarkData.passmarkAngleType == PassmarkAngleType::Bisector) { @@ -1525,15 +1545,44 @@ QVector VPiece::SAPassmark(const VPiecePassmarkData &passmarkData, const } //--------------------------------------------------------------------------------------------------------------------- -QVector VPiece::BuiltInSAPassmark(const VPiecePassmarkData &passmarkData, const QVector &mainPath) +QVector VPiece::BuiltInSAPassmark(const VPiecePassmarkData &passmarkData, + const QVector &mainPath) const { + qreal length = 0; + if (not IsSeamAllowanceBuiltIn()) + { + length = passmarkData.passmarkSAPoint.PassmarkLength(passmarkData.saWidth); + if (not passmarkData.passmarkSAPoint.IsManualPasskmarkLength() && length <= accuracyPointOnLine) + { + const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less " + "than minimal allowed.") + .arg(passmarkData.nodeName, passmarkData.pieceName); + qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg; + return QVector(); + } + } + else + { + if (passmarkData.passmarkSAPoint.IsManualPasskmarkLength()) + { + length = passmarkData.passmarkSAPoint.GetPasskmarkLength(); + } + else + { + const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2' with built in " + "seam allowance. User must manually provide length.") + .arg(passmarkData.nodeName, passmarkData.pieceName); + qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg; + return QVector(); + } + } QVector passmarksLines; QLineF edge1 = QLineF(passmarkData.passmarkSAPoint, passmarkData.previousSAPoint); QLineF edge2 = QLineF(passmarkData.passmarkSAPoint, passmarkData.nextSAPoint); edge1.setAngle(edge1.angle() + edge1.angleTo(edge2)/2.); - edge1.setLength(passmarkData.passmarkSAPoint.PassmarkLength(passmarkData.saWidth)); + edge1.setLength(length); passmarksLines += CreatePassmarkLines(passmarkData.passmarkLineType, passmarkData.passmarkAngleType, edge1, mainPath); @@ -1590,8 +1639,18 @@ QVector VPiece::PassmarkBisector(PassmarkStatus seamPassmarkType, const return QVector(); } + const qreal length = passmarkData.passmarkSAPoint.PassmarkLength(passmarkData.saWidth); + if (not passmarkData.passmarkSAPoint.IsManualPasskmarkLength() && length <= accuracyPointOnLine) + { + const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less " + "than minimal allowed.") + .arg(passmarkData.nodeName, passmarkData.pieceName); + qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg; + return QVector(); + } + edge1.setAngle(edge1.angle() + edge1.angleTo(edge2)/2.); - edge1.setLength(passmarkData.passmarkSAPoint.PassmarkLength(passmarkData.saWidth)); + edge1.setLength(length); return CreatePassmarkLines(passmarkData.passmarkLineType, passmarkData.passmarkAngleType, edge1, seamAllowance); } diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h index f482de936..c0bffdb94 100644 --- a/src/libs/vpatterndb/vpiece.h +++ b/src/libs/vpatterndb/vpiece.h @@ -184,7 +184,7 @@ private: QVector CreatePassmark(const QVector &path, int previousIndex, int passmarkIndex, int nextIndex, const VContainer *data) const; - static QVector BuiltInSAPassmark(const VPiecePassmarkData &passmarkData, const QVector &mainPath); + QVector BuiltInSAPassmark(const VPiecePassmarkData &passmarkData, const QVector &mainPath) const; static QVector PassmarkBisector(PassmarkStatus seamPassmarkType, const VPiecePassmarkData &passmarkData, const QPointF &seamPassmarkSAPoint, const QVector& seamAllowance);