router: rename "mesh" to "navmesh"

Clearer name. There will be more kinds of meshes (e.g. the ratsnest).
This commit is contained in:
Mikolaj Wielgus 2024-04-20 14:12:31 +02:00
parent 014aa018a9
commit 51c6eeea1f
4 changed files with 17 additions and 17 deletions

View File

@ -1,6 +1,6 @@
pub mod astar; pub mod astar;
pub mod draw; pub mod draw;
pub mod mesh; pub mod navmesh;
mod router; mod router;
pub mod tracer; pub mod tracer;
pub mod triangulation; pub mod triangulation;

View File

@ -77,12 +77,12 @@ impl HasPosition for TriangulationWeight {
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Mesh { pub struct Navmesh {
triangulation: Triangulation<TriangulationVertexIndex, TriangulationWeight>, triangulation: Triangulation<TriangulationVertexIndex, TriangulationWeight>,
vertex_to_triangulation_vertex: Vec<Option<TriangulationVertexIndex>>, vertex_to_triangulation_vertex: Vec<Option<TriangulationVertexIndex>>,
} }
impl Mesh { impl Navmesh {
pub fn new(layout: &Layout<impl RulesTrait>) -> Result<Self, InsertionError> { pub fn new(layout: &Layout<impl RulesTrait>) -> Result<Self, InsertionError> {
let mut this = Self { let mut this = Self {
triangulation: Triangulation::new(layout.drawing()), triangulation: Triangulation::new(layout.drawing()),
@ -114,7 +114,7 @@ impl Mesh {
} }
for node in layout.drawing().primitive_nodes() { for node in layout.drawing().primitive_nodes() {
// Add rails as vertices. This is how the mesh differs from the triangulation. // Add rails as vertices. This is how the navmesh differs from the triangulation.
match node { match node {
PrimitiveIndex::LooseBend(bend) => { PrimitiveIndex::LooseBend(bend) => {
this.triangulation this.triangulation
@ -142,12 +142,12 @@ impl Mesh {
} }
} }
impl visit::GraphBase for Mesh { impl visit::GraphBase for Navmesh {
type NodeId = VertexIndex; type NodeId = VertexIndex;
type EdgeId = (VertexIndex, VertexIndex); type EdgeId = (VertexIndex, VertexIndex);
} }
impl visit::Data for Mesh { impl visit::Data for Navmesh {
type NodeWeight = (); type NodeWeight = ();
type EdgeWeight = (); type EdgeWeight = ();
} }
@ -180,7 +180,7 @@ impl visit::EdgeRef for MeshEdgeReference {
} }
} }
impl<'a> visit::IntoNeighbors for &'a Mesh { impl<'a> visit::IntoNeighbors for &'a Navmesh {
type Neighbors = Box<dyn Iterator<Item = VertexIndex> + 'a>; type Neighbors = Box<dyn Iterator<Item = VertexIndex> + 'a>;
fn neighbors(self, vertex: Self::NodeId) -> Self::Neighbors { fn neighbors(self, vertex: Self::NodeId) -> Self::Neighbors {
@ -236,7 +236,7 @@ fn edge_with_near_edges(
}) })
} }
impl<'a> visit::IntoEdgeReferences for &'a Mesh { impl<'a> visit::IntoEdgeReferences for &'a Navmesh {
type EdgeRef = MeshEdgeReference; type EdgeRef = MeshEdgeReference;
type EdgeReferences = Box<dyn Iterator<Item = MeshEdgeReference> + 'a>; type EdgeReferences = Box<dyn Iterator<Item = MeshEdgeReference> + 'a>;
@ -276,7 +276,7 @@ fn vertex_edges(
}) })
} }
impl<'a> visit::IntoEdges for &'a Mesh { impl<'a> visit::IntoEdges for &'a Navmesh {
type Edges = Box<dyn Iterator<Item = MeshEdgeReference> + 'a>; type Edges = Box<dyn Iterator<Item = MeshEdgeReference> + 'a>;
fn edges(self, vertex: Self::NodeId) -> Self::Edges { fn edges(self, vertex: Self::NodeId) -> Self::Edges {

View File

@ -17,7 +17,7 @@ use crate::layout::Layout;
use crate::router::{ use crate::router::{
astar::{astar, AstarStrategy, PathTracker}, astar::{astar, AstarStrategy, PathTracker},
draw::DrawException, draw::DrawException,
mesh::{Mesh, MeshEdgeReference, VertexIndex}, navmesh::{MeshEdgeReference, Navmesh, VertexIndex},
tracer::{Trace, Tracer}, tracer::{Trace, Tracer},
}; };
@ -79,10 +79,10 @@ impl<'a, RO: RouterObserverTrait<R>, R: RulesTrait> RouterAstarStrategy<'a, RO,
} }
} }
impl<'a, RO: RouterObserverTrait<R>, R: RulesTrait> AstarStrategy<&Mesh, f64> impl<'a, RO: RouterObserverTrait<R>, R: RulesTrait> AstarStrategy<&Navmesh, f64>
for RouterAstarStrategy<'a, RO, R> for RouterAstarStrategy<'a, RO, R>
{ {
fn is_goal(&mut self, vertex: VertexIndex, tracker: &PathTracker<&Mesh>) -> bool { fn is_goal(&mut self, vertex: VertexIndex, tracker: &PathTracker<&Navmesh>) -> bool {
let new_path = tracker.reconstruct_path_to(vertex); let new_path = tracker.reconstruct_path_to(vertex);
let width = self.trace.width; let width = self.trace.width;
@ -149,7 +149,7 @@ impl<R: RulesTrait> Router<R> {
// XXX: Should we actually store the mesh? May be useful for debugging, but doesn't look // XXX: Should we actually store the mesh? May be useful for debugging, but doesn't look
// right. // right.
//self.mesh.triangulate(&self.layout)?; //self.mesh.triangulate(&self.layout)?;
let mesh = Mesh::new(&self.layout).map_err(|err| RoutingError { let mesh = Navmesh::new(&self.layout).map_err(|err| RoutingError {
from, from,
to, to,
source: err.into(), source: err.into(),
@ -187,7 +187,7 @@ impl<R: RulesTrait> Router<R> {
self.route_band(from_dot, to_dot, width, observer) self.route_band(from_dot, to_dot, width, observer)
} }
pub fn tracer<'a>(&'a mut self, mesh: &'a Mesh) -> Tracer<R> { pub fn tracer<'a>(&'a mut self, mesh: &'a Navmesh) -> Tracer<R> {
Tracer::new(&mut self.layout, mesh) Tracer::new(&mut self.layout, mesh)
} }
} }

View File

@ -10,7 +10,7 @@ use crate::{
layout::{connectivity::BandIndex, Layout}, layout::{connectivity::BandIndex, Layout},
router::{ router::{
draw::{Draw, DrawException}, draw::{Draw, DrawException},
mesh::{Mesh, VertexIndex}, navmesh::{Navmesh, VertexIndex},
}, },
}; };
@ -24,11 +24,11 @@ pub struct Trace {
pub struct Tracer<'a, R: RulesTrait> { pub struct Tracer<'a, R: RulesTrait> {
pub layout: &'a mut Layout<R>, pub layout: &'a mut Layout<R>,
pub mesh: &'a Mesh, pub mesh: &'a Navmesh,
} }
impl<'a, R: RulesTrait> Tracer<'a, R> { impl<'a, R: RulesTrait> Tracer<'a, R> {
pub fn new(layout: &'a mut Layout<R>, mesh: &'a Mesh) -> Self { pub fn new(layout: &'a mut Layout<R>, mesh: &'a Navmesh) -> Self {
Tracer { layout, mesh } Tracer { layout, mesh }
} }