diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index 9da59fdab..e051eefef 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -139,14 +139,30 @@ QVector AngleByLength(QVector points, QPointF p1, QPoi if (angle > 180 && p.GetAngleType() != PieceNodeAngle::ByLengthCurve) { - QLineF loop(sp2, bigLine1.p1()); - loop.setLength(accuracyPointOnLine*2.); - points.append(loop.p2()); - points.append(sp2); + if (VGObject::IsPointOnLineSegment(sp2, bigLine2.p1(), bigLine2.p2())) + { + QLineF loop(bigLine1.p2(), sp2); + loop.setLength(loop.length() + accuracyPointOnLine*2.); + points.append(loop.p2()); + points.append(sp2); + points.append(VRawSAPoint(bigLine1.p2(), true)); - loop = QLineF(bigLine1.p1(), sp2); - loop.setLength(loop.length() + localWidth); - points.append(VRawSAPoint(loop.p2(), true)); + loop = QLineF(bigLine2.p2(), sp2); + loop.setLength(loop.length() + localWidth); + points.append(VRawSAPoint(loop.p2(), true)); + } + else + { + QLineF loop(sp2, bigLine1.p1()); + loop.setLength(accuracyPointOnLine*2.); + points.append(loop.p2()); + points.append(sp2); + + loop = QLineF(bigLine1.p1(), sp2); + loop.setLength(loop.length() + localWidth); + points.append(VRawSAPoint(loop.p2(), true)); + points.append(VRawSAPoint(bigLine2.p1(), true)); + } } else { diff --git a/src/test/ValentinaTest/share/smart_pattern_#58/input.json b/src/test/ValentinaTest/share/smart_pattern_#58/input.json new file mode 100644 index 000000000..d203778fe --- /dev/null +++ b/src/test/ValentinaTest/share/smart_pattern_#58/input.json @@ -0,0 +1,379 @@ +{ + "vector": [ + { + "type": "VSAPoint", + "x": 231.4373260132128, + "y": 1778.5814173228348 + }, + { + "type": "VSAPoint", + "x": 278.28811792486107, + "y": 1510.10068637634 + }, + { + "type": "VSAPoint", + "x": 294.44144427545694, + "y": 1507.6495640035857 + }, + { + "type": "VSAPoint", + "x": 314.1269659888851, + "y": 1503.5492125764567 + }, + { + "type": "VSAPoint", + "x": 333.00728556677325, + "y": 1498.482931460618 + }, + { + "type": "VSAPoint", + "x": 351.09867959627206, + "y": 1492.4722175314846 + }, + { + "type": "VSAPoint", + "x": 368.4186960667595, + "y": 1485.5367395533972 + }, + { + "type": "VSAPoint", + "x": 384.9856837378738, + "y": 1477.6940146223433 + }, + { + "type": "VSAPoint", + "x": 400.8181941459449, + "y": 1468.9592367784041 + }, + { + "type": "VSAPoint", + "x": 415.93431749889527, + "y": 1459.3453001893827 + }, + { + "type": "VSAPoint", + "x": 430.35103211455817, + "y": 1448.863030046361 + }, + { + "type": "VSAPoint", + "x": 444.0836493187042, + "y": 1437.521599021348 + }, + { + "type": "VSAPoint", + "x": 457.14542004046064, + "y": 1425.329075271635 + }, + { + "type": "VSAPoint", + "x": 469.54733984197816, + "y": 1412.2930283139299 + }, + { + "type": "VSAPoint", + "x": 481.41282344527315, + "y": 1398.2857485794134 + }, + { + "type": "VSAPoint", + "x": 492.5547151481526, + "y": 1383.8143086488699 + }, + { + "type": "VSAPoint", + "x": 502.7806762003831, + "y": 1368.354315381568 + }, + { + "type": "VSAPoint", + "x": 512.7021925961178, + "y": 1351.8778241538607 + }, + { + "type": "VSAPoint", + "x": 521.8994317308129, + "y": 1334.755806229509 + }, + { + "type": "VSAPoint", + "x": 530.4649110715529, + "y": 1316.8507353993848 + }, + { + "type": "VSAPoint", + "x": 538.4000910521302, + "y": 1298.1769788688134 + }, + { + "type": "VSAPoint", + "x": 545.7063359288908, + "y": 1278.750029508588 + }, + { + "type": "VSAPoint", + "x": 552.3851047281271, + "y": 1258.5863487419938 + }, + { + "type": "VSAPoint", + "x": 561.6218539603159, + "y": 1226.71900974186 + }, + { + "type": "VSAPoint", + "x": 1065.6617011589467, + "y": 1408.7816864056442 + }, + { + "type": "VSAPoint", + "x": 1053.7610921605533, + "y": 1462.9515486776288 + }, + { + "type": "VSAPoint", + "x": 1045.6861606944276, + "y": 1507.180805329162 + }, + { + "type": "VSAPoint", + "x": 1039.4920283827717, + "y": 1549.9923080635576 + }, + { + "type": "VSAPoint", + "x": 1035.1030651939789, + "y": 1591.4005848362904 + }, + { + "type": "VSAPoint", + "x": 1032.443659558613, + "y": 1631.4206168216922 + }, + { + "type": "VSAPoint", + "x": 1031.4382897156343, + "y": 1670.0678577282356 + }, + { + "type": "VSAPoint", + "x": 1032.011602691146, + "y": 1707.358237104317 + }, + { + "type": "VSAPoint", + "x": 1034.0884973970792, + "y": 1743.3081444872419 + }, + { + "type": "VSAPoint", + "x": 1037.5942072449768, + "y": 1777.934392204008 + }, + { + "type": "VSAPoint", + "x": 1042.4543768508215, + "y": 1811.2541560476245 + }, + { + "type": "VSAPoint", + "x": 1048.5951270419177, + "y": 1843.2848948211301 + }, + { + "type": "VSAPoint", + "x": 1055.9431026079276, + "y": 1874.0442516822304 + }, + { + "type": "VSAPoint", + "x": 1064.4254981299555, + "y": 1903.5499420898432 + }, + { + "type": "VSAPoint", + "x": 1073.9700587286613, + "y": 1931.819634663438 + }, + { + "type": "VSAPoint", + "x": 1084.5050545378274, + "y": 1958.8708321833387 + }, + { + "type": "VSAPoint", + "x": 1095.9592298734308, + "y": 1984.720760099687 + }, + { + "type": "VSAPoint", + "x": 1108.2617301296443, + "y": 2009.3862692585317 + }, + { + "type": "VSAPoint", + "x": 1121.342011098845, + "y": 2032.8837581844984 + }, + { + "type": "VSAPoint", + "x": 1135.1297364563522, + "y": 2055.2291183870766 + }, + { + "type": "VSAPoint", + "x": 1149.5546694683946, + "y": 2076.4377040809786 + }, + { + "type": "VSAPoint", + "x": 1164.5465645811753, + "y": 2096.524325711441 + }, + { + "type": "VSAPoint", + "x": 1180.0350635466189, + "y": 2115.503265001873 + }, + { + "type": "VSAPoint", + "x": 1195.9495993249827, + "y": 2133.388308066852 + }, + { + "type": "VSAPoint", + "x": 1212.2193093724165, + "y": 2150.192792517222 + }, + { + "type": "VSAPoint", + "x": 1228.7729582473444, + "y": 2165.929664410282 + }, + { + "type": "VSAPoint", + "x": 1245.5388678808974, + "y": 2180.6115413000603 + }, + { + "type": "VSAPoint", + "x": 1262.444852398235, + "y": 2194.2507784151867 + }, + { + "type": "VSAPoint", + "x": 1279.467872304478, + "y": 2206.8964704281216 + }, + { + "type": "VSAPoint", + "x": 1297.7306927357072, + "y": 2219.5481177526704 + }, + { + "type": "VSAPoint", + "x": 1290.6688688058985, + "y": 2265.114491714009 + }, + { + "type": "VSAPoint", + "x": 1279.8411584230082, + "y": 2348.340860262282 + }, + { + "type": "VSAPoint", + "x": 1269.2007054480705, + "y": 2445.1062634514115 + }, + { + "type": "VSAPoint", + "x": 1259.2924779368475, + "y": 2550.4989183874577 + }, + { + "type": "VSAPoint", + "x": 1250.6990229464336, + "y": 2659.330065143677 + }, + { + "type": "VSAPoint", + "x": 1243.997919031011, + "y": 2766.4281622163053 + }, + { + "type": "VSAPoint", + "x": 1239.7744748167386, + "y": 2866.372200302109 + }, + { + "type": "VSAPoint", + "x": 1238.662527733217, + "y": 2933.4891450708683 + }, + { + "type": "VSAPoint", + "x": 1238.9261603693603, + "y": 2973.119458224285 + }, + { + "type": "VSAPoint", + "x": 1241.377182637957, + "y": 3040.6931546213623 + }, + { + "type": "VSAPoint", + "x": 1247.793904909571, + "y": 3148.2002648573434 + }, + { + "type": "VSAPoint", + "x": 1261.0603355784306, + "y": 3323.365351778843 + }, + { + "type": "VSAPoint", + "x": 1275.875018636029, + "y": 3507.686290864064 + }, + { + "type": "VSAPoint", + "x": 1284.7791722332051, + "y": 3630.0820495612816 + }, + { + "type": "VSAPoint", + "x": 1291.7477353338952, + "y": 3748.8886678968684 + }, + { + "type": "VSAPoint", + "x": 1294.9738206996367, + "y": 3833.719655751931 + }, + { + "type": "VSAPoint", + "x": 1296.0443480421582, + "y": 3887.8189099718516 + }, + { + "type": "VSAPoint", + "x": 1296.4710249835694, + "y": 4004.723149606299 + }, + { + "type": "VSAPoint", + "x": 218.40944881889754, + "y": 4004.723149606299 + }, + { + "type": "VSAPoint", + "x": 218.40944881889763, + "y": 1778.581417322835 + }, + { + "type": "VSAPoint", + "x": 231.4373260132128, + "y": 1778.5814173228348 + } + ] +} diff --git a/src/test/ValentinaTest/share/smart_pattern_#58/output.json b/src/test/ValentinaTest/share/smart_pattern_#58/output.json new file mode 100644 index 000000000..e645993f5 --- /dev/null +++ b/src/test/ValentinaTest/share/smart_pattern_#58/output.json @@ -0,0 +1,354 @@ +{ + "vector": [ + { + "type": "QPointF", + "x": 215.55181738075316, + "y": 1759.6837795275594 + }, + { + "type": "QPointF", + "x": 262.00930671586383, + "y": 1493.4568880344461 + }, + { + "type": "QPointF", + "x": 291.09462187476083, + "y": 1489.043452364464 + }, + { + "type": "QPointF", + "x": 309.7478344375091, + "y": 1485.1581234478303 + }, + { + "type": "QPointF", + "x": 327.5746219350357, + "y": 1480.3745435681462 + }, + { + "type": "QPointF", + "x": 344.60118002693173, + "y": 1474.717612448229 + }, + { + "type": "QPointF", + "x": 360.8562471772427, + "y": 1468.2085735887445 + }, + { + "type": "QPointF", + "x": 376.370163390527, + "y": 1460.8643671536574 + }, + { + "type": "QPointF", + "x": 391.17367422476445, + "y": 1452.6972871951 + }, + { + "type": "QPointF", + "x": 405.29660258104514, + "y": 1443.7150280206884 + }, + { + "type": "QPointF", + "x": 418.7665475803542, + "y": 1433.921145984555 + }, + { + "type": "QPointF", + "x": 431.60777435951525, + "y": 1423.315892402708 + }, + { + "type": "QPointF", + "x": 443.8404272620727, + "y": 1411.8973095617152 + }, + { + "type": "QPointF", + "x": 455.3283556076691, + "y": 1399.821987695691 + }, + { + "type": "QPointF", + "x": 477.16092721702586, + "y": 1372.7974497744376 + }, + { + "type": "QPointF", + "x": 496.36686661014573, + "y": 1342.3534308035958 + }, + { + "type": "QPointF", + "x": 505.0425994249497, + "y": 1326.2022738545943 + }, + { + "type": "QPointF", + "x": 513.1496326119415, + "y": 1309.2555277752656 + }, + { + "type": "QPointF", + "x": 527.9474906909386, + "y": 1272.2636557056294 + }, + { + "type": "QPointF", + "x": 534.3338078412216, + "y": 1252.9829073875771 + }, + { + "type": "QPointF", + "x": 549.0830173658185, + "y": 1202.097249664362 + }, + { + "type": "QPointF", + "x": 1087.677158556939, + "y": 1396.6411761528666 + }, + { + "type": "QPointF", + "x": 1072.2908988173997, + "y": 1466.6772197775535 + }, + { + "type": "QPointF", + "x": 1064.3391308814378, + "y": 1510.231866197585 + }, + { + "type": "QPointF", + "x": 1058.246462608034, + "y": 1552.3420878271359 + }, + { + "type": "QPointF", + "x": 1053.9345262946583, + "y": 1593.0236439510468 + }, + { + "type": "QPointF", + "x": 1051.3249911631221, + "y": 1632.2932002918737 + }, + { + "type": "QPointF", + "x": 1050.3397060520292, + "y": 1670.1683676404546 + }, + { + "type": "QPointF", + "x": 1050.900857374271, + "y": 1706.6677084675218 + }, + { + "type": "QPointF", + "x": 1052.9311353143887, + "y": 1741.8107052214336 + }, + { + "type": "QPointF", + "x": 1056.3538990561485, + "y": 1775.617685930125 + }, + { + "type": "QPointF", + "x": 1061.093330192228, + "y": 1808.109705553749 + }, + { + "type": "QPointF", + "x": 1067.074562737886, + "y": 1839.3083850719854 + }, + { + "type": "QPointF", + "x": 1074.2237786331425, + "y": 1869.2357141742327 + }, + { + "type": "QPointF", + "x": 1082.46825940089, + "y": 1897.9138271522188 + }, + { + "type": "QPointF", + "x": 1091.736387643132, + "y": 1925.364764618775 + }, + { + "type": "QPointF", + "x": 1101.9575959881163, + "y": 1951.6102355084413 + }, + { + "type": "QPointF", + "x": 1113.0622654284812, + "y": 1976.671394095393 + }, + { + "type": "QPointF", + "x": 1124.981579113256, + "y": 2000.5686454456195 + }, + { + "type": "QPointF", + "x": 1137.6473409879022, + "y": 2023.3214899823083 + }, + { + "type": "QPointF", + "x": 1150.9917707636712, + "y": 2044.9484140982 + }, + { + "type": "QPointF", + "x": 1164.9472873337718, + "y": 2065.4668295967367 + }, + { + "type": "QPointF", + "x": 1179.4462919512748, + "y": 2084.8930607422462 + }, + { + "type": "QPointF", + "x": 1194.4209604807113, + "y": 2103.2423743554377 + }, + { + "type": "QPointF", + "x": 1209.8030512032797, + "y": 2120.529046039356 + }, + { + "type": "QPointF", + "x": 1225.5237313919633, + "y": 2136.7664543895835 + }, + { + "type": "QPointF", + "x": 1241.5134225242932, + "y": 2151.967194894608 + }, + { + "type": "QPointF", + "x": 1257.5613187469414, + "y": 2166.020308732782 + }, + { + "type": "QPointF", + "x": 1290.643204117968, + "y": 2191.6489715000203 + }, + { + "type": "QPointF", + "x": 1318.2172909832254, + "y": 2210.751038654947 + }, + { + "type": "QPointF", + "x": 1309.3788545733341, + "y": 2267.7809933365734 + }, + { + "type": "QPointF", + "x": 1298.5808685960924, + "y": 2350.778887511974 + }, + { + "type": "QPointF", + "x": 1287.9851186563023, + "y": 2447.1718226163307 + }, + { + "type": "QPointF", + "x": 1278.107153288197, + "y": 2552.26773315016 + }, + { + "type": "QPointF", + "x": 1269.538022401012, + "y": 2660.8176180979776 + }, + { + "type": "QPointF", + "x": 1262.858673182873, + "y": 2767.6082753737733 + }, + { + "type": "QPointF", + "x": 1258.665502028198, + "y": 2866.9277448150037 + }, + { + "type": "QPointF", + "x": 1257.5575725911851, + "y": 2933.802185095188 + }, + { + "type": "QPointF", + "x": 1257.8215191610568, + "y": 2972.71401362399 + }, + { + "type": "QPointF", + "x": 1260.2624013822092, + "y": 3040.008152998583 + }, + { + "type": "QPointF", + "x": 1266.6579711735735, + "y": 3147.0743349177915 + }, + { + "type": "QPointF", + "x": 1294.7152632658247, + "y": 3506.214592345045 + }, + { + "type": "QPointF", + "x": 1303.627000733289, + "y": 3628.71089126524 + }, + { + "type": "QPointF", + "x": 1310.6129493305946, + "y": 3747.7821349782007 + }, + { + "type": "QPointF", + "x": 1313.8578079676856, + "y": 3833.0015059753864 + }, + { + "type": "QPointF", + "x": 1314.9382870193162, + "y": 3887.4450327608874 + }, + { + "type": "QPointF", + "x": 1315.4377612202204, + "y": 4023.6207874015745 + }, + { + "type": "QPointF", + "x": 199.5118110236217, + "y": 4023.6207874015745 + }, + { + "type": "QPointF", + "x": 199.51181102362204, + "y": 1759.6837795275596 + }, + { + "type": "QPointF", + "x": 215.55181738075316, + "y": 1759.6837795275594 + } + ] +} diff --git a/src/test/ValentinaTest/share/test_data.qrc b/src/test/ValentinaTest/share/test_data.qrc index 2a535842c..458a709b4 100644 --- a/src/test/ValentinaTest/share/test_data.qrc +++ b/src/test/ValentinaTest/share/test_data.qrc @@ -117,5 +117,7 @@ Issue_548_case1/output.json smart_pattern_#36/input.json smart_pattern_#36/output.json + smart_pattern_#58/input.json + smart_pattern_#58/output.json diff --git a/src/test/ValentinaTest/tst_vabstractpiece.cpp b/src/test/ValentinaTest/tst_vabstractpiece.cpp index 7dfa25177..af18a3795 100644 --- a/src/test/ValentinaTest/tst_vabstractpiece.cpp +++ b/src/test/ValentinaTest/tst_vabstractpiece.cpp @@ -319,6 +319,44 @@ void TST_VAbstractPiece::EquidistantRemoveLoop() const Comparison(ekv, ekvOrig); } +//--------------------------------------------------------------------------------------------------------------------- +void TST_VAbstractPiece::LayoutAllowanceRemoveLoop_data() +{ + QTest::addColumn>("points"); + QTest::addColumn("width"); + QTest::addColumn>("ekvOrig"); + + auto ASSERT_TEST_CASE = [this](const char *title, const QString &input, const QString &output, qreal width) + { + QVector inputPoints; + AbstractTest::VectorFromJson(input, inputPoints); + + QVector outputPoints; + AbstractTest::VectorFromJson(output, outputPoints); + + QTest::newRow(title) << inputPoints << width << outputPoints; + }; + + // See file src/app/share/collection/test/smart_pattern_#58.val (private collection) + ASSERT_TEST_CASE("Loop in layout allowance", + QStringLiteral("://smart_pattern_#58/input.json"), + QStringLiteral("://smart_pattern_#58/output.json"), + 18.897637795275593 /*seam allowance width (0.5 cm)*/); +} + +//--------------------------------------------------------------------------------------------------------------------- +void TST_VAbstractPiece::LayoutAllowanceRemoveLoop() const +{ + QFETCH(QVector, points); + QFETCH(qreal, width); + QFETCH(QVector, ekvOrig); + + const QVector ekv = VAbstractPiece::Equidistant(points, width, QString()); + + // Begin comparison + Comparison(ekv, ekvOrig); +} + //--------------------------------------------------------------------------------------------------------------------- void TST_VAbstractPiece::SumTrapezoids() const { diff --git a/src/test/ValentinaTest/tst_vabstractpiece.h b/src/test/ValentinaTest/tst_vabstractpiece.h index c1f08294b..157c068c2 100644 --- a/src/test/ValentinaTest/tst_vabstractpiece.h +++ b/src/test/ValentinaTest/tst_vabstractpiece.h @@ -42,6 +42,8 @@ public: private slots: void EquidistantRemoveLoop_data(); void EquidistantRemoveLoop() const; + void LayoutAllowanceRemoveLoop_data(); + void LayoutAllowanceRemoveLoop() const; void SumTrapezoids() const; void PathRemoveLoop_data() const; void PathRemoveLoop() const;