Recover bounded routes around bends and through narrow corridors

This commit is contained in:
Jan Petykiewicz 2026-11-28 20:29:40 -08:00
commit af3ddfbb09

View file

@ -180,6 +180,30 @@ class RoutingWorld:
def _ensure_static_raw_tree(self) -> None:
self._static_obstacles.ensure_raw_tree()
def terminal_issue(self, port: Port, width: float) -> str | None:
dx, dy = rotate_cardinal(0, width / 2, int(port.r))
bounds = (port.x - abs(dx), port.y - abs(dy), port.x + abs(dx), port.y + abs(dy))
if self.board is not None:
x0, y0, x1, y1 = self.board.bounds
if bounds[0] < x0 or bounds[1] < y0 or bounds[2] > x1 or bounds[3] > y1:
return "face extends outside the routing board"
self._ensure_static_raw_tree()
tree = self._static_obstacles.raw_tree
if tree is None:
return None
clearance = self.clearance
candidates = tree.query(box(bounds[0] - clearance, bounds[1] - clearance, bounds[2] + clearance, bounds[3] + clearance))
if not len(candidates):
return None
face = LineString(((port.x - dx, port.y - dy), (port.x + dx, port.y + dy)))
for index in candidates:
keepout = tree.geometries[index]
if (clearance or id(keepout) in self._reserved_geometry_ids) and _violates_net_clearance(face, keepout, clearance):
return "face violates keepout clearance"
if not clearance and not face.relate_pattern(keepout, "F**F*****"):
return "face enters a keepout"
return None
def add_path(
self,
net_id: str,