Skip to content
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

Add SetOperation to construct more complex geometry #1052

Merged
merged 1 commit into from
Aug 16, 2023

Conversation

lucas-flexcompute
Copy link
Collaborator

@lucas-flexcompute lucas-flexcompute commented Aug 3, 2023

Also, allow GeometryGroup to accept GeometryGroup instances as group elements. That's because SetOperation must accept them as operands, so it makes sense to extend the support to GeometryGroup, since the backend code is already in place.

There's some overlap between GeometryGroup and SetOperation(operation="union") but they are left as is for a few reasons:

  1. Removing GeometryGroup would break backwards compatibility
  2. GUI depends on GeometryGroup for organization of structures
  3. SetOperation with more than 2 operands would be strange for difference and symmetric difference operations

One option would be to have the number of operands depend on the operation, but I'm not sure that's a better options then what is currently implemented because we can't remove GeometryGroup anyway.

@lucas-flexcompute lucas-flexcompute changed the title Lucas/set operations Add SetOperation to construct more complex geometry Aug 4, 2023
@lucas-flexcompute lucas-flexcompute marked this pull request as ready for review August 4, 2023 19:01
Copy link
Collaborator

@tylerflex tylerflex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, I can't follow many of the internals so maybe @weiliangjin2021 can comment on that. But in general I think it will be really nice to have this stuff generalized like this. Thanks @lucas-flexcompute

tidy3d/components/types.py Outdated Show resolved Hide resolved
tidy3d/components/geometry.py Show resolved Hide resolved
@lucas-flexcompute
Copy link
Collaborator Author

With both ClipOperation and GeometryGroup classes working, I've added Geometry.from_gds and Geometry.from_shapely to facilitate the creation of complex slabs from 2D primitives. I'm not removing PolySlab.from_gds for backwards compatibility, though.

Copy link
Collaborator

@weiliangjin2021 weiliangjin2021 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My experience of playing with those set operations is great. Lots of fun!

@lucas-flexcompute
Copy link
Collaborator Author

Great! I'll wait for any revisions required from the back-end before merging.

Also, allow GeometryGroup to accept GeometryGroup instances as group
elements. That's because ClipOperation must accept them as operands, so
it makes sense to extend the support to GeometryGroup, since the backend
code is already in place.

Importing a general gds file requires the implementation of
`ComplexPolySlab`, but the plugin implementation depends on `Medium` and
`Structure` for the `to_structure` method, so it cannot be simply
refactored into the geometry namespace. The solution was to have a
base class without the problematic method in geometry, which can be used
to import gds files.

Signed-off-by: Lucas Heitzmann Gabrielli <lucas@flexcompute.com>
@lucas-flexcompute lucas-flexcompute merged commit 02ff1b5 into pre/2.4 Aug 16, 2023
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants