tracer: Starting and finishing is always on a fixed dot

This commit is contained in:
Mikolaj Wielgus 2023-10-30 15:50:35 +00:00
parent 700ffb0096
commit c46d8c7434
3 changed files with 12 additions and 18 deletions

View File

@ -70,7 +70,7 @@ impl Mesh {
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()
}

View File

@ -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.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> {
@ -94,17 +96,12 @@ impl Router {
mesh.triangulate(&self.layout)?;
let mut tracer = self.tracer(&mesh);
let trace = tracer.start(mesh.vertex(DotIndex::Fixed(from)));
let trace = tracer.start(from);
let (_cost, _path) = astar(
&mesh,
mesh.vertex(DotIndex::Fixed(from)),
&mut RouterAstarStrategy::new(
tracer,
trace,
mesh.vertex(DotIndex::Fixed(to)),
observer,
),
mesh.vertex(from),
&mut RouterAstarStrategy::new(tracer, trace, mesh.vertex(to), observer),
)
.unwrap(); // TODO.

View File

@ -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 {
path: vec![from],
head: Head::from(BareHead {
dot: self.mesh.dot(from),
}),
path: vec![self.mesh.vertex(from)],
head: BareHead { dot: from }.into(),
}
}
pub fn finish(&mut self, trace: &mut Trace, into: VertexIndex, width: f64) -> Result<(), ()> {
let into_dot = self.mesh.dot(into);
self.draw().finish_in_dot(trace.head, into_dot, width)
pub fn finish(&mut self, trace: &mut Trace, into: FixedDotIndex, width: f64) -> Result<(), ()> {
self.draw().finish_in_dot(trace.head, into, width)
}
#[debug_ensures(ret.is_ok() -> trace.path.len() == path.len())]