Bug in ClipperOffset
Polygon and line clipping and offsetting library (C++, C#, Delphi)
Brought to you by:
angusj
Hi,
if you run ClipperOffset with distance 2 and join type jtSquare on this polygon, the output polygon cuts off one corner of the input polygon, see attached image.
{ 500, 70 },
{ 200, 70 },
{ 30, 20 },
{ 200, 20 }
The bug is located in ClipperOffset::OffsetPoint(): the assignment "k = j" should not only done at the end of the method, but also at the other return point:
@@ -4140,6 +4141,7 @@ void ClipperOffset::OffsetPoint(int j, int& k, JoinType jointype)
{
m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].X + m_normals[k].X * m_delta),
Round(m_srcPoly[j].Y + m_normals[k].Y * m_delta)));
+ k = j;
return;
}
//else angle => 180 degrees
Anonymous