diff --git a/locales/en-US/main.ftl b/locales/en-US/main.ftl index 9ff9010..319d288 100644 --- a/locales/en-US/main.ftl +++ b/locales/en-US/main.ftl @@ -18,6 +18,7 @@ action-undo = Undo action-redo = Redo presort-by-pairwise-detours = Presort by pairwise detours +squeeze-under-bands = Squeeze under bands wrap-around-bands = Wrap around bands show-ratsnest = Show Ratsnest diff --git a/src/autorouter/autorouter.rs b/src/autorouter/autorouter.rs index ae42d6c..ff72a6f 100644 --- a/src/autorouter/autorouter.rs +++ b/src/autorouter/autorouter.rs @@ -31,15 +31,6 @@ pub struct AutorouterOptions { pub router_options: RouterOptions, } -impl AutorouterOptions { - pub fn new() -> Self { - Self { - presort_by_pairwise_detours: false, - router_options: RouterOptions::new(), - } - } -} - #[derive(Error, Debug, Clone)] pub enum AutorouterError { #[error("nothing to route")] diff --git a/src/bin/topola-egui/top.rs b/src/bin/topola-egui/top.rs index e698eb9..e48ff14 100644 --- a/src/bin/topola-egui/top.rs +++ b/src/bin/topola-egui/top.rs @@ -9,6 +9,7 @@ use topola::{ invoker::{Command, Execute, ExecuteWithStatus, Invoker, InvokerError, InvokerStatus}, AutorouterOptions, }, + router::RouterOptions, specctra::{design::SpecctraDesign, mesadata::SpecctraMesadata}, }; @@ -32,7 +33,13 @@ pub struct Top { impl Top { pub fn new() -> Self { Self { - autorouter_options: AutorouterOptions::new(), + autorouter_options: AutorouterOptions { + presort_by_pairwise_detours: false, + router_options: RouterOptions { + wrap_around_bands: true, + squeeze_under_bands: true, + }, + }, is_placing_via: false, show_ratsnest: false, show_navmesh: false, @@ -142,6 +149,10 @@ impl Top { &mut self.autorouter_options.presort_by_pairwise_detours, tr.text("presort-by-pairwise-detours"), ); + ui.checkbox( + &mut self.autorouter_options.router_options.squeeze_under_bands, + tr.text("squeeze-under-bands"), + ); ui.checkbox( &mut self.autorouter_options.router_options.wrap_around_bands, tr.text("wrap-around-bands"), diff --git a/src/router/navmesh.rs b/src/router/navmesh.rs index b4e3955..1bc308f 100644 --- a/src/router/navmesh.rs +++ b/src/router/navmesh.rs @@ -202,26 +202,50 @@ impl Navmesh { map.insert(trianvertex, vec![(navvertex, navvertex)]); } else { map.insert(trianvertex, vec![]); - Self::add_node_to_graph_and_map_as_binavvertex( - &mut graph, - &mut map, - trianvertex, - trianvertex.into(), - ); - if options.wrap_around_bands { - let mut gear = - Into::::into(Into::::into(trianvertex)); + let mut gear = + Into::::into(Into::::into(trianvertex)); - while let Some(bend) = gear.ref_(layout.drawing()).next_gear() { - Self::add_node_to_graph_and_map_as_binavvertex( - &mut graph, - &mut map, - trianvertex, - bend.into(), - ); + if options.squeeze_under_bands { + Self::add_node_to_graph_and_map_as_binavvertex( + &mut graph, + &mut map, + trianvertex, + trianvertex.into(), + ); + + if options.wrap_around_bands { + while let Some(bend) = gear.ref_(layout.drawing()).next_gear() { + Self::add_node_to_graph_and_map_as_binavvertex( + &mut graph, + &mut map, + trianvertex, + bend.into(), + ); + gear = bend.into(); + } + } + } else if let Some(first_bend) = gear.ref_(layout.drawing()).next_gear() { + let mut bend = first_bend; + + while let Some(next_bend) = gear.ref_(layout.drawing()).next_gear() { + bend = next_bend; gear = bend.into(); } + + Self::add_node_to_graph_and_map_as_binavvertex( + &mut graph, + &mut map, + trianvertex, + bend.into(), + ); + } else { + Self::add_node_to_graph_and_map_as_binavvertex( + &mut graph, + &mut map, + trianvertex, + trianvertex.into(), + ); } }; } diff --git a/src/router/router.rs b/src/router/router.rs index 9c1afed..f8fef1e 100644 --- a/src/router/router.rs +++ b/src/router/router.rs @@ -36,15 +36,7 @@ use super::{ #[derive(Debug, Clone, Copy, Serialize, Deserialize)] pub struct RouterOptions { pub wrap_around_bands: bool, - //pub squeeze_under_bands: bool, -} - -impl RouterOptions { - pub fn new() -> Self { - Self { - wrap_around_bands: true, - } - } + pub squeeze_under_bands: bool, } #[derive(Error, Debug, Clone)]