Do not remove a loop created by intersection point when it is the first or

the last point of lines that intersect.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-01-10 21:41:46 +02:00
parent f240a3d599
commit ac5c8d8201
2 changed files with 32 additions and 1 deletions

View File

@ -338,8 +338,12 @@ QVector<QPointF> VAbstractDetail::CheckLoops(const QVector<QPointF> &points)
intersect = line1.intersect(line2, &crosPoint);
if (intersect == QLineF::BoundedIntersection && not (i == 0 && j+1 == count-1 && closed))
{ // Break, but not if intersects the first edge and the last edge in closed path
if (line1.p1() != crosPoint && line1.p2() != crosPoint &&
line2.p1() != crosPoint && line2.p2() != crosPoint)
{
break;
}
}
intersect = QLineF::NoIntersection;
}

View File

@ -172,6 +172,33 @@ void TST_VAbstractDetail::PathRemoveLoop_data() const
path.removeLast();
res.removeLast();
QTest::newRow("One loop, the second loop, unclosed a path (six unique points)") << path << res;
path.clear();
path << QPointF(20, 10);
path << QPointF(10, 10);
path << QPointF(20, 15);
path << QPointF(10, 20);
path << QPointF(20, 20);
path << QPointF(20, 10);
QTest::newRow("Correct closed a path, point on line (four unique points)") << path << path;
path.removeLast();
QTest::newRow("Corect unclosed a path, point on line (four unique points)") << path << path;
path.clear();
path << QPointF(20, 10);
path << QPointF(10, 10);
path << QPointF(0, 10);
path << QPointF(10, 15);
path << QPointF(0, 20);
path << QPointF(10, 20);
path << QPointF(20, 20);
path << QPointF(10, 15);
path << QPointF(20, 10);
QTest::newRow("Correct closed a path, point on line (six unique points)") << path << path;
path.removeLast();
QTest::newRow("Corect unclosed a path, point on line (six unique points)") << path << path;
}
//---------------------------------------------------------------------------------------------------------------------