From 9f919ffe8aa0585c7c5d54406abf15fd4e33a33e Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sun, 23 Sep 2018 15:51:28 +0300 Subject: [PATCH] Improve seam allowance. Case with custom seam allowance. --HG-- branch : release --- src/libs/vlayout/vabstractpiece.cpp | 45 +++++++++-------------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index f86b2b4c3..6fe8186e9 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -202,6 +202,19 @@ QVector RollbackSeamAllowance(QVector points, const QLineF &cu *success = true; } } + + if (not *success && points.size() > 1) + { + QPointF crosPoint; + QLineF secondLast(points.at(points.size()-2), points.at(points.size()-1)); + QLineF::IntersectType type = secondLast.intersect(cuttingEdge, &crosPoint); + if (type != QLineF::NoIntersection && IsOutsidePoint(secondLast.p1(), secondLast.p2(), crosPoint)) + { + points.append(crosPoint); + *success = true; + } + } + return points; } @@ -252,12 +265,6 @@ QVector AngleByLength(QVector points, QPointF p2, const QLineF { bool success = false; points = RollbackSeamAllowance(points, bigLine2, &success); - if (not success) - { - // Cannot find clipping point. - // Show at least something. - points.append(sp2); - } } else { @@ -306,12 +313,6 @@ QVector AngleByIntersection(const QVector &points, QPointF p1, {// Because artificial loop can lead to wrong clipping we must rollback current seam allowance points bool success = false; pointsIntr = RollbackSeamAllowance(pointsIntr, edge2, &success); - if (not success) - { - // Cannot find clipping point. - // Show at least something. - pointsIntr.append(px); - } } // Second point @@ -368,12 +369,6 @@ QVector AngleByFirstSymmetry(const QVector &points, QPointF p1 {// Because artificial loop can lead to wrong clipping we must rollback current seam allowance points bool success = false; pointsIntr = RollbackSeamAllowance(pointsIntr, bigLine2, &success); - if (not success) - { - // Cannot find clipping point. - // Show at least something. - pointsIntr.append(px); - } } type = sEdge.intersect(bigLine2, &px); @@ -430,12 +425,6 @@ QVector AngleBySecondSymmetry(const QVector &points, QPointF p {// Because artificial loop can lead to wrong clipping we must rollback current seam allowance points bool success = false; pointsIntr = RollbackSeamAllowance(pointsIntr, bigLine2, &success); - if (not success) - { - // Cannot find clipping point. - // Show at least something. - pointsIntr.append(px); - } } type = sEdge.intersect(bigLine2, &px); @@ -541,13 +530,7 @@ QVector AngleBySecondRightAngle(QVector points, QPointF p2, QP // Because artificial loop can lead to wrong clipping we must rollback current seam allowance points bool success = false; points = RollbackSeamAllowance(points, edge, &success); - if (not success) - { - // Cannot find clipping point. - // Show at least something. - points.append(px); - } - else + if (success) { px = points.last(); }