Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top