Port new test case. Zigzag in main path.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-12-10 20:09:03 +02:00
parent bd49df3d50
commit 93535d8f19

View File

@ -214,24 +214,49 @@ QVector<T> VAbstractPiece::CorrectEquidistantPoints(const QVector<T> &points, bo
}
//Clear equivalent points
QVector<T> correctPoints = RemoveDublicates(points, removeFirstAndLast);
QVector<T> buf1 = RemoveDublicates(points, removeFirstAndLast);
if (correctPoints.size()<3)
if (buf1.size()<3)
{
return correctPoints;
return buf1;
}
QVector<T> buf2;
//Remove point on line
for (qint32 i = 1; i <correctPoints.size()-1; ++i)
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.
if (VGObject::IsPointOnLineviaPDP(correctPoints.at(i), correctPoints.at(i-1), correctPoints.at(i+1)))
int prev = i-1;
int next = i+1;
if (i == 0)
{
correctPoints.remove(i);
prev = buf1.size() - 1;
}
else if (i == buf1.size() - 1)
{
next = 0;
}
const QPointF &iPoint = buf1.at(i);
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
{
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));
}
}
return correctPoints;
buf2 = RemoveDublicates(buf2, false);
return buf2;
}
//---------------------------------------------------------------------------------------------------------------------