From e56d3440d22123fb7e6a3ae168ea130986f9ddb9 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 20 Mar 2017 08:16:35 +0200 Subject: [PATCH] Fixed issue #642. Detail's main path is cutted. --HG-- branch : develop --- src/app/share/collection/bugs/Issue_#642.val | 429 ++++++++++++++++++ src/libs/vlayout/vabstractpiece.h | 25 +- src/test/ValentinaTest/tst_vabstractpiece.cpp | 137 ++++++ 3 files changed, 578 insertions(+), 13 deletions(-) create mode 100644 src/app/share/collection/bugs/Issue_#642.val diff --git a/src/app/share/collection/bugs/Issue_#642.val b/src/app/share/collection/bugs/Issue_#642.val new file mode 100644 index 000000000..4b950f930 --- /dev/null +++ b/src/app/share/collection/bugs/Issue_#642.val @@ -0,0 +1,429 @@ + + + + 0.4.4 + cm + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+
diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h index 6d7345a17..4fa1e78b5 100644 --- a/src/libs/vlayout/vabstractpiece.h +++ b/src/libs/vlayout/vabstractpiece.h @@ -227,18 +227,20 @@ QVector VAbstractPiece::CorrectEquidistantPoints(const QVector &points, bo return buf1; } + int prev = -1; + QVector buf2; //Remove point on line for (qint32 i = 0; i < buf1.size(); ++i) {// In this case we alwayse will have bounded intersection, so all is need is to check if point i is on line. // Unfortunatelly QLineF::intersect can't be used in this case because of the floating-point accuraccy problem. - int prev = i-1; - int next = i+1; - if (i == 0) + if (prev == -1) { - prev = buf1.size() - 1; + i == 0 ? prev = buf1.size() - 1 : prev = i-1; } - else if (i == buf1.size() - 1) + + int next = i+1; + if (i == buf1.size() - 1) { next = 0; } @@ -247,16 +249,13 @@ QVector VAbstractPiece::CorrectEquidistantPoints(const QVector &points, bo const QPointF &prevPoint = buf1.at(prev); const QPointF &nextPoint = buf1.at(next); - if (not VGObject::IsPointOnLineviaPDP(buf1.at(i), buf1.at(prev), buf1.at(next)) - && prevPoint != nextPoint) // not zigzag + if ((not VGObject::IsPointOnLineviaPDP(iPoint, prevPoint, nextPoint) && prevPoint != nextPoint)// not zigzag + // If RemoveDublicates does not remove these points it is a valid case. + // Case where last point equal first point + || ((i == 0 || i == buf1.size() - 1) && (iPoint == prevPoint || iPoint == nextPoint))) { buf2.append(buf1.at(i)); - } - else if ((i == 0 || i == buf1.size() - 1) && (iPoint == prevPoint || iPoint == nextPoint)) - { - // If RemoveDublicates does not remove these points it is a valid case. - // Case where last point equal first point - buf2.append(buf1.at(i)); + prev = -1; } } diff --git a/src/test/ValentinaTest/tst_vabstractpiece.cpp b/src/test/ValentinaTest/tst_vabstractpiece.cpp index 061a3118c..5af96445b 100644 --- a/src/test/ValentinaTest/tst_vabstractpiece.cpp +++ b/src/test/ValentinaTest/tst_vabstractpiece.cpp @@ -588,6 +588,11 @@ QVector TST_VAbstractPiece::OutputPointsCase1() const points += QPointF(1001.5753826870504, 572.6532694631434); points += QPointF(1001.7511114738644, 580.6472328726268); points += QPointF(1002.5244573746393, 592.6631414076071); + points += QPointF(1003.5253444923072, 601.4269775229475); + points += QPointF(1004.8346806929111, 607.4219012430418); + points += QPointF(1007.3734895026099, 615.879537116226); + points += QPointF(1011.1831553003773, 625.860901250618); + points += QPointF(1016.1978697144372, 636.6181674061058); points += QPointF(1022.283791807397, 647.5382096308747); points += QPointF(1025.6730034935645, 652.8974380139866); points += QPointF(1029.258679857382, 658.1156604426072); @@ -1767,6 +1772,8 @@ QVector TST_VAbstractPiece::OutputPointsCase3() const points += QPointF(298.43819035278193, 155.84335424804448); points += QPointF(298.1940021729857, 152.25436961670644); points += QPointF(297.7243212024687, 149.73346552056378); + points += QPointF(296.30769954702157, 146.83360641173047); + points += QPointF(293.59863859999393, 145.93124637657365); points += QPointF(289.51401190033005, 145.54903057599236); points += QPointF(285.1770288005626, 145.6959639947203); points += QPointF(278.3617236899766, 146.6950293230864); @@ -2703,6 +2710,136 @@ void TST_VAbstractPiece::TestCorrectEquidistantPoints_data() expect << QPointF(30.0, 3819.527433070866); QTest::newRow("Test case issue #548") << before << expect; + + before.clear(); + before << QPointF(2555.0992166373157, 1774.4207500831487); + before << QPointF(2533.267784793755, 1653.2290736835712); + before << QPointF(2506.535007601057, 1502.652017289041); + before << QPointF(2491.542377709352, 1415.6778721390556); + before << QPointF(2478.773102822018, 1338.265755656977); + before << QPointF(2468.038937020391, 1268.6117806424259); + before << QPointF(2459.151634385811, 1204.9120598950217); + before << QPointF(2451.9229489996146, 1145.3627062143837); + before << QPointF(2446.16463494314, 1088.1598324001313); + before << QPointF(2441.688446297725, 1031.4995512518844); + before << QPointF(2438.3061371447066, 973.5779755692625); + before << QPointF(2435.829461565424, 912.5912181518852); + before << QPointF(2434.0701736412148, 846.7353917993719); + before << QPointF(2432.8400274534156, 774.2066093113424); + before << QPointF(2431.567845112944, 650.353473841431); + before << QPointF(2430.8388882820395, 551.3113535235192); + before << QPointF(2430.8388882820395, 551.3113535235192); + before << QPointF(2521.6176598985803, 672.644700521423); + before << QPointF(2521.6176454460388, 672.6446812044021); + before << QPointF(2524.825194988043, 676.8586168908913); + before << QPointF(2531.556290527688, 684.9826746886265); + before << QPointF(2538.6519462028364, 692.7334672321138); + before << QPointF(2546.0959002232003, 700.1013401169566); + before << QPointF(2553.8718907984908, 707.0766389387593); + before << QPointF(2561.9636561384195, 713.6497092931257); + before << QPointF(2570.354934452699, 719.8108967756598); + before << QPointF(2579.0294639510394, 725.5505469819657); + before << QPointF(2587.9709828431537, 730.8590055076468); + before << QPointF(2597.1632293387524, 735.7266179483076); + before << QPointF(2606.5899416475477, 740.1437298995519); + before << QPointF(2616.2348579792506, 744.1006869569835); + before << QPointF(2626.0817165435737, 747.5878347162065); + before << QPointF(2636.1142555502283, 750.5955187728248); + before << QPointF(2646.3162132089255, 753.1140847224424); + before << QPointF(2656.6713277293766, 755.1338781606632); + before << QPointF(2661.9066021773087, 755.9323325983765); + before << QPointF(2669.4674223109823, 756.929551265488); + before << QPointF(2684.673455582832, 758.0191371470853); + before << QPointF(2692.299212598425, 758.1101102362205); + before << QPointF(2692.299212598425, 758.1101102362205); + before << QPointF(2692.299212598425, 758.1101102362205); + before << QPointF(2699.3540234509323, 757.9931392559722); + before << QPointF(2713.2964524768695, 756.6087867033591); + before << QPointF(2726.9543839401804, 753.8786800188636); + before << QPointF(2740.2346330100504, 749.8414176232166); + before << QPointF(2753.0440148556645, 744.5355979371486); + before << QPointF(2765.2893446462085, 737.9998193813908); + before << QPointF(2776.8774375508674, 730.2726803766734); + before << QPointF(2787.7151087388274, 721.3927793437279); + before << QPointF(2792.78632430596, 716.4869857232671); + before << QPointF(2795.193441837398, 714.0407970608542); + before << QPointF(2797.5205646867075, 711.5183868986292); + before << QPointF(2797.55905511811, 711.5533198040212); + before << QPointF(2797.55905511811, 711.5533198040212); + before << QPointF(2797.5653033070657, 778.3129219994751); + before << QPointF(2798.042165185835, 888.6599947271147); + before << QPointF(2799.2551263764, 959.1215703859448); + before << QPointF(2800.6047354960533, 1003.4500031833654); + before << QPointF(2802.525679148114, 1047.064797090694); + before << QPointF(2805.1184282354075, 1091.416649923951); + before << QPointF(2808.4834536607586, 1137.9562594991576); + before << QPointF(2812.7212263269944, 1188.1343236323337); + before << QPointF(2817.932217136939, 1243.4015401395004); + before << QPointF(2824.216896993419, 1305.208606836678); + before << QPointF(2835.7112555523727, 1412.0840031200023); + before << QPointF(2855.928400378448, 1592.3456114466708); + before << QPointF(2868.5464960059594, 1703.7728336081707); + + expect.clear(); + expect << QPointF(2555.0992166373157, 1774.4207500831487); + expect << QPointF(2533.267784793755, 1653.2290736835712); + expect << QPointF(2506.535007601057, 1502.652017289041); + expect << QPointF(2491.542377709352, 1415.6778721390556); + expect << QPointF(2478.773102822018, 1338.265755656977); + expect << QPointF(2468.038937020391, 1268.6117806424259); + expect << QPointF(2459.151634385811, 1204.9120598950217); + expect << QPointF(2451.9229489996146, 1145.3627062143837); + expect << QPointF(2446.16463494314, 1088.1598324001313); + expect << QPointF(2441.688446297725, 1031.4995512518844); + expect << QPointF(2438.3061371447066, 973.5779755692625); + expect << QPointF(2435.829461565424, 912.5912181518852); + expect << QPointF(2434.0701736412148, 846.7353917993719); + expect << QPointF(2432.8400274534156, 774.2066093113424); + expect << QPointF(2431.567845112944, 650.353473841431); + expect << QPointF(2430.8388882820395, 551.3113535235192); + expect << QPointF(2524.825194988043, 676.8586168908913); + expect << QPointF(2531.556290527688, 684.9826746886265); + expect << QPointF(2538.6519462028364, 692.7334672321138); + expect << QPointF(2546.0959002232003, 700.1013401169566); + expect << QPointF(2553.8718907984908, 707.0766389387593); + expect << QPointF(2561.9636561384195, 713.6497092931257); + expect << QPointF(2570.354934452699, 719.8108967756598); + expect << QPointF(2579.0294639510394, 725.5505469819657); + expect << QPointF(2587.9709828431537, 730.8590055076468); + expect << QPointF(2597.1632293387524, 735.7266179483076); + expect << QPointF(2606.5899416475477, 740.1437298995519); + expect << QPointF(2616.2348579792506, 744.1006869569835); + expect << QPointF(2626.0817165435737, 747.5878347162065); + expect << QPointF(2636.1142555502283, 750.5955187728248); + expect << QPointF(2646.3162132089255, 753.1140847224424); + expect << QPointF(2656.6713277293766, 755.1338781606632); + expect << QPointF(2669.4674223109823, 756.929551265488); + expect << QPointF(2684.673455582832, 758.0191371470853); + expect << QPointF(2699.3540234509323, 757.9931392559722); + expect << QPointF(2713.2964524768695, 756.6087867033591); + expect << QPointF(2726.9543839401804, 753.8786800188636); + expect << QPointF(2740.2346330100504, 749.8414176232166); + expect << QPointF(2753.0440148556645, 744.5355979371486); + expect << QPointF(2765.2893446462085, 737.9998193813908); + expect << QPointF(2776.8774375508674, 730.2726803766734); + expect << QPointF(2787.7151087388274, 721.3927793437279); + expect << QPointF(2795.193441837398, 714.0407970608542); + expect << QPointF(2797.55905511811, 711.5533198040212); + expect << QPointF(2797.5653033070657, 778.3129219994751); + expect << QPointF(2798.042165185835, 888.6599947271147); + expect << QPointF(2799.2551263764, 959.1215703859448); + expect << QPointF(2800.6047354960533, 1003.4500031833654); + expect << QPointF(2802.525679148114, 1047.064797090694); + expect << QPointF(2805.1184282354075, 1091.416649923951); + expect << QPointF(2808.4834536607586, 1137.9562594991576); + expect << QPointF(2812.7212263269944, 1188.1343236323337); + expect << QPointF(2817.932217136939, 1243.4015401395004); + expect << QPointF(2824.216896993419, 1305.208606836678); + expect << QPointF(2835.7112555523727, 1412.0840031200023); + expect << QPointF(2868.5464960059594, 1703.7728336081707); + + // See the file "collection/bugs/Issue_#642.val" + QTest::newRow("Test case issue #642") << before << expect; } //---------------------------------------------------------------------------------------------------------------------