From 7f5ec1c9a1b0d3354a1f20a4239a1047a3d80f45 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sun, 3 Nov 2019 09:30:36 +0200 Subject: [PATCH] It is better to not allow user to set seam allowance width to 0. 0 seam allowance creates intersections with a main path. --HG-- branch : develop --- src/libs/vlayout/vabstractpiece.cpp | 39 +++++++---------------------- src/libs/vlayout/vsapoint.h | 1 + 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index 15bc43293..ae8500583 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -53,6 +53,7 @@ const qreal maxL = 2.5; const qreal VSAPoint::passmarkFactor = 0.5; const qreal VSAPoint::maxPassmarkLength = (10/*mm*/ / 25.4) * PrintDPI; +const qreal VSAPoint::minSAWidth = ToPixel(0.01, Unit::Mm); namespace { @@ -1004,6 +1005,7 @@ QVector VAbstractPiece::Equidistant(QVector points, qreal wid qDebug()<<"Width < 0."; return QVector(); } + width = qMax(width, VSAPoint::minSAWidth); // DumpVector(points, QStringLiteral("input.json.XXXXXX")); // Uncomment for dumping test data @@ -1256,6 +1258,8 @@ QVector VAbstractPiece::EkvPoint(QVector points, const VSAPoin return QVector(); } + width = qMax(width, VSAPoint::minSAWidth); + if (p2Line1 != p2Line2) { qDebug()<<"Last points of two lines must be equal."; @@ -1417,21 +1421,8 @@ QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- QLineF VAbstractPiece::ParallelLine(const VSAPoint &p1, const VSAPoint &p2, qreal width) { - qreal w1 = p1.GetSAAfter(); - if (w1 < 0) - { - w1 = width; - } - - qreal w2 = p2.GetSABefore(); - if (w2 < 0) - { - w2 = width; - } - - const QLineF paralel = QLineF(SingleParallelPoint(p1, p2, 90, w1), - SingleParallelPoint(p2, p1, -90, w2)); - return paralel; + return QLineF(SingleParallelPoint(p1, p2, 90, p1.GetSAAfter(width)), + SingleParallelPoint(p2, p1, -90, p2.GetSABefore(width))); } //--------------------------------------------------------------------------------------------------------------------- @@ -1576,7 +1567,7 @@ qreal VSAPoint::GetSABefore(qreal width) const { return width; } - return m_before; + return qMax(m_before, minSAWidth); } //--------------------------------------------------------------------------------------------------------------------- @@ -1586,25 +1577,13 @@ qreal VSAPoint::GetSAAfter(qreal width) const { return width; } - return m_after; + return qMax(m_after, minSAWidth); } //--------------------------------------------------------------------------------------------------------------------- qreal VSAPoint::MaxLocalSA(qreal width) const { - qreal w1 = GetSAAfter(); - if (w1 < 0) - { - w1 = width; - } - - qreal w2 = GetSABefore(); - if (w2 < 0) - { - w2 = width; - } - - return qMax(w1, w2); + return qMax(GetSAAfter(width), GetSABefore(width)); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vlayout/vsapoint.h b/src/libs/vlayout/vsapoint.h index e5ed676d2..f2a5e23f1 100644 --- a/src/libs/vlayout/vsapoint.h +++ b/src/libs/vlayout/vsapoint.h @@ -71,6 +71,7 @@ public: static const qreal passmarkFactor; static const qreal maxPassmarkLength; + static const qreal minSAWidth; private: qreal m_before{-1};