Snap return-detour board pivots inward
This commit is contained in:
parent
6c5ee351c8
commit
a83b5ed155
2 changed files with 17 additions and 3 deletions
|
|
@ -218,11 +218,13 @@ def _return_detours(
|
|||
high = max(start.y, target.y) + 2 * radius
|
||||
bottom = min(low, min((floor(bottom - margin) for _, bottom, _, _ in obstacles), default=low))
|
||||
top = max(high, max((ceil(top + margin) for _, _, _, top in obstacles), default=high))
|
||||
pivots = {xmin + half_width, xmax - half_width, start.x + radius + 1, target.x - radius - 1}
|
||||
left_edge = ceil(xmin + half_width)
|
||||
right_edge = floor(xmax - half_width)
|
||||
pivots = {left_edge, right_edge, start.x + radius + 1, target.x - radius - 1}
|
||||
for left, _, right, _ in obstacles:
|
||||
pivots.update((floor(left - margin), ceil(right + margin)))
|
||||
departures = sorted(x for x in pivots if start.x + radius <= x <= xmax - half_width)
|
||||
arrivals = sorted((x for x in pivots if xmin + half_width <= x <= target.x - radius), reverse=True)
|
||||
departures = sorted(x for x in pivots if start.x + radius <= x <= right_edge)
|
||||
arrivals = sorted((x for x in pivots if left_edge <= x <= target.x - radius), reverse=True)
|
||||
for y in (bottom, top):
|
||||
if not ymin + half_width <= y <= ymax - half_width:
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -49,3 +49,15 @@ def test_perimeter_detours_choose_a_radius_usable_by_the_planner(smaller_radius)
|
|||
assert result.is_valid
|
||||
assert run.automatic.selected_planner == "perimeter"
|
||||
assert {move.radius for move in result.as_seed().segments if isinstance(move, Bend90Seed)} == {20}
|
||||
|
||||
|
||||
def test_return_detours_snap_board_pivots_inward_before_generating_seeds() -> None:
|
||||
net = NetSpec("return", Port(88, 50, 0), Port(12, 50, 0), width=3)
|
||||
problem = RoutingProblem((0, 0, 100, 100), (net,), 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 result.path[-1].end_port == net.target
|
||||
|
|
|
|||
Loading…
Reference in a new issue