Skip to content

Commit

Permalink
Merge branch 'main' into process_version
Browse files Browse the repository at this point in the history
  • Loading branch information
joamatab authored Aug 19, 2024
2 parents a5ea941 + 653971f commit 57b3c51
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
39 changes: 24 additions & 15 deletions gplugins/common/utils/get_component_with_net_layers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import copy

import gdsfactory as gf
import gdstk
from gdsfactory.technology import LogicalLayer
from gdsfactory.typings import Component, LayerStack


Expand Down Expand Up @@ -56,9 +56,9 @@ def get_component_with_net_layers(
add_to_layerstack: True by default, but can be set to False to disable parsing of the layerstack.
"""

return NotImplementedError(
"Meshing component with net layers not implemented in gdsfactory8 yet."
)
# return NotImplementedError(
# "Meshing component with net layers not implemented in gdsfactory8 yet."
# )

# Initialize returned component
net_component = component.copy()
Expand All @@ -67,17 +67,23 @@ def get_component_with_net_layers(
for i, portname in enumerate(port_names):
port = component.ports[portname]
# Get original port layer polygons, and modify a new component without that layer
polygons = net_component.extract(layers=[port.layer]).get_polygons()
net_component = net_component.remove_layers(layers=[port.layer])
polygons = (
net_component.extract(layers=(port.layer,))
.get_polygons()
.get(port.layer, [])
)
net_component = net_component.remove_layers(layers=(port.layer,))
for polygon in polygons:
# If polygon belongs to port, create a unique new layer, and add the polygon to it

if gdstk.inside(
[port.center],
gdstk.offset(gdstk.Polygon(polygon), gf.get_active_pdk().grid_size),
)[0]:
if polygon.sized(3 * gf.kcl.dbu).inside(port.center):
# if gdstk.inside(
# [port.center],
# gdstk.offset(gdstk.Polygon(polygon), gf.get_active_pdk().grid_size),
# )[0]:
try:
port_layernames = layer_stack.get_layer_to_layername()[port.layer]
port_layernames = layer_stack.get_layer_to_layername()[
LogicalLayer(layer=port.layer)
]
except KeyError as e:
raise KeyError(
"Make sure your `layer_stack` contains all layers with ports"
Expand All @@ -89,10 +95,13 @@ def get_component_with_net_layers(
)
if add_to_layerstack:
new_layer = copy.deepcopy(layer_stack.layers[old_layername])
new_layer.layer = (
new_layers_init[0] + i,
new_layers_init[1] + j,
new_layer.layer = LogicalLayer(
layer=(
new_layers_init[0] + i,
new_layers_init[1] + j,
)
)
new_layer.name = f"{old_layername}{delimiter}{portname}"
layer_stack.layers[f"{old_layername}{delimiter}{portname}"] = (
new_layer
)
Expand Down
3 changes: 1 addition & 2 deletions gplugins/gmsh/parse_gds.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def _round_coords(x, y, z=None):

def fuse_polygons(component, layer, round_tol=4, simplify_tol=1e-4, offset_tol=None):
"""Take all polygons from a layer, and returns a single (Multi)Polygon shapely object."""

layer_region = layer.get_shapes(component)

# Convert polygons to shapely
Expand All @@ -37,7 +36,7 @@ def fuse_polygons(component, layer, round_tol=4, simplify_tol=1e-4, offset_tol=N
exterior_points.append((point.x / 1000, point.y / 1000))
for hole_index in range(klayout_polygon.holes()):
holes_points = []
for point in layer_region.each_polygon_hole(hole_index):
for point in klayout_polygon.each_point_hole(hole_index):
holes_points.append((point.x / 1000, point.y / 1000))
interior_points.append(holes_points)

Expand Down

0 comments on commit 57b3c51

Please sign in to comment.