def connect_strip_way_points(way_points=[], bend_factory=bend_circular, straight_factory=waveguide, taper_factory=taper_factory, bend_radius=10.0, wg_width=0.5, layer=LAYER.WG, **kwargs): """ Returns a deep-etched route formed by the given way_points with bends instead of corners and optionally tapers in straight sections. taper_factory: can be either a taper component or a factory """ bend90 = bend_factory(radius=bend_radius, width=wg_width) if taper_factory: if callable(taper_factory): taper = taper_factory( length=TAPER_LENGTH, width1=wg_width, width2=WG_EXPANDED_WIDTH, layer=layer, ) else: # In this case the taper is a fixed cell taper = taper_factory else: taper = None connector = round_corners(way_points, bend90, straight_factory, taper) return connector
def connect_strip_way_points(way_points: List[Tuple[float, float]], bend_factory: Callable = bend_circular, straight_factory: Callable = waveguide, taper_factory: Callable = taper_factory, bend_radius: float = 10.0, wg_width: float = 0.5, layer=LAYER.WG, **kwargs): """Returns a deep-etched route formed by the given way_points with bends instead of corners and optionally tapers in straight sections. taper_factory: can be either a taper Component or a factory """ way_points = np.array(way_points) bend90 = bend_factory(radius=bend_radius, width=wg_width) taper = (taper_factory( length=TAPER_LENGTH, width1=wg_width, width2=WG_EXPANDED_WIDTH, layer=layer, ) if callable(taper_factory) else taper_factory) connector = round_corners(way_points, bend90, straight_factory, taper) return connector
def connect_strip( input_port: Port, output_port: Port, bend_factory: Callable = bend_circular, straight_factory: Callable = waveguide, taper_factory: Callable = taper_factory, start_straight: float = 0.01, end_straight: float = 0.01, min_straight: float = 0.01, bend_radius: float = 10.0, route_factory: Callable = route_manhattan, ) -> ComponentReference: """Returns an optical route Reference""" bend90 = bend_factory(radius=bend_radius, width=input_port.width) taper = (taper_factory( length=TAPER_LENGTH, width1=input_port.width, width2=WG_EXPANDED_WIDTH, layer=input_port.layer, ) if callable(taper_factory) else taper_factory) connector = route_factory( input_port, output_port, bend90, straight_factory=straight_factory, taper=taper, start_straight=start_straight, end_straight=end_straight, min_straight=min_straight, ) return connector
def connect_strip( input_port, output_port, bend_factory=bend_circular, straight_factory=waveguide, taper_factory=taper_factory, start_straight=0.01, end_straight=0.01, min_straight=0.01, bend_radius=10.0, route_factory=route_manhattan, ): bend90 = bend_factory(radius=bend_radius, width=input_port.width) if taper_factory: if callable(taper_factory): taper = taper_factory( length=TAPER_LENGTH, width1=input_port.width, width2=WG_EXPANDED_WIDTH, layer=input_port.layer, ) else: # In this case the taper is a fixed cell taper = taper_factory else: taper = None connector = route_factory( input_port, output_port, bend90, straight_factory=straight_factory, taper=taper, start_straight=start_straight, end_straight=end_straight, min_straight=min_straight, ) return connector
def connect_bundle_waypoints(start_ports, end_ports, way_points, straight_factory=waveguide, taper_factory=taper_factory, bend_factory=bend_circular, bend_radius=10.0, auto_sort=True, **kwargs): """ start_ports: a list of ports end_ports: a list of ports way_points: a list of points defining a route with way_points[0] = start_ports[0] way_points[-1] = end_ports[0] """ if len(end_ports) != len(start_ports): raise ValueError( "Number of start ports should match number of end ports.\ Got {} {}".format(len(start_ports), len(end_ports))) for p in start_ports: p.angle = int(p.angle) % 360 for p in end_ports: p.angle = int(p.angle) % 360 start_angle = start_ports[0].orientation end_angle = end_ports[0].orientation """ Sort the ports such that the bundle connect the correct corresponding ports. """ angles_to_sorttypes = { (0, 180): ("Y", "Y"), (0, 90): ("Y", "X"), (0, 0): ("Y", "-Y"), (0, 270): ("Y", "-X"), (90, 0): ("X", "Y"), (90, 90): ("X", "-X"), (90, 180): ("X", "-Y"), (90, 270): ("X", "X"), (180, 90): ("Y", "-X"), (180, 0): ("Y", "Y"), (180, 270): ("Y", "X"), (180, 180): ("Y", "-Y"), (270, 90): ("X", "X"), (270, 270): ("X", "-X"), (270, 0): ("X", "-Y"), (270, 180): ("X", "Y"), } dict_sorts = { "X": lambda p: p.x, "Y": lambda p: p.y, "-X": lambda p: -p.x, "-Y": lambda p: -p.y, } key = (start_angle, end_angle) sp_st, ep_st = angles_to_sorttypes[key] start_port_sort = dict_sorts[sp_st] end_port_sort = dict_sorts[ep_st] if auto_sort: start_ports.sort(key=start_port_sort) end_ports.sort(key=end_port_sort) routes = _generate_manhattan_bundle_waypoints(start_ports, end_ports, way_points, **kwargs) bends90 = [ bend_factory(radius=bend_radius, width=p.width) for p in start_ports ] if taper_factory != None: if type(taper_factory) == type(lambda a: a): taper = taper_factory( length=TAPER_LENGTH, width1=start_ports[0].width, width2=WG_EXPANDED_WIDTH, layer=start_ports[0].layer, ) else: # In this case the taper is a fixed cell taper = taper_factory else: taper = None connections = [ round_corners(pts, bend90, straight_factory, taper=taper) for pts, bend90 in zip(routes, bends90) ] return connections