Fit forward perimeter detours in tight spans
This commit is contained in:
parent
a15693ac4f
commit
c32148c312
2 changed files with 17 additions and 2 deletions
|
|
@ -259,14 +259,16 @@ def perimeter_detour_candidates(problem: RoutingProblem, search: SearchOptions)
|
|||
yield from ((net, seed) for seed in _return_detours(problem, net, obstacles, radius))
|
||||
continue
|
||||
# The two outer tangencies take one radius each, and the middle leg takes two.
|
||||
if net.target.x - net.start.x < 4 * radius or not obstacles:
|
||||
spare = net.target.x - net.start.x - 4 * radius
|
||||
if spare < 0 or not obstacles:
|
||||
continue
|
||||
low, high = sorted((net.start.y, net.target.y))
|
||||
if all(bottom > high or top < low or right < net.start.x or left > net.target.x for left, bottom, right, top in obstacles):
|
||||
continue
|
||||
margin = ceil(problem.clearance + net.width / 2 + 1)
|
||||
lanes = (max(ceil(top + margin) for _, _, _, top in obstacles), min(floor(bottom - margin) for _, bottom, _, _ in obstacles))
|
||||
pivots = {net.start.x + radius + 1, net.target.x - radius - 1}
|
||||
end_slack = 1 if spare >= 2 else 0
|
||||
pivots = {net.start.x + radius + end_slack, net.target.x - radius - end_slack}
|
||||
pivots.update(
|
||||
x
|
||||
for left, _, right, _ in obstacles
|
||||
|
|
|
|||
|
|
@ -40,6 +40,19 @@ def test_forward_perimeter_detour_can_fit_at_exactly_four_radii() -> None:
|
|||
assert sum(isinstance(move, Bend90Seed) for move in result.as_seed().segments) == 4
|
||||
|
||||
|
||||
@pytest.mark.parametrize("forward", [40, 41])
|
||||
def test_tight_forward_perimeter_detours_use_pivots_without_extra_end_spacing(forward) -> None:
|
||||
net = NetSpec("edge", Port(20, 25, 0), Port(20 + forward, 25, 0))
|
||||
problem = RoutingProblem((0, 0, 100, 100), (net,), (box(38, 20, 42, 50),), clearance=0)
|
||||
|
||||
run = route(problem, options=OPTIONS)
|
||||
|
||||
result = run.results_by_net[net.net_id]
|
||||
assert result.is_valid
|
||||
assert run.automatic.selected_planner == "perimeter"
|
||||
assert sum(isinstance(move, Bend90Seed) for move in result.as_seed().segments) == 4
|
||||
|
||||
|
||||
@pytest.mark.parametrize("smaller_radius", [10, 17.5])
|
||||
def test_perimeter_detours_choose_a_radius_usable_by_the_planner(smaller_radius) -> None:
|
||||
net = NetSpec("wide", Port(20, 70, 0), Port(220, 70, 0), width=30)
|
||||
|
|
|
|||
Loading…
Reference in a new issue