diff --git a/src/autorouter/autorouter.rs b/src/autorouter/autorouter.rs index e05dd6d..f72870a 100644 --- a/src/autorouter/autorouter.rs +++ b/src/autorouter/autorouter.rs @@ -18,7 +18,8 @@ use crate::{ ratsnests::Ratsnests, }, board::{AccessMesadata, Board}, - drawing::band::BandTermsegIndex, + drawing::{band::BandTermsegIndex, graph::MakePrimitiveRef}, + geometry::GetLayer, graph::MakeRef, layout::{via::ViaWeight, LayoutEdit, LayoutException}, router::{navmesh::NavmeshError, ng, thetastar::ThetastarError, RouterOptions}, @@ -139,7 +140,7 @@ impl Autorouter { ) -> Result { PlanarAutorouteExecutionPermutator::new( self, - self.selected_ratlines(selection, options.principal_layer), + self.selected_planar_ratlines(selection, options.principal_layer), options, ) } @@ -348,6 +349,24 @@ impl Autorouter { .collect() } + fn selected_planar_ratlines(&self, selection: &PinSelection, layer: usize) -> Vec { + self.selected_ratlines(selection, layer) + .into_iter() + .filter(|ratline| { + let (endpoint_dot1, endpoint_dot2) = ratline.ref_(self).endpoint_dots(); + + endpoint_dot1 + .primitive_ref(self.board().layout().drawing()) + .layer() + == layer + && endpoint_dot2 + .primitive_ref(self.board().layout().drawing()) + .layer() + == layer + }) + .collect() + } + fn find_selected_ratvertex( &self, selection: &PinSelection, diff --git a/src/autorouter/permutator.rs b/src/autorouter/permutator.rs index 8590035..5004b04 100644 --- a/src/autorouter/permutator.rs +++ b/src/autorouter/permutator.rs @@ -41,6 +41,7 @@ impl PlanarAutorouteExecutionPermutator { intersector_count_weight: 1.0, length_weight: 0.001, }, + &options, ); let initially_sorted_ratlines = presorter.presort_ratlines(autorouter, &ratlines); /*let permuter = RatlinesPermuter::SccPermutations(SccPermutationsRatlinePermuter::new( diff --git a/src/autorouter/presorter.rs b/src/autorouter/presorter.rs index 1f9cc9d..d738736 100644 --- a/src/autorouter/presorter.rs +++ b/src/autorouter/presorter.rs @@ -7,7 +7,7 @@ use enum_dispatch::enum_dispatch; use petgraph::algo::tarjan_scc; use specctra_core::mesadata::AccessMesadata; -use crate::autorouter::{ratline::RatlineUid, scc::Scc, Autorouter}; +use crate::autorouter::{ratline::RatlineUid, scc::Scc, Autorouter, PlanarAutorouteOptions}; pub struct PresortParams { pub intersector_count_weight: f64, @@ -38,11 +38,12 @@ impl SccIntersectionsAndLengthPresorter { autorouter: &mut Autorouter, ratlines: &[RatlineUid], params: &PresortParams, + options: &PlanarAutorouteOptions, ) -> Self { // FIXME: Unnecessary copy. let mut filtered_ratsnest = autorouter .ratsnests() - .on_principal_layer(ratlines[0].principal_layer) + .on_principal_layer(options.principal_layer) .graph() .clone(); filtered_ratsnest.retain_edges(|_g, i| ratlines.iter().any(|ratline| ratline.index == i));