diff --git a/ChangeLog.txt b/ChangeLog.txt
index 27066b045..c5a5ab06c 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -62,6 +62,7 @@
- Remove space as thousands separator when return formula to user.
- [#752] Valentina produces corrupted file if unite two pieces.
- [#753] Elliptical arc tool is broken.
+- [#767] Valentina produces wrong main path.
# Version 0.5.0 May 9, 2017
- [#581] User can now filter input lists by keyword in function wizard.
diff --git a/src/app/share/collection/bugs/Issue_#767.val b/src/app/share/collection/bugs/Issue_#767.val
new file mode 100644
index 000000000..6a1d60548
--- /dev/null
+++ b/src/app/share/collection/bugs/Issue_#767.val
@@ -0,0 +1,597 @@
+
+
+
+ 0.6.5
+ cm
+
+
+ Issue_#767.vit
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/share/collection/bugs/Issue_#767.vit b/src/app/share/collection/bugs/Issue_#767.vit
new file mode 100644
index 000000000..4f61e9b40
--- /dev/null
+++ b/src/app/share/collection/bugs/Issue_#767.vit
@@ -0,0 +1,29 @@
+
+
+
+ 0.3.3
+ false
+
+ cm
+ 998
+
+ CKCPatterns
+ CKC Girls 2T
+ 1800-01-01
+ female
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/libs/vgeometry/vgobject.cpp b/src/libs/vgeometry/vgobject.cpp
index 1b85be5d1..cb0e676b4 100644
--- a/src/libs/vgeometry/vgobject.cpp
+++ b/src/libs/vgeometry/vgobject.cpp
@@ -457,19 +457,31 @@ bool VGObject::IsPointOnLineSegment(const QPointF &t, const QPointF &p1, const Q
// The test point must lie inside the bounding box spanned by the two line points.
if (not ( (p1.x() <= t.x() && t.x() <= p2.x()) || (p2.x() <= t.x() && t.x() <= p1.x()) ))
{
- if (not (qAbs(p1.x() - t.x()) <= accuracyPointOnLine) && not (qAbs(p2.x() - t.x()) <= accuracyPointOnLine))
+ if (VFuzzyComparePossibleNulls(p1.x(), p2.x()))
+ {// vertical line
+ if (not (qAbs(p1.x() - t.x()) <= accuracyPointOnLine))
+ {
+ return false;// test point not in x-range
+ }
+ }
+ else
{
- // test point not in x-range
- return false;
+ return false;// test point not in x-range
}
}
if (not ( (p1.y() <= t.y() && t.y() <= p2.y()) || (p2.y() <= t.y() && t.y() <= p1.y()) ))
{
- if (not (qAbs(p1.y() - t.y()) <= accuracyPointOnLine) && not (qAbs(p2.y() - t.y()) <= accuracyPointOnLine))
+ if (VFuzzyComparePossibleNulls(p1.y(), p2.y()))
+ {// horizontal line
+ if (not (qAbs(p1.y() - t.y()) <= accuracyPointOnLine))
+ {
+ return false;// test point not in y-range
+ }
+ }
+ else
{
- // test point not in y-range
- return false;
+ return false;// test point not in y-range
}
}
diff --git a/src/test/ValentinaTest/tst_vspline.cpp b/src/test/ValentinaTest/tst_vspline.cpp
index 54c2b016f..3937bf140 100644
--- a/src/test/ValentinaTest/tst_vspline.cpp
+++ b/src/test/ValentinaTest/tst_vspline.cpp
@@ -317,6 +317,65 @@ void TST_VSpline::GetSegmentPoints_RotateTool()
Comparison(points, origPoints);
}
+//---------------------------------------------------------------------------------------------------------------------
+void TST_VSpline::GetSegmentPoints_issue767()
+{
+ // Input data taken from real case
+ // See the file /src/app/share/collection/bugs/Issue_#767.val
+ // Test issue with method IsPointOnLineSegment.
+
+ const QPointF begin(3964.650771379471, 3212.2173150777817);
+ const QPointF end (4200.023629188538, 2559.9039118110236);
+
+ QVector points;
+ points.append(QPointF(3964.650771379471, 3212.2173150777817));
+ points.append(QPointF(4009.6319008613655, 3103.623262231279));
+ points.append(QPointF(4064.8193464067945, 2969.0243880817015));
+ points.append(QPointF(4095.804988589596, 2891.7621601338465));
+ points.append(QPointF(4122.206955892843, 2823.6554697520774));
+ points.append(QPointF(4139.097797821786, 2777.9307145219336));
+ points.append(QPointF(4149.204800929745, 2749.4023517620412));
+ points.append(QPointF(4158.372150687417, 2722.3578709475264));
+ points.append(QPointF(4166.645683843604, 2696.6183826459132));
+ points.append(QPointF(4174.071237147104, 2672.004997424725));
+ points.append(QPointF(4180.694647346716, 2648.338825851485));
+ points.append(QPointF(4186.561751191242, 2625.440978493719));
+ points.append(QPointF(4191.718385429485, 2603.132565918948));
+ points.append(QPointF(4196.210386810242, 2581.2346986946964));
+ points.append(QPointF(4200.083592082314, 2559.5684873884893));
+ points.append(QPointF(4203.383837994501, 2537.955042567848));
+ points.append(QPointF(4206.156961295605, 2516.2154748002986));
+ points.append(QPointF(4208.448798734424, 2494.170894653362));
+ points.append(QPointF(4210.305187059759, 2471.642412694565));
+ points.append(QPointF(4212.4136775031675, 2436.667443899716));
+ points.append(QPointF(4214.063800458542, 2386.5603959212317));
+ points.append(QPointF(4214.797188438389, 2331.297730910725));
+ points.append(QPointF(4214.980535433111, 2269.448333408385));
+ points.append(QPointF(4214.980535433071, 2235.242494488189));
+
+ const QVector res = VAbstractCurve::GetSegmentPoints(points, begin, end, false);
+
+ QVector origPoints;
+ origPoints.append(QPointF(3964.650771379471, 3212.2173150777817));
+ origPoints.append(QPointF(4009.6319008613655, 3103.623262231279));
+ origPoints.append(QPointF(4064.8193464067945, 2969.0243880817015));
+ origPoints.append(QPointF(4095.804988589596, 2891.7621601338465));
+ origPoints.append(QPointF(4122.206955892843, 2823.6554697520774));
+ origPoints.append(QPointF(4139.097797821786, 2777.9307145219336));
+ origPoints.append(QPointF(4149.204800929745, 2749.4023517620412));
+ origPoints.append(QPointF(4158.372150687417, 2722.3578709475264));
+ origPoints.append(QPointF(4166.645683843604, 2696.6183826459132));
+ origPoints.append(QPointF(4174.071237147104, 2672.004997424725));
+ origPoints.append(QPointF(4180.694647346716, 2648.338825851485));
+ origPoints.append(QPointF(4186.561751191242, 2625.440978493719));
+ origPoints.append(QPointF(4191.718385429485, 2603.132565918948));
+ origPoints.append(QPointF(4196.210386810242, 2581.2346986946964));
+ origPoints.append(QPointF(4200.023629188538, 2559.9039118110236));
+
+ // Begin comparison
+ Comparison(res, origPoints);
+}
+
//---------------------------------------------------------------------------------------------------------------------
void TST_VSpline::CompareThreeWays()
{
diff --git a/src/test/ValentinaTest/tst_vspline.h b/src/test/ValentinaTest/tst_vspline.h
index 6542e94b3..8858114cc 100644
--- a/src/test/ValentinaTest/tst_vspline.h
+++ b/src/test/ValentinaTest/tst_vspline.h
@@ -47,6 +47,7 @@ private slots:
void GetSegmentPoints_TestPuzzle();
void GetSegmentPoints_NullSegment();
void GetSegmentPoints_RotateTool();
+ void GetSegmentPoints_issue767();
void CompareThreeWays();
void TestParametrT();
void TestLengthByPoint_data();