-
-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Holes form Polygons #182
Comments
Not directly. You can first subtract the polygon from its bounding box (or the convex hull to get fewer false positives). That will leave you with all holes and concave cutouts. The idea is then to merge the original polygon with the holes or (better, in my opinion) subtract the cutouts from a new bounding box (or convex hull, if you started with it). Sorting the pieces into holes and cutouts is the tricky part. The way I can see it being possible is by checking if each piece intersects with the external boundary (bounding box or convex hull): offset the bounding box (convex hull) inwards by a small amount and subtract it from the original. That will give the external contour. Then, intersect each piece with this contour: the ones with any intersection are exterior cutouts. |
Thank you very much for your reply. poly1 ={ {0, 0}, {50, 0}, {50, 50}, {0, 50} } I am now able to split inside and outside using Clipper, I am thinking of merging inside and outside to generate the points[] below points[] = { {0, 0}, {50, 0}, {50, 50}, {20, 20}, {20, 30}, {30, 30}, {30, 20}, {20, 20} }; Is it possible to realize Here is my code split polygons into outer and inner
|
I'm not sure I understand how you want to merge those points. The array you describe ( |
By the way: the suggestion I gave comes from #173, if you wanto to take a look. |
hi @ethanVodka , I'd suggest you consider converting the polygons to a library which has a notion of shapes with holes. For example, in Klayout you can do this quite naturally: https://www.klayout.de/doc/code/class_Region.html#method79 In python, I also often use the shapely library. I believe it wraps the GEOS library from C++, so while I can't speak from experience, you can probably get the functionality you need from GEOS also. For example, to do this with shapely, it is as simple as copying over all the polygons from gdstk, merging them, and then reporting out the |
hi @heitzmann , That issue was quite helpful. thank for your advice. |
hi, @tvt173. I was able to find a library with similar functionality to shapely and will try it out. |
I tryto remove a hole from a polygon in a gds file and save it as a new gds file,
Is there any good way to do this?
I am using C++ for the gdstk library.
The text was updated successfully, but these errors were encountered: