Skip to content

Commit

Permalink
Merge pull request #2154 from gdsfactory/fix_bbox
Browse files Browse the repository at this point in the history
bbox does not extend beyond ports in bends
  • Loading branch information
joamatab committed Oct 3, 2023
2 parents 90116d6 + a87c575 commit 9cc50d4
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 15 deletions.
7 changes: 5 additions & 2 deletions gdsfactory/components/bend_circular.py
Expand Up @@ -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(
Expand Down
21 changes: 14 additions & 7 deletions gdsfactory/components/bend_circular_heater.py
Expand Up @@ -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)
5 changes: 4 additions & 1 deletion gdsfactory/components/bend_euler.py
Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions gdsfactory/components/straight.py
Expand Up @@ -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
Expand All @@ -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)
6 changes: 4 additions & 2 deletions test-data-regression/test_settings_bend_circular_heater_.yml
Expand Up @@ -8,7 +8,7 @@ ports:
- 1
- 0
name: o1
orientation: 180
orientation: 180.0
port_type: optical
shear_angle: null
width: 0.5
Expand All @@ -20,7 +20,7 @@ ports:
- 1
- 0
name: o2
orientation: 90
orientation: 90.0
port_type: optical
shear_angle: null
width: 0.5
Expand All @@ -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
Expand Down

0 comments on commit 9cc50d4

Please sign in to comment.