mirror of https://codeberg.org/topola/topola.git
router: rename "mesh" to "navmesh"
Clearer name. There will be more kinds of meshes (e.g. the ratsnest).
This commit is contained in:
parent
014aa018a9
commit
51c6eeea1f
|
|
@ -1,6 +1,6 @@
|
|||
pub mod astar;
|
||||
pub mod draw;
|
||||
pub mod mesh;
|
||||
pub mod navmesh;
|
||||
mod router;
|
||||
pub mod tracer;
|
||||
pub mod triangulation;
|
||||
|
|
|
|||
|
|
@ -77,12 +77,12 @@ impl HasPosition for TriangulationWeight {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Mesh {
|
||||
pub struct Navmesh {
|
||||
triangulation: Triangulation<TriangulationVertexIndex, TriangulationWeight>,
|
||||
vertex_to_triangulation_vertex: Vec<Option<TriangulationVertexIndex>>,
|
||||
}
|
||||
|
||||
impl Mesh {
|
||||
impl Navmesh {
|
||||
pub fn new(layout: &Layout<impl RulesTrait>) -> Result<Self, InsertionError> {
|
||||
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<dyn Iterator<Item = VertexIndex> + '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<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>;
|
||||
|
||||
fn edges(self, vertex: Self::NodeId) -> Self::Edges {
|
||||
|
|
@ -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>, 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>
|
||||
{
|
||||
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<R: RulesTrait> Router<R> {
|
|||
// 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<R: RulesTrait> Router<R> {
|
|||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<R>,
|
||||
pub mesh: &'a Mesh,
|
||||
pub mesh: &'a Navmesh,
|
||||
}
|
||||
|
||||
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 }
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue