Fix bug in VPiece::IsBufferAllowanceValid.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-06-18 13:48:32 +03:00
parent 12871f0708
commit a97c90378d

View File

@ -1438,17 +1438,37 @@ bool VAbstractPiece::IsAllowanceValid(const QVector<QPointF> &base, const QVecto
return false; // Wrong direction
}
for (auto i = 0; i < base.count()-1; ++i)
for (auto i = 0; i < base.count(); ++i)
{
QLineF baseSegment(base.at(i), base.at(i+1));
int nextI = -1;
if (i < base.count()-1)
{
nextI = i + 1;
}
else
{
nextI = 0;
}
QLineF baseSegment(base.at(i), base.at(nextI));
if (baseSegment.isNull())
{
continue;
}
for (auto j = 0; j < allowance.count()-1; ++j)
for (auto j = 0; j < allowance.count(); ++j)
{
QLineF allowanceSegment(allowance.at(j), allowance.at(j+1));
int nextJ = -1;
if (j < allowance.count()-1)
{
nextJ = j + 1;
}
else
{
nextJ = 0;
}
QLineF allowanceSegment(allowance.at(j), allowance.at(nextJ));
if (allowanceSegment.isNull())
{
continue;
@ -1462,7 +1482,6 @@ bool VAbstractPiece::IsAllowanceValid(const QVector<QPointF> &base, const QVecto
&& not VGObject::IsPointOnLineviaPDP(allowanceSegment.p1(), baseSegment.p1(), baseSegment.p2())
&& not VGObject::IsPointOnLineviaPDP(allowanceSegment.p2(), baseSegment.p1(), baseSegment.p2()))
{
return false;
}
}