2026-03-08 22:57:42 -07:00
|
|
|
from inire.geometry.collision import CollisionEngine
|
|
|
|
|
from inire.geometry.primitives import Port
|
|
|
|
|
from inire.router.astar import AStarRouter
|
|
|
|
|
from inire.router.cost import CostEvaluator
|
|
|
|
|
from inire.router.danger_map import DangerMap
|
|
|
|
|
from inire.router.pathfinder import PathFinder
|
|
|
|
|
from inire.utils.visualization import plot_routing_results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main() -> None:
|
|
|
|
|
print("Running Example 05: Orientation Stress Test...")
|
|
|
|
|
|
|
|
|
|
# 1. Setup Environment
|
2026-03-11 09:37:54 -07:00
|
|
|
bounds = (0, 0, 200, 200)
|
2026-03-08 22:57:42 -07:00
|
|
|
engine = CollisionEngine(clearance=2.0)
|
|
|
|
|
danger_map = DangerMap(bounds=bounds)
|
|
|
|
|
danger_map.precompute([])
|
2026-03-09 01:48:18 -07:00
|
|
|
|
2026-03-11 09:37:54 -07:00
|
|
|
evaluator = CostEvaluator(engine, danger_map, bend_penalty=50.0, sbend_penalty=150.0)
|
|
|
|
|
router = AStarRouter(evaluator, snap_size=1.0, straight_lengths=[1.0, 5.0, 25.0], bend_radii=[10.0])
|
2026-03-08 22:57:42 -07:00
|
|
|
pf = PathFinder(router, evaluator)
|
2026-03-09 01:48:18 -07:00
|
|
|
|
2026-03-11 09:37:54 -07:00
|
|
|
# 2. Define Netlist: Complex orientation challenges
|
2026-03-08 22:57:42 -07:00
|
|
|
netlist = {
|
2026-03-11 09:37:54 -07:00
|
|
|
"u_turn": (Port(50, 100, 0), Port(30, 100, 180)),
|
|
|
|
|
"loop": (Port(150, 50, 90), Port(150, 40, 90)),
|
|
|
|
|
"zig_zag": (Port(20, 20, 0), Port(180, 180, 0)),
|
2026-03-08 22:57:42 -07:00
|
|
|
}
|
2026-03-11 09:37:54 -07:00
|
|
|
net_widths = {nid: 2.0 for nid in netlist}
|
2026-03-08 22:57:42 -07:00
|
|
|
|
|
|
|
|
# 3. Route
|
2026-03-11 09:37:54 -07:00
|
|
|
print("Routing complex orientation nets...")
|
2026-03-08 22:57:42 -07:00
|
|
|
results = pf.route_all(netlist, net_widths)
|
|
|
|
|
|
|
|
|
|
# 4. Check Results
|
|
|
|
|
for nid, res in results.items():
|
|
|
|
|
status = "Success" if res.is_valid else "Failed"
|
2026-03-11 09:37:54 -07:00
|
|
|
print(f" {nid}: {status}")
|
2026-03-08 22:57:42 -07:00
|
|
|
|
|
|
|
|
# 5. Visualize
|
|
|
|
|
fig, ax = plot_routing_results(results, [], bounds, netlist=netlist)
|
2026-03-08 23:34:18 -07:00
|
|
|
fig.savefig("examples/05_orientation_stress.png")
|
|
|
|
|
print("Saved plot to examples/05_orientation_stress.png")
|
2026-03-08 22:57:42 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|