Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Odd "notches" in Polygon when using OffsetPolygon from Angus Johnsons's Clipper lib

enter image description here

The eventual goal of this code is to make sure the customer is defining shapes that can actually be machined by our... uh, machines. To do this, we are offsetting the specified shape inward by the radius of the bit and then back outward that same amount, thus rounding out any parts that would be too skinny to actually fit the bit into. For the polygon offsetting, we are using Angus Johnson's Clipper library, version 5.1.6 (c++).

But as can be seen in the picture this is resulting in some unexpected shapes. In the picture, I have offset the original shape(green, mostly covered by later drawing) by -radius using ClipperLib::OffsetPolygon to get the yellow shape,and then offsetting by radius to get the red shape.

In theory, this should result in the red shape matching the green shape completely for the case shown in the link.

What might be going wrong to make the above result happen?

like image 214
Mike M Avatar asked Dec 02 '13 19:12

Mike M


1 Answers

I had these artifacts also and in my case it was solved by CleanPolygons() before each and every offset operation. The problem was due to micro-self-intersections and/or duplicate points, which can be addressed using the mentioned cleaning function.

like image 52
Timo Kähkönen Avatar answered Nov 05 '22 16:11

Timo Kähkönen