mirror of https://codeberg.org/topola/topola.git
router: don't store `&'a mut Layout` in `Router`
First step towards removing multithreading in code in favor of stepping over the routing process.
This commit is contained in:
parent
43d84dc29e
commit
114329a1ef
|
|
@ -129,8 +129,8 @@ impl<M: MesadataTrait> Board<M> {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
let mut router = Router::new_from_navmesh(self.layout_mut(), navmesh);
|
let mut router = Router::new_from_navmesh(navmesh);
|
||||||
let result = router.route_band(100.0);
|
let result = router.route_band(self.layout_mut(), 100.0);
|
||||||
|
|
||||||
if let Ok(band) = result {
|
if let Ok(band) = result {
|
||||||
self.pinname_pair_to_band
|
self.pinname_pair_to_band
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,7 @@ pub enum RouterError {
|
||||||
Astar(#[from] AstarError),
|
Astar(#[from] AstarError),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Router<'a, R: RulesTrait> {
|
pub struct Router {
|
||||||
layout: &'a mut Layout<R>,
|
|
||||||
navmesh: Navmesh,
|
navmesh: Navmesh,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,9 +93,6 @@ impl<'a, R: RulesTrait> AstarStrategy<&UnGraph<NavvertexWeight, (), usize>, f64,
|
||||||
tracker: &PathTracker<&UnGraph<NavvertexWeight, (), usize>>,
|
tracker: &PathTracker<&UnGraph<NavvertexWeight, (), usize>>,
|
||||||
) -> Option<BandFirstSegIndex> {
|
) -> Option<BandFirstSegIndex> {
|
||||||
let new_path = tracker.reconstruct_path_to(vertex);
|
let new_path = tracker.reconstruct_path_to(vertex);
|
||||||
/*.into_iter()
|
|
||||||
.map(|ni| graph.node_weight(ni).unwrap().node)
|
|
||||||
.collect();*/
|
|
||||||
let width = self.trace.width;
|
let width = self.trace.width;
|
||||||
|
|
||||||
self.tracer
|
self.tracer
|
||||||
|
|
@ -155,22 +151,26 @@ impl<'a, R: RulesTrait> AstarStrategy<&UnGraph<NavvertexWeight, (), usize>, f64,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, R: RulesTrait> Router<'a, R> {
|
impl Router {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
layout: &'a mut Layout<R>,
|
layout: &Layout<impl RulesTrait>,
|
||||||
from: FixedDotIndex,
|
from: FixedDotIndex,
|
||||||
to: FixedDotIndex,
|
to: FixedDotIndex,
|
||||||
) -> Result<Self, RouterError> {
|
) -> Result<Self, RouterError> {
|
||||||
let navmesh = { Navmesh::new(layout, from, to)? };
|
let navmesh = { Navmesh::new(layout, from, to)? };
|
||||||
Ok(Self::new_from_navmesh(layout, navmesh))
|
Ok(Self::new_from_navmesh(navmesh))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_from_navmesh(layout: &'a mut Layout<R>, navmesh: Navmesh) -> Self {
|
pub fn new_from_navmesh(navmesh: Navmesh) -> Self {
|
||||||
Self { layout, navmesh }
|
Self { navmesh }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn route_band(&mut self, width: f64) -> Result<BandFirstSegIndex, RouterError> {
|
pub fn route_band(
|
||||||
let mut tracer = Tracer::new(self.layout);
|
&mut self,
|
||||||
|
layout: &mut Layout<impl RulesTrait>,
|
||||||
|
width: f64,
|
||||||
|
) -> Result<BandFirstSegIndex, RouterError> {
|
||||||
|
let mut tracer = Tracer::new(layout);
|
||||||
let trace = tracer.start(
|
let trace = tracer.start(
|
||||||
self.navmesh.graph(),
|
self.navmesh.graph(),
|
||||||
self.navmesh.source(),
|
self.navmesh.source(),
|
||||||
|
|
@ -202,8 +202,4 @@ impl<'a, R: RulesTrait> Router<'a, R> {
|
||||||
|
|
||||||
self.route_band(width)
|
self.route_band(width)
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
pub fn layout(&mut self) -> &mut Layout<R> {
|
|
||||||
self.layout
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue