heitzmann / gdstk

Gdstk (GDSII Tool Kit) is a C++/Python library for creation and manipulation of GDSII and OASIS files.
https://heitzmann.github.io/gdstk/
Boost Software License 1.0
324 stars 78 forks source link

Error: [GDSTK] Unable to link hole in boolean operation. #254

Open David-Pahl opened 1 month ago

David-Pahl commented 1 month ago

How do I resolve the error [GDSTK] Unable to link hole in boolean operation.

It appears when I perform a boolean "not" operation of the shape, first image attached (white is the part that is cutout). In most situations where this shape is generated, it works.

image

Sometimes, however, the boolean operation results in the following:

image

A hacky solution had previously been to scale the gridsize, as this is probably a rounding issue. But even when going to max precision the situation is not always resolved. I have also tried scaling up the shapes, then performing the boolean operation and then scaling the shapes down to their original size, but this also doesn't always resolve the issue.

Finally, if I change the cutout shapes to the following it always works, but this is not the cutout shape I want.

image

Any ideas on how to solve this issue? Thanks

heitzmann commented 1 month ago

Hard to say, usually these floating point issues can be resolved by setting an appropriate scaling. if that's not the case, them it gets a lot more complicated. Would it be possible to build it without rotation, maybe?

David-Pahl commented 1 month ago

I see, unfortunately, I need these shapes diagonally. Interestingly, depending on how other part of the design are laid out, this boolean operation fails or succeeds. It’s not great to constrain you design based on what the design software allows, but I found a lay out where the design compiles fine. Do you think there is a way to tackle this issue at a deeper level? Perhaps allow for more precision? I’d be happy to help brainstorm. I will also investigate this on my side to understand the issue better.

Best, David

On Jun 10, 2024, at 3:23 PM, Lucas H. Gabrielli @.***> wrote:

Hard to say, usually these floating point issues can be resolved by setting an appropriate scaling. if that's not the case, them it gets a lot more complicated. Would it be possible to build it without rotation, maybe?

— Reply to this email directly, view it on GitHub https://github.com/heitzmann/gdstk/issues/254#issuecomment-2159126058, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5HCU2GD7QYJNF36AIA6OKLZGX4K5AVCNFSM6AAAAABJBP4GYGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJZGEZDMMBVHA. You are receiving this because you authored the thread.

tvt173 commented 1 month ago

i suggest trying the booleans with klayout. i find that booleans in klayout are generally more robust. klayout shapes and operations are based on integer (dbu) values, not floating point, which helps to eliminate this class of error