Skip to content

Commit

Permalink
Merge pull request #612 from gdsfactory/fix-route-waypoints-and-overl…
Browse files Browse the repository at this point in the history
…oads

fix route bundle waypoints for um interface
  • Loading branch information
sebastian-goeldi authored Feb 13, 2025
2 parents 93acb1f + b8d4f56 commit c20d5cc
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 128 deletions.
31 changes: 0 additions & 31 deletions src/kfactory/enclosure.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,37 +89,6 @@ def path_pts_to_polygon(
return kdb.DPolygon(pts_top + pts_bot)


def clean_points(points: list[kdb.Point]) -> list[kdb.Point]:
"""Remove useless points from a manhattan type of list.
This will remove the middle points that are on a straight line.
"""
if len(points) < 2:
return points
if len(points) == 2:
return points if points[1] != points[0] else points[:1]
p_p = points[0]
p = points[1]

del_points: list[int] = []

for i, p_n in enumerate(points[2:], 2):
v2 = p_n - p
v1 = p - p_p

if (
(np.sign(v1.x) == np.sign(v2.x)) and (np.sign(v1.y) == np.sign(v2.y))
) or v2.abs() == 0:
del_points.append(i - 1)
else:
p_p = p
p = p_n
for i in reversed(del_points):
del points[i]

return points


def extrude_path_points(
path: Sequence[kdb.DPoint],
width: float,
Expand Down
4 changes: 2 additions & 2 deletions src/kfactory/routing/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,6 @@ def route_bundle(
placer_errors.append(e)
error_routes.append((ps, pe, router.start.pts, router.width))
if placer_errors and on_placer_error == "show_error":
print(len(placer_errors))
db = rdb.ReportDatabase("Route Placing Errors")
cell = db.create_cell(
c.name
Expand All @@ -540,12 +539,13 @@ def route_bundle(
)
it.add_value(f"Exception: {error}")
path = kdb.Path(pts, width or ps.cross_section.width)
print(f"{width=}")
it.add_value(c.kcl.to_um(path.polygon()))
c.show(lyrdb=db)
if placer_errors and on_placer_error is not None:
for error in placer_errors:
logger.error(error)
if c.name.startswith("Unnamed_"):
c.name = c.kcl.future_cell_name or c.name
raise PlacerError(
"Failed to place routes for bundle routing from "
f"{[p.name for p in start_ports]} to {[p.name for p in end_ports]}"
Expand Down
Loading

0 comments on commit c20d5cc

Please sign in to comment.