From 3424f34354c35c4b3f67dee153eff587b117f573 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 17 Apr 2024 15:17:39 +0300 Subject: [PATCH] Fix Seam Allowance Issue. --- src/libs/vlayout/vabstractpiece.cpp | 6 + src/libs/vlayout/vabstractpiece.h | 5 +- .../share/25L_Knitting_Bag/input.json | 322 ++++++++++++++++++ .../share/25L_Knitting_Bag/output.json | 144 ++++++++ src/test/ValentinaTest/share/test_data.qrc | 2 + src/test/ValentinaTest/tst_vabstractpiece.cpp | 4 + 6 files changed, 481 insertions(+), 2 deletions(-) create mode 100644 src/test/ValentinaTest/share/25L_Knitting_Bag/input.json create mode 100644 src/test/ValentinaTest/share/25L_Knitting_Bag/output.json diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index e55c72e54..d61473130 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -1258,6 +1258,12 @@ auto VAbstractPiece::EkvPoint(QVector points, const VSAPoint &p1Lin } return points; } + else if (a > 345) + { + points.append(VRawSAPoint(bigLine1.p2(), p2Line1.CurvePoint(), p2Line1.TurnPoint())); + points.append(VRawSAPoint(bigLine2.p1(), p2Line1.CurvePoint(), p2Line1.TurnPoint())); + return points; + } QPointF crosPoint; const QLineF::IntersectType type = bigLine1.intersects(bigLine2, &crosPoint); diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h index 3e78725f6..3a4ebf253 100644 --- a/src/libs/vlayout/vabstractpiece.h +++ b/src/libs/vlayout/vabstractpiece.h @@ -221,7 +221,8 @@ template inline auto VAbstractPiece::CheckPointOnLine(QVector &points, const T &iPoint, const T &prevPoint, const T &nextPoint) -> bool { - if (!IsEkvPointOnLine(iPoint, prevPoint, nextPoint)) + if (!VGObject::IsPointOnLineSegment(iPoint, prevPoint, nextPoint) || + !IsEkvPointOnLine(iPoint, prevPoint, nextPoint)) { points.append(iPoint); return false; @@ -245,7 +246,7 @@ template <> inline auto VAbstractPiece::CheckPointOnLine(QVector &points, const QPointF &iPoint, const QPointF &prevPoint, const QPointF &nextPoint) -> bool { - if (!IsEkvPointOnLine(iPoint, prevPoint, nextPoint)) + if (!VGObject::IsPointOnLineSegment(iPoint, prevPoint, nextPoint, accuracyPointOnLine / 4.)) { points.append(iPoint); return false; diff --git a/src/test/ValentinaTest/share/25L_Knitting_Bag/input.json b/src/test/ValentinaTest/share/25L_Knitting_Bag/input.json new file mode 100644 index 000000000..4a1defaaf --- /dev/null +++ b/src/test/ValentinaTest/share/25L_Knitting_Bag/input.json @@ -0,0 +1,322 @@ +{ + "vector": [ + { + "passmarkClockwiseOpening": false, + "turnPoint": true, + "type": "VSAPoint", + "x": 2269.6800775571364, + "y": -661.873152 + }, + { + "passmarkClockwiseOpening": false, + "turnPoint": true, + "type": "VSAPoint", + "x": 1501.0464, + "y": -661.873152 + }, + { + "curvePoint": true, + "passmarkClockwiseOpening": false, + "turnPoint": true, + "type": "VSAPoint", + "x": 1501.0464, + "y": -661.873152 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 1512.1145995857821, + "y": -659.2664997701993 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 1532.8912663053902, + "y": -652.4991862709662 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 1552.0904133319214, + "y": -643.9354106020951 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 1569.7722176090087, + "y": -633.6511157390513 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 1585.996856080286, + "y": -621.7222446573012 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 1600.824505689387, + "y": -608.2247403323104 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 1620.7340813635424, + "y": -585.3757687481523 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 1642.729570732287, + "y": -549.8802763443196 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 1660.2202896377282, + "y": -509.4772245259127 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 1673.6876536289349, + "y": -464.7741570966591 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 1683.6130782549744, + "y": -416.37861786028685 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 1690.477979064915, + "y": -364.8981506205236 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 1694.7637716078248, + "y": -310.9402991810972 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 1697.5816751093885, + "y": -226.8072443045367 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 1694.9984043727732, + "y": -53.22203976977377 + }, + { + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 1693.0464, + "y": 58.126848 + }, + { + "passmarkClockwiseOpening": false, + "turnPoint": true, + "type": "VSAPoint", + "x": 1189.0464, + "y": 58.12684799999993 + }, + { + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 685.0464, + "y": 58.12684799999986 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 685.2339, + "y": 30.84559799999986 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 687.4135875, + "y": -26.107527000000132 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 694.2339, + "y": -115.12315200000012 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 709.9839, + "y": -236.62315200000012 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 731.9214, + "y": -354.7481520000001 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 751.89015, + "y": -436.5919020000001 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 766.4448375, + "y": -486.7950270000001 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 781.9135875, + "y": -532.3575270000001 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 798.155775, + "y": -572.4356520000001 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 815.030775, + "y": -606.1856520000001 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 832.3979625, + "y": -632.7637770000001 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 850.1167125, + "y": -651.3262770000001 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 863.5551890625, + "y": -659.1836988750001 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "type": "VSAPoint", + "x": 872.5464, + "y": -661.6622145000001 + }, + { + "curvePoint": true, + "passmarkClockwiseOpening": false, + "turnPoint": true, + "type": "VSAPoint", + "x": 877.0464, + "y": -661.8731520000001 + }, + { + "passmarkClockwiseOpening": false, + "turnPoint": true, + "type": "VSAPoint", + "x": 877.0464, + "y": -661.8731520000001 + }, + { + "passmarkClockwiseOpening": false, + "turnPoint": true, + "type": "VSAPoint", + "x": 108.41272244286347, + "y": -661.8731520000001 + }, + { + "passmarkClockwiseOpening": false, + "turnPoint": true, + "type": "VSAPoint", + "x": 108.41272244286347, + "y": -949.8731520000001 + }, + { + "passmarkClockwiseOpening": false, + "turnPoint": true, + "type": "VSAPoint", + "x": 1189.0464, + "y": -949.8731520000001 + }, + { + "passmarkClockwiseOpening": false, + "turnPoint": true, + "type": "VSAPoint", + "x": 2269.6800775571364, + "y": -949.873152 + } + ] +} diff --git a/src/test/ValentinaTest/share/25L_Knitting_Bag/output.json b/src/test/ValentinaTest/share/25L_Knitting_Bag/output.json new file mode 100644 index 000000000..2976476e7 --- /dev/null +++ b/src/test/ValentinaTest/share/25L_Knitting_Bag/output.json @@ -0,0 +1,144 @@ +{ + "vector": [ + { + "type": "QPointF", + "x": 2305.6800775571364, + "y": -625.873152 + }, + { + "type": "QPointF", + "x": 1633.1958258789232, + "y": -625.873152 + }, + { + "type": "QPointF", + "x": 1649.795721788633, + "y": -606.8224923501662 + }, + { + "type": "QPointF", + "x": 1674.7193149323566, + "y": -566.6017363452385 + }, + { + "type": "QPointF", + "x": 1694.087408271691, + "y": -521.8620042025294 + }, + { + "type": "QPointF", + "x": 1708.6267314176046, + "y": -473.6007154015538 + }, + { + "type": "QPointF", + "x": 1719.1312661189374, + "y": -422.3814839376958 + }, + { + "type": "QPointF", + "x": 1726.2889633615728, + "y": -368.7053116792325 + }, + { + "type": "QPointF", + "x": 1730.7160060188758, + "y": -312.9691304182097 + }, + { + "type": "QPointF", + "x": 1733.5906452137085, + "y": -227.14213989317568 + }, + { + "type": "QPointF", + "x": 1730.9944185791073, + "y": -52.68635212068391 + }, + { + "type": "QPointF", + "x": 1728.4208324505355, + "y": 94.126848 + }, + { + "type": "QPointF", + "x": 648.7981270798671, + "y": 94.12684799999985 + }, + { + "type": "QPointF", + "x": 649.2386325321073, + "y": 30.03330469904454 + }, + { + "type": "QPointF", + "x": 651.4662346184206, + "y": -28.171782072366085 + }, + { + "type": "QPointF", + "x": 658.4112351329172, + "y": -118.8147784780652 + }, + { + "type": "QPointF", + "x": 674.4092423831233, + "y": -242.22797726536976 + }, + { + "type": "QPointF", + "x": 696.7096815639468, + "y": -362.30726516211126 + }, + { + "type": "QPointF", + "x": 717.0990262409201, + "y": -445.8748609508329 + }, + { + "type": "QPointF", + "x": 732.0947750184293, + "y": -497.5993277486183 + }, + { + "type": "QPointF", + "x": 748.1588560513961, + "y": -544.9153482457203 + }, + { + "type": "QPointF", + "x": 765.3232534020617, + "y": -587.2690559941162 + }, + { + "type": "QPointF", + "x": 783.7592926518024, + "y": -624.1411344935976 + }, + { + "type": "QPointF", + "x": 784.8910607049277, + "y": -625.8731520000001 + }, + { + "type": "QPointF", + "x": 72.41272244286347, + "y": -625.8731520000001 + }, + { + "type": "QPointF", + "x": 72.41272244286347, + "y": -985.8731520000001 + }, + { + "type": "QPointF", + "x": 2305.6800775571364, + "y": -985.873152 + }, + { + "type": "QPointF", + "x": 2305.6800775571364, + "y": -625.873152 + } + ] +} diff --git a/src/test/ValentinaTest/share/test_data.qrc b/src/test/ValentinaTest/share/test_data.qrc index 2dbfce189..461b2707a 100644 --- a/src/test/ValentinaTest/share/test_data.qrc +++ b/src/test/ValentinaTest/share/test_data.qrc @@ -180,5 +180,7 @@ full_path_case_3/input.json full_path_case_4/output.json full_path_case_4/input.json + 25L_Knitting_Bag/input.json + 25L_Knitting_Bag/output.json diff --git a/src/test/ValentinaTest/tst_vabstractpiece.cpp b/src/test/ValentinaTest/tst_vabstractpiece.cpp index 8f938a845..eea5b97bf 100644 --- a/src/test/ValentinaTest/tst_vabstractpiece.cpp +++ b/src/test/ValentinaTest/tst_vabstractpiece.cpp @@ -948,6 +948,10 @@ void TST_VAbstractPiece::BrokenDetailEquidistant_data() ASSERT_TEST_CASE("Piece 2. CSA Exclude", QStringLiteral("://custom_seam_allwance_exclude_p2/input.json"), QStringLiteral("://custom_seam_allwance_exclude_p2/output.json"), 37.795275590551185 /*seam allowance width 1 cm*/); + + // See the file "valentina_private_collection/bugs/25L Knitting Bag.val" + ASSERT_TEST_CASE("Base", QStringLiteral("://25L_Knitting_Bag/input.json"), + QStringLiteral("://25L_Knitting_Bag/output.json"), 36 /*seam allowance width*/); } //---------------------------------------------------------------------------------------------------------------------