Skip to content

Commit

Permalink
Merge pull request #871 from simbilod/uz_mesh_polish
Browse files Browse the repository at this point in the history
Uz mesh polish
  • Loading branch information
joamatab committed Nov 15, 2022
2 parents eb478fa + 62e550f commit 75d6104
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions gdsfactory/simulation/gmsh/uz_xsection_mesh.py
Expand Up @@ -3,12 +3,14 @@

import numpy as np
from shapely.geometry import LineString, MultiPolygon, Point, Polygon
from shapely.ops import unary_union

import gdsfactory as gf
from gdsfactory.simulation.gmsh.mesh import mesh_from_polygons
from gdsfactory.simulation.gmsh.parse_gds import cleanup_component, to_polygons
from gdsfactory.simulation.gmsh.parse_layerstack import order_layerstack
from gdsfactory.simulation.gmsh.parse_layerstack import (
list_unique_layerstack_z,
order_layerstack,
)
from gdsfactory.tech import LayerStack
from gdsfactory.types import ComponentOrReference

Expand Down Expand Up @@ -135,13 +137,28 @@ def uz_xsection_mesh(
# TODO: buffer the union instead of adding a square
if background_tag is not None:
# shapes[background_tag] = bounds.buffer(background_padding[0])
bounds = unary_union(list(shapes.values())).bounds
# bounds = unary_union(list(shapes.values())).bounds
zs = list_unique_layerstack_z(layerstack)
zmin = np.min(zs)
zmax = np.max(zs)
shapes[background_tag] = Polygon(
[
[bounds[0] - background_padding[0], bounds[1] - background_padding[1]],
[bounds[0] - background_padding[0], bounds[3] + background_padding[3]],
[bounds[2] + background_padding[2], bounds[3] + background_padding[3]],
[bounds[2] + background_padding[2], bounds[1] - background_padding[1]],
[-1 * background_padding[0], zmin - background_padding[1]],
[-1 * background_padding[0], zmax + background_padding[3]],
[
np.linalg.norm(
np.array(xsection_bounds[1]) - np.array(xsection_bounds[0])
)
+ background_padding[2],
zmax + background_padding[3],
],
[
np.linalg.norm(
np.array(xsection_bounds[1]) - np.array(xsection_bounds[0])
)
+ background_padding[2],
zmin - background_padding[1],
],
]
)

Expand Down

0 comments on commit 75d6104

Please sign in to comment.