Skip to content

Commit

Permalink
Set grid size for union of GDSII shapes
Browse files Browse the repository at this point in the history
Without a grid size, the default from shapely is `double` precision,
which leads to artifacts in the final geometry.  Because the GDSII
cordinates are already snapped to a grid, this should have no adverse
effect unless the GDSII grid is finer than 1e-12.  The usual default in
GDSII files is for precision to be 1e-9 with unit 1e-6, that is a grid
size of 1e-3, so the chosen value of 1e-12 should be quite safe.

Signed-off-by: Lucas Heitzmann Gabrielli <[email protected]>
  • Loading branch information
heitzmann committed Mar 21, 2023
1 parent 3ae0238 commit 28f2751
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tidy3d/components/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2336,7 +2336,9 @@ def _load_gds_vertices(

# convert vertices into polyslabs
polygons = (Polygon(vertices) for vertices in all_vertices)
polys_union = functools.reduce(lambda poly1, poly2: poly1.union(poly2), polygons)
polys_union = functools.reduce(
lambda poly1, poly2: poly1.union(poly2, grid_size=1e-12), polygons
)

if isinstance(polys_union, Polygon):
all_vertices = [PolySlab.strip_coords(polys_union)[0]]
Expand Down

0 comments on commit 28f2751

Please sign in to comment.