Try inner forward detour lanes when outer lanes leave the board
This commit is contained in:
parent
393c01704a
commit
0847413ff6
2 changed files with 19 additions and 5 deletions
|
|
@ -293,12 +293,17 @@ def perimeter_detour_candidates(problem: RoutingProblem, search: SearchOptions)
|
||||||
margin = ceil(padding + 1)
|
margin = ceil(padding + 1)
|
||||||
top = max(ceil(top + margin) for _, _, _, top in nearby)
|
top = max(ceil(top + margin) for _, _, _, top in nearby)
|
||||||
bottom = min(floor(bottom - margin) for _, bottom, _, _ in nearby)
|
bottom = min(floor(bottom - margin) for _, bottom, _, _ in nearby)
|
||||||
|
y_floor = problem.bounds[1] + net.width / 2
|
||||||
|
y_ceiling = problem.bounds[3] - net.width / 2
|
||||||
lanes, fallback_lanes = [], []
|
lanes, fallback_lanes = [], []
|
||||||
for y, fallback in ((top, high + 2 * radius), (bottom, low - 2 * radius)):
|
for y, fallback in ((top, high + 2 * radius), (bottom, low - 2 * radius)):
|
||||||
if min(abs(y - low), abs(y - high)) >= 2 * radius:
|
if y_floor <= y <= y_ceiling and min(abs(y - low), abs(y - high)) >= 2 * radius:
|
||||||
lanes.append(y)
|
lanes.append(y)
|
||||||
else:
|
elif y_floor <= fallback <= y_ceiling:
|
||||||
fallback_lanes.append(fallback)
|
fallback_lanes.append(fallback)
|
||||||
|
lanes.extend(fallback_lanes)
|
||||||
|
if not lanes:
|
||||||
|
continue
|
||||||
end_slack = 1 if spare >= 2 else 0
|
end_slack = 1 if spare >= 2 else 0
|
||||||
pivots = {net.start.x + radius + end_slack, net.target.x - radius - end_slack}
|
pivots = {net.start.x + radius + end_slack, net.target.x - radius - end_slack}
|
||||||
pivots.update(
|
pivots.update(
|
||||||
|
|
@ -307,9 +312,7 @@ def perimeter_detour_candidates(problem: RoutingProblem, search: SearchOptions)
|
||||||
for x in (floor(left - radius - margin), ceil(right + radius + margin))
|
for x in (floor(left - radius - margin), ceil(right + radius + margin))
|
||||||
if net.start.x + radius <= x <= net.target.x - radius
|
if net.start.x + radius <= x <= net.target.x - radius
|
||||||
)
|
)
|
||||||
for y in (*lanes, *fallback_lanes):
|
for y in lanes:
|
||||||
if not problem.bounds[1] + net.width / 2 <= y <= problem.bounds[3] - net.width / 2:
|
|
||||||
continue
|
|
||||||
for first, last in combinations(sorted(pivots), 2):
|
for first, last in combinations(sorted(pivots), 2):
|
||||||
if last - first < 2 * radius:
|
if last - first < 2 * radius:
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,17 @@ def test_forward_perimeter_lanes_ignore_keepouts_beyond_the_target() -> None:
|
||||||
assert result.as_seed() == clean.as_seed()
|
assert result.as_seed() == clean.as_seed()
|
||||||
|
|
||||||
|
|
||||||
|
def test_forward_detours_try_inner_lanes_when_keepouts_reach_board_edges() -> None:
|
||||||
|
net = NetSpec("forward", Port(20, 60, 0), Port(120, 60, 0))
|
||||||
|
obstacles = (box(55, 50, 85, 70), box(40, 0, 45, 4), box(40, 116, 45, 120))
|
||||||
|
problem = RoutingProblem((0, 0, 200, 120), (net,), obstacles, clearance=0)
|
||||||
|
|
||||||
|
run = route(problem, options=OPTIONS)
|
||||||
|
|
||||||
|
assert run.automatic.selected_planner == "perimeter"
|
||||||
|
assert run.results_by_net[net.net_id].is_valid
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(("width", "clearance"), [(4, 0), (2, 2)])
|
@pytest.mark.parametrize(("width", "clearance"), [(4, 0), (2, 2)])
|
||||||
def test_forward_perimeter_detours_include_keepouts_clear_of_the_centerline(width, clearance) -> None:
|
def test_forward_perimeter_detours_include_keepouts_clear_of_the_centerline(width, clearance) -> None:
|
||||||
net = NetSpec("forward", Port(20, 50, 0), Port(120, 50, 0), width=width)
|
net = NetSpec("forward", Port(20, 50, 0), Port(120, 50, 0), width=width)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue