Reputation: 59
While I was trying to parse and convert a Gerber RS274X file to a GDSII file, I encountered a certain problem.
If you stroke a solid circle along a certain path (a polyline), what you get is a solid shape, which can be subsequently converted to a closed polygon. My question would be is there a library or reliable algorithm to automate this process,where the input would be a string of points signifying the polyline, the output would be the resulting polygon.
Below is an image I uploaded to explain my problem.
Upvotes: 4
Views: 2327
Reputation: 3103
The algorithm you are talking about is called "Minkowski sum" (in your case, of polyline and of a polygon, approximating a circle). In you case the second summand (the circle) is convex and it means the Minkowski sum can be computed rather efficiently using so called polygon convolution.
You did not specify the language you use. In C++ Minkowski sum is available as part of Boost.Polygon or as part of CGAL.
To use them you will probably need to convert your polyline into a (degenerated) polygon by traversing it twice: forward, then backward.
Union of convex hulls proposed by @melak47 will produce correct result but much less efficiently.
Upvotes: 2
Reputation: 4850
The shape you seek can be calculated by placing a desired number of evenly spaced points in a circle around each input point, and then finding the convex hull for each pair of circles on a line segment. The union of these polygons will make up the polygon you want.
There are a number of algorithms that can find the convex hull for a set of points, and also libraries which provide implementations.
Upvotes: 1