-
Notifications
You must be signed in to change notification settings - Fork 192
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
Fix boolean_or operations #2804
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've reviewed this pull request using the Sourcery rules engine. If you would also like our AI-powered code review then let us know.
Code used to generate the included screenshot:
|
Co-authored-by: Sebastian Goeldi <44963764+sebastian-goeldi@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Matthew and Sebastian!
When trying to merge two component references using the
or
operator withgf.boolean(...)
, as the docs suggest, the output doesn't mergeA
andB
unless they explicitly overlap. Even if the references share an edge, the output is not merged. Additionally, the output is currently dependent on the order in which the references are given (e.g.A=ref1, B=ref2
vs.A=ref2, B=ref1
), and in one of the cases, the output appears mirrored (though it is actually just mistranslated, as shown later).Issues:
A | B
:B | A
:Expected behavior
I would expect a boolean
or
to maintain the relative positions of the input polygons and also merge everything into a singular output polygon (in the case that the inputs share at least an edge).The mistranslation issue was being caused by this bit of code here:
This was applying both transformations from
A
andB
tor1
.From what I can tell, however, the issue with the output not merging seems like it might be due to how the
or
operation is performed in the backend (maybe within KLayout itself?) rather than an issue with GDSFactory/KFactory, but I don't think I'm familiar enough with any of the backend stuff to really say with any degree of certainty.Regardless, especially since the docs suggest using
gf.boolean(...)
to merge components/references, I would expectboolean_or
to merge any regions that are touching.The solution I've found is to use the
interacting(...)
function in KLayout'sRegion
class to detect the cases where two non-overlapping polygons share an edge so that they can be merged.I am not sure how this change effects performance, however, or if a more elegant solution exists, so any suggestions/edits are welcome.