Verify static clearance at mitred component corners

This commit is contained in:
Jan Petykiewicz 2026-11-26 11:57:35 -08:00
commit d741456d6b
2 changed files with 18 additions and 0 deletions

View file

@ -695,6 +695,11 @@ class RoutingWorld:
obstacle = raw_geometries[hit_idx] obstacle = raw_geometries[hit_idx]
if buffered.touches(obstacle): if buffered.touches(obstacle):
continue continue
# A mitre may extend past the physical clearance
# radius at a component corner. Check the distance
# before counting an overlap with that broad phase.
if self.clearance > 0 and polygon.distance(obstacle) >= self.clearance:
continue
obj_id = static_obstacles.raw_obj_ids[hit_idx] obj_id = static_obstacles.raw_obj_ids[hit_idx]
if not self._is_in_safety_zone(polygon, obj_id, None, None): if not self._is_in_safety_zone(polygon, obj_id, None, None):

View file

@ -85,6 +85,19 @@ def test_check_move_static_clearance() -> None:
assert not engine.check_move_static(res_exact, start_port=start_exact) assert not engine.check_move_static(res_exact, start_port=start_exact)
def test_verify_path_report_uses_physical_distance_at_a_mitred_corner() -> None:
engine = RoutingWorld(clearance=2.0)
path = (Straight.generate(Port(0, 0, 0), 20.0, width=2.0),)
outside_radius = box(21.6, 2.6, 22.0, 3.0)
engine.add_static_obstacle(outside_radius)
assert engine.verify_path_report("net", path).is_valid
engine.add_static_obstacle(box(21.2, 2.2, 21.8, 2.8))
assert engine.verify_path_report("net", path).static_collision_count == 1
def test_verify_path_report_preserves_long_net_id() -> None: def test_verify_path_report_preserves_long_net_id() -> None:
engine = RoutingWorld(clearance=2.0) engine = RoutingWorld(clearance=2.0)
engine.metrics = AStarMetrics() engine.metrics = AStarMetrics()