From 8235c66c7e864afb9103b1361e82401445924375 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Wed, 8 Oct 2025 02:18:56 +0200 Subject: [PATCH] fix(autorouter/anterouter): Correctly calculate fanout lengths --- crates/topola-egui/src/menu_bar.rs | 2 +- src/autorouter/anterouter.rs | 27 +++++++++------------------ 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/crates/topola-egui/src/menu_bar.rs b/crates/topola-egui/src/menu_bar.rs index 2c89ce7..59081dc 100644 --- a/crates/topola-egui/src/menu_bar.rs +++ b/crates/topola-egui/src/menu_bar.rs @@ -48,7 +48,7 @@ impl MenuBar { Self { multilayer_autorouter_options: MultilayerAutorouterOptions { anterouter: AnterouterOptions { - fanout_clearance: 100.0, + fanout_clearance: 200.0, }, planar: AutorouterOptions { presort_by: PresortBy::RatlineIntersectionCountAndLength, diff --git a/src/autorouter/anterouter.rs b/src/autorouter/anterouter.rs index 2274543..c05a697 100644 --- a/src/autorouter/anterouter.rs +++ b/src/autorouter/anterouter.rs @@ -348,6 +348,7 @@ impl Anterouter { .drawing() .primitive(source_dot) .maybe_net(); + let bbox_center = point! {x: bbox.center()[0], y: bbox.center()[1]}; let center = autorouter .board() .layout() @@ -357,22 +358,19 @@ impl Anterouter { .center(); let cardinal_direction_vector = Point::from(cardinal_direction); - /*bbox_to_anchor *= 1.0 - + dbg!( - options.fanout_outer_length - / Euclidean::distance(bbox_to_anchor, point! {x: 0.0, y: 0.0}) - );*/ + let bbox_anchor = point! { x: (bbox.upper()[0] - bbox.lower()[0]) / 2.0 * cardinal_direction_vector.x(), y: (bbox.upper()[1] - bbox.lower()[1]) / 2.0 * cardinal_direction_vector.y(), }; + let bbox_anchor_with_clearance = bbox_anchor + * (1.0 + + options.fanout_clearance + / Euclidean::distance(bbox_anchor, point! {x: 0.0, y: 0.0})); let pos = center - + bbox_anchor - * (1.0 - + options.fanout_clearance - / Euclidean::distance(bbox_anchor, point! {x: 0.0, y: 0.0})); - - //let via_bbox_to_anchor = [-pin_bbox_to_anchor[0], -pin_bbox_to_anchor[1]]; + + cardinal_direction_vector + * (bbox_center + bbox_anchor_with_clearance - center) + .dot(cardinal_direction_vector); let mut board_edit = BoardEdit::new(); @@ -407,12 +405,5 @@ impl Anterouter { } else { Err(()) } - /*let bbox = if let Some(poly) = autorouter.board().layout().drawing().geometry().compounds(dot).find(|(_, compound_weight)| { - matches!(compound_weight, CompoundWeight::Poly(..)) - }) { - poly.ref_(autorouter.board().layout()).polygon() - } else { - // - }*/ } }