mirror of https://codeberg.org/topola/topola.git
tracer: Starting and finishing is always on a fixed dot
This commit is contained in:
parent
700ffb0096
commit
c46d8c7434
|
|
@ -70,7 +70,7 @@ impl Mesh {
|
||||||
self.triangulation.vertex(vertex.handle).as_ref().dot
|
self.triangulation.vertex(vertex.handle).as_ref().dot
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn vertex(&self, dot: DotIndex) -> VertexIndex {
|
pub fn vertex(&self, dot: FixedDotIndex) -> VertexIndex {
|
||||||
self.dot_to_vertex[dot.node_index().index()].unwrap()
|
self.dot_to_vertex[dot.node_index().index()].unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,9 @@ impl<'a, RO: RouterObserver> AstarStrategy<&Mesh, u64> for RouterAstarStrategy<'
|
||||||
self.tracer.rework_path(&mut self.trace, &new_path, 5.0);
|
self.tracer.rework_path(&mut self.trace, &new_path, 5.0);
|
||||||
self.observer.on_rework(&self.tracer, &self.trace);
|
self.observer.on_rework(&self.tracer, &self.trace);
|
||||||
|
|
||||||
self.tracer.finish(&mut self.trace, self.to, 5.0).is_ok()
|
self.tracer
|
||||||
|
.finish(&mut self.trace, self.tracer.mesh.dot(self.to), 5.0)
|
||||||
|
.is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn edge_cost(&mut self, edge: MeshEdgeReference) -> Option<u64> {
|
fn edge_cost(&mut self, edge: MeshEdgeReference) -> Option<u64> {
|
||||||
|
|
@ -94,17 +96,12 @@ impl Router {
|
||||||
mesh.triangulate(&self.layout)?;
|
mesh.triangulate(&self.layout)?;
|
||||||
|
|
||||||
let mut tracer = self.tracer(&mesh);
|
let mut tracer = self.tracer(&mesh);
|
||||||
let trace = tracer.start(mesh.vertex(DotIndex::Fixed(from)));
|
let trace = tracer.start(from);
|
||||||
|
|
||||||
let (_cost, _path) = astar(
|
let (_cost, _path) = astar(
|
||||||
&mesh,
|
&mesh,
|
||||||
mesh.vertex(DotIndex::Fixed(from)),
|
mesh.vertex(from),
|
||||||
&mut RouterAstarStrategy::new(
|
&mut RouterAstarStrategy::new(tracer, trace, mesh.vertex(to), observer),
|
||||||
tracer,
|
|
||||||
trace,
|
|
||||||
mesh.vertex(DotIndex::Fixed(to)),
|
|
||||||
observer,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
.unwrap(); // TODO.
|
.unwrap(); // TODO.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,18 +29,15 @@ impl<'a> Tracer<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start(&mut self, from: VertexIndex) -> Trace {
|
pub fn start(&mut self, from: FixedDotIndex) -> Trace {
|
||||||
Trace {
|
Trace {
|
||||||
path: vec![from],
|
path: vec![self.mesh.vertex(from)],
|
||||||
head: Head::from(BareHead {
|
head: BareHead { dot: from }.into(),
|
||||||
dot: self.mesh.dot(from),
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn finish(&mut self, trace: &mut Trace, into: VertexIndex, width: f64) -> Result<(), ()> {
|
pub fn finish(&mut self, trace: &mut Trace, into: FixedDotIndex, width: f64) -> Result<(), ()> {
|
||||||
let into_dot = self.mesh.dot(into);
|
self.draw().finish_in_dot(trace.head, into, width)
|
||||||
self.draw().finish_in_dot(trace.head, into_dot, width)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[debug_ensures(ret.is_ok() -> trace.path.len() == path.len())]
|
#[debug_ensures(ret.is_ok() -> trace.path.len() == path.len())]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue