From a87c57566cb1ce232c54e8d24115b87a5121557d Mon Sep 17 00:00:00 2001 From: Joaquin Matres <4514346+joamatab@users.noreply.github.com> Date: Tue, 3 Oct 2023 06:44:36 -0700 Subject: [PATCH] bbox does not extend beyond ports in bends --- gdsfactory/components/bend_circular.py | 7 +++++-- gdsfactory/components/bend_circular_heater.py | 21 ++++++++++++------- gdsfactory/components/bend_euler.py | 5 ++++- gdsfactory/components/straight.py | 5 ++--- .../test_settings_bend_circular_heater_.yml | 6 ++++-- 5 files changed, 29 insertions(+), 15 deletions(-) diff --git a/gdsfactory/components/bend_circular.py b/gdsfactory/components/bend_circular.py index b5945404b0..d3d2e02b91 100644 --- a/gdsfactory/components/bend_circular.py +++ b/gdsfactory/components/bend_circular.py @@ -49,13 +49,16 @@ def bend_circular( path = p.extrude(x) ref = c << path c.add_ports(ref.ports) - c.absorb(ref) + c.info["length"] = float(snap_to_grid(p.length())) c.info["dy"] = snap_to_grid(float(abs(p.points[0][0] - p.points[-1][0]))) c.info["radius"] = float(radius) x.validate_radius(radius) - x.add_bbox(c) + + top = None if int(angle) in {180, -180, -90} else 0 + bottom = 0 if int(angle) in {-90} else None + x.add_bbox(c, top=top, bottom=bottom) if add_pins: x.add_pins(c) c.add_route_info( diff --git a/gdsfactory/components/bend_circular_heater.py b/gdsfactory/components/bend_circular_heater.py index 84a65370dd..4ea74efb8a 100644 --- a/gdsfactory/components/bend_circular_heater.py +++ b/gdsfactory/components/bend_circular_heater.py @@ -51,18 +51,25 @@ def bend_circular_heater( xs = x.copy(sections=sections) p = arc(radius=radius, angle=angle, npoints=npoints) - c = p.extrude(xs) - c.length = np.round(p.length(), 3) - c.dx = abs(p.points[0][0] - p.points[-1][0]) - c.dy = abs(p.points[0][0] - p.points[-1][0]) + + c = Component() + path = p.extrude(xs) + ref = c << path + c.add_ports(ref.ports) + c.absorb(ref) + c.info["length"] = np.round(p.length(), 3) + c.info["dx"] = abs(p.points[0][0] - p.points[-1][0]) + c.info["dy"] = abs(p.points[0][0] - p.points[-1][0]) x.validate_radius(radius) - if with_bbox and x.bbox_layers: - x.add_bbox(c) + if with_bbox: + top = None if int(angle) in {180, -180, -90} else 0 + bottom = 0 if int(angle) in {-90} else None + x.add_bbox(c, top=top, bottom=bottom) return c if __name__ == "__main__": - c = bend_circular_heater(heater_width=1) + c = bend_circular_heater(heater_width=1, cross_section="xs_rc") print(c.ports) c.show(show_ports=True) diff --git a/gdsfactory/components/bend_euler.py b/gdsfactory/components/bend_euler.py index 21e5c2ca23..073b0f5acd 100644 --- a/gdsfactory/components/bend_euler.py +++ b/gdsfactory/components/bend_euler.py @@ -85,7 +85,10 @@ def bend_euler( ref.mirror(p1=[0, 0], p2=[1, 0]) x.validate_radius(radius) - x.add_bbox(c) + + top = None if int(angle) in {180, -180, -90} else 0 + bottom = 0 if int(angle) in {-90} else None + x.add_bbox(c, top=top, bottom=bottom) if add_pins: x.add_pins(c) c.absorb(ref) diff --git a/gdsfactory/components/straight.py b/gdsfactory/components/straight.py index d79ba6beb7..aaa2f7ca2d 100644 --- a/gdsfactory/components/straight.py +++ b/gdsfactory/components/straight.py @@ -41,7 +41,7 @@ def straight( ref = c << path c.add_ports(ref.ports) - x.add_bbox(c) + x.add_bbox(c, right=0, left=0) if add_pins: x.add_pins(c) c.info["length"] = length @@ -56,8 +56,7 @@ def straight( if __name__ == "__main__": import gdsfactory as gf - xs = gf.cross_section.strip() - c = straight(layer=(2, 0)) + c = straight(cross_section="xs_rc") # c = straight() print(c.info) c.show(show_ports=True) diff --git a/test-data-regression/test_settings_bend_circular_heater_.yml b/test-data-regression/test_settings_bend_circular_heater_.yml index e9788ac366..c7c49ea239 100644 --- a/test-data-regression/test_settings_bend_circular_heater_.yml +++ b/test-data-regression/test_settings_bend_circular_heater_.yml @@ -8,7 +8,7 @@ ports: - 1 - 0 name: o1 - orientation: 180 + orientation: 180.0 port_type: optical shear_angle: null width: 0.5 @@ -20,7 +20,7 @@ ports: - 1 - 0 name: o2 - orientation: 90 + orientation: 90.0 port_type: optical shear_angle: null width: 0.5 @@ -47,6 +47,8 @@ settings: with_bbox: true function_name: bend_circular_heater info: + dx: 10.0 + dy: 10.0 length: 15.708 info_version: 2 module: gdsfactory.components.bend_circular_heater