Skip to content

Commit

Permalink
Merge pull request #2202 from gdsfactory/add_bbox_to_bend
Browse files Browse the repository at this point in the history
add optional function add_bbox to bend_euler and bend_circular
  • Loading branch information
joamatab committed Oct 20, 2023
2 parents e5ed4de + abd4174 commit 2835046
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 3 deletions.
7 changes: 6 additions & 1 deletion gdsfactory/components/bend_circular.py
Expand Up @@ -18,6 +18,7 @@ def bend_circular(
width: float | None = None,
cross_section: CrossSectionSpec = "xs_sc",
add_pins: bool = True,
add_bbox: callable | None = None,
) -> Component:
"""Returns a radial arc.
Expand All @@ -29,6 +30,7 @@ def bend_circular(
width: width to use. Defaults to cross_section.width.
cross_section: spec (CrossSection, string or dict).
add_pins: add pins to the component.
add_bbox: optional function to add bounding box to the component.
.. code::
Expand Down Expand Up @@ -58,7 +60,10 @@ def bend_circular(

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_bbox:
add_bbox(c)
else:
x.add_bbox(c, top=top, bottom=bottom)
if add_pins:
x.add_pins(c)
c.add_route_info(
Expand Down
7 changes: 6 additions & 1 deletion gdsfactory/components/bend_euler.py
Expand Up @@ -25,6 +25,7 @@ def bend_euler(
direction: str = "ccw",
cross_section: CrossSectionSpec = "xs_sc",
add_pins: bool = True,
add_bbox: callable | None = None,
) -> Component:
"""Euler bend with changing bend radius.
Expand All @@ -50,6 +51,7 @@ def bend_euler(
direction: cw (clock-wise) or ccw (counter clock-wise).
cross_section: specification (CrossSection, string, CrossSectionFactory dict).
add_pins: add pins to the component.
add_bbox: optional function to add bounding box to the component.
.. code::
Expand Down Expand Up @@ -88,7 +90,10 @@ def bend_euler(

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_bbox:
add_bbox(c)
else:
x.add_bbox(c, top=top, bottom=bottom)
if add_pins:
x.add_pins(c)
c.absorb(ref)
Expand Down
3 changes: 2 additions & 1 deletion gdsfactory/components/straight.py
Expand Up @@ -44,7 +44,8 @@ def straight(

if add_bbox:
add_bbox(c)
x.add_bbox(c, right=0, left=0)
else:
x.add_bbox(c, right=0, left=0)
if add_pins:
x.add_pins(c)
c.info["length"] = length
Expand Down
Expand Up @@ -63,6 +63,7 @@ settings:
width_wide: null
child: null
default:
add_bbox: null
add_pins: true
angle: 90.0
cross_section: xs_sc
Expand All @@ -74,6 +75,7 @@ settings:
width: null
with_arc_floorplan: true
full:
add_bbox: null
add_pins: true
angle: 90.0
cross_section:
Expand Down
2 changes: 2 additions & 0 deletions test-data-regression/test_settings_add_trenches90_.yml
Expand Up @@ -34,6 +34,7 @@ settings:
changed: {}
child: null
default:
add_bbox: null
add_pins: true
angle: 90.0
cross_section: xs_sc
Expand All @@ -45,6 +46,7 @@ settings:
width: null
with_arc_floorplan: true
full:
add_bbox: null
add_pins: true
angle: 90.0
cross_section: xs_sc
Expand Down
2 changes: 2 additions & 0 deletions test-data-regression/test_settings_bend_circular180_.yml
Expand Up @@ -29,6 +29,7 @@ settings:
angle: 180
child: null
default:
add_bbox: null
add_pins: true
angle: 90.0
cross_section: xs_sc
Expand All @@ -37,6 +38,7 @@ settings:
radius: null
width: null
full:
add_bbox: null
add_pins: true
angle: 180
cross_section: xs_sc
Expand Down
2 changes: 2 additions & 0 deletions test-data-regression/test_settings_bend_circular_.yml
Expand Up @@ -28,6 +28,7 @@ settings:
changed: {}
child: null
default:
add_bbox: null
add_pins: true
angle: 90.0
cross_section: xs_sc
Expand All @@ -36,6 +37,7 @@ settings:
radius: null
width: null
full:
add_bbox: null
add_pins: true
angle: 90.0
cross_section: xs_sc
Expand Down
2 changes: 2 additions & 0 deletions test-data-regression/test_settings_bend_euler180_.yml
Expand Up @@ -29,6 +29,7 @@ settings:
angle: 180
child: null
default:
add_bbox: null
add_pins: true
angle: 90.0
cross_section: xs_sc
Expand All @@ -40,6 +41,7 @@ settings:
width: null
with_arc_floorplan: true
full:
add_bbox: null
add_pins: true
angle: 180
cross_section: xs_sc
Expand Down
2 changes: 2 additions & 0 deletions test-data-regression/test_settings_bend_euler_.yml
Expand Up @@ -28,6 +28,7 @@ settings:
changed: {}
child: null
default:
add_bbox: null
add_pins: true
angle: 90.0
cross_section: xs_sc
Expand All @@ -39,6 +40,7 @@ settings:
width: null
with_arc_floorplan: true
full:
add_bbox: null
add_pins: true
angle: 90.0
cross_section: xs_sc
Expand Down
2 changes: 2 additions & 0 deletions test-data-regression/test_settings_bend_euler_trenches_.yml
Expand Up @@ -34,6 +34,7 @@ settings:
changed: {}
child: null
default:
add_bbox: null
add_pins: true
angle: 90.0
cross_section: xs_sc
Expand All @@ -45,6 +46,7 @@ settings:
width: null
with_arc_floorplan: true
full:
add_bbox: null
add_pins: true
angle: 90.0
cross_section: xs_sc
Expand Down

0 comments on commit 2835046

Please sign in to comment.