Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting a polyline to a polygonal shape with width

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.

enter image description here

like image 419
david lin Avatar asked Oct 21 '25 22:10

david lin


1 Answers

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.

like image 89
Michael Simbirsky Avatar answered Oct 24 '25 11:10

Michael Simbirsky