From 51c6eeea1f72de2a48caf1623093c37ccde62656 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Sat, 20 Apr 2024 14:12:31 +0200 Subject: [PATCH] router: rename "mesh" to "navmesh" Clearer name. There will be more kinds of meshes (e.g. the ratsnest). --- src/router/mod.rs | 2 +- src/router/{mesh.rs => navmesh.rs} | 16 ++++++++-------- src/router/router.rs | 10 +++++----- src/router/tracer.rs | 6 +++--- 4 files changed, 17 insertions(+), 17 deletions(-) rename src/router/{mesh.rs => navmesh.rs} (96%) diff --git a/src/router/mod.rs b/src/router/mod.rs index 3efa300..5d923d7 100644 --- a/src/router/mod.rs +++ b/src/router/mod.rs @@ -1,6 +1,6 @@ pub mod astar; pub mod draw; -pub mod mesh; +pub mod navmesh; mod router; pub mod tracer; pub mod triangulation; diff --git a/src/router/mesh.rs b/src/router/navmesh.rs similarity index 96% rename from src/router/mesh.rs rename to src/router/navmesh.rs index a6f8f9e..bd1dbb0 100644 --- a/src/router/mesh.rs +++ b/src/router/navmesh.rs @@ -77,12 +77,12 @@ impl HasPosition for TriangulationWeight { } #[derive(Debug, Clone)] -pub struct Mesh { +pub struct Navmesh { triangulation: Triangulation, vertex_to_triangulation_vertex: Vec>, } -impl Mesh { +impl Navmesh { pub fn new(layout: &Layout) -> Result { let mut this = Self { triangulation: Triangulation::new(layout.drawing()), @@ -114,7 +114,7 @@ impl Mesh { } 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 { PrimitiveIndex::LooseBend(bend) => { this.triangulation @@ -142,12 +142,12 @@ impl Mesh { } } -impl visit::GraphBase for Mesh { +impl visit::GraphBase for Navmesh { type NodeId = VertexIndex; type EdgeId = (VertexIndex, VertexIndex); } -impl visit::Data for Mesh { +impl visit::Data for Navmesh { type NodeWeight = (); 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 + 'a>; 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 EdgeReferences = Box + '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 + 'a>; fn edges(self, vertex: Self::NodeId) -> Self::Edges { diff --git a/src/router/router.rs b/src/router/router.rs index 7d34515..96b5ef7 100644 --- a/src/router/router.rs +++ b/src/router/router.rs @@ -17,7 +17,7 @@ use crate::layout::Layout; use crate::router::{ astar::{astar, AstarStrategy, PathTracker}, draw::DrawException, - mesh::{Mesh, MeshEdgeReference, VertexIndex}, + navmesh::{MeshEdgeReference, Navmesh, VertexIndex}, tracer::{Trace, Tracer}, }; @@ -79,10 +79,10 @@ impl<'a, RO: RouterObserverTrait, R: RulesTrait> RouterAstarStrategy<'a, RO, } } -impl<'a, RO: RouterObserverTrait, R: RulesTrait> AstarStrategy<&Mesh, f64> +impl<'a, RO: RouterObserverTrait, R: RulesTrait> AstarStrategy<&Navmesh, f64> 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 width = self.trace.width; @@ -149,7 +149,7 @@ impl Router { // XXX: Should we actually store the mesh? May be useful for debugging, but doesn't look // right. //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, to, source: err.into(), @@ -187,7 +187,7 @@ impl Router { self.route_band(from_dot, to_dot, width, observer) } - pub fn tracer<'a>(&'a mut self, mesh: &'a Mesh) -> Tracer { + pub fn tracer<'a>(&'a mut self, mesh: &'a Navmesh) -> Tracer { Tracer::new(&mut self.layout, mesh) } } diff --git a/src/router/tracer.rs b/src/router/tracer.rs index 778bd00..bdc22e5 100644 --- a/src/router/tracer.rs +++ b/src/router/tracer.rs @@ -10,7 +10,7 @@ use crate::{ layout::{connectivity::BandIndex, Layout}, router::{ draw::{Draw, DrawException}, - mesh::{Mesh, VertexIndex}, + navmesh::{Navmesh, VertexIndex}, }, }; @@ -24,11 +24,11 @@ pub struct Trace { pub struct Tracer<'a, R: RulesTrait> { pub layout: &'a mut Layout, - pub mesh: &'a Mesh, + pub mesh: &'a Navmesh, } impl<'a, R: RulesTrait> Tracer<'a, R> { - pub fn new(layout: &'a mut Layout, mesh: &'a Mesh) -> Self { + pub fn new(layout: &'a mut Layout, mesh: &'a Navmesh) -> Self { Tracer { layout, mesh } }