mirror of https://codeberg.org/topola/topola.git
mesh: Remove `Visitable`, `VisitMap` trait impls
I don't know why the original A* implementation needed tem.
This commit is contained in:
parent
13e38c6889
commit
66d5b3e605
|
|
@ -10,7 +10,7 @@ use std::collections::{BinaryHeap, HashMap};
|
|||
use std::hash::Hash;
|
||||
|
||||
use petgraph::algo::Measure;
|
||||
use petgraph::visit::{EdgeRef, GraphBase, IntoEdges, Visitable};
|
||||
use petgraph::visit::{EdgeRef, GraphBase, IntoEdges};
|
||||
|
||||
use std::cmp::Ordering;
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ where
|
|||
|
||||
pub trait AstarStrategy<G, K>
|
||||
where
|
||||
G: IntoEdges + Visitable,
|
||||
G: IntoEdges,
|
||||
K: Measure + Copy,
|
||||
G::NodeId: Eq + Hash,
|
||||
{
|
||||
|
|
@ -111,7 +111,7 @@ pub fn astar<G, K>(
|
|||
strategy: &mut impl AstarStrategy<G, K>,
|
||||
) -> Option<(K, Vec<G::NodeId>)>
|
||||
where
|
||||
G: IntoEdges + Visitable,
|
||||
G: IntoEdges,
|
||||
G::NodeId: Eq + Hash,
|
||||
K: Measure + Copy,
|
||||
{
|
||||
|
|
|
|||
44
src/mesh.rs
44
src/mesh.rs
|
|
@ -91,50 +91,6 @@ impl visit::GraphBase for Mesh {
|
|||
type EdgeId = (VertexIndex, VertexIndex);
|
||||
}
|
||||
|
||||
pub struct MeshVisitMap {
|
||||
fixedbitset: FixedBitSet,
|
||||
}
|
||||
|
||||
impl MeshVisitMap {
|
||||
pub fn with_capacity(bits: usize) -> Self {
|
||||
Self {
|
||||
fixedbitset: FixedBitSet::with_capacity(bits),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear(&mut self) {
|
||||
self.fixedbitset.clear();
|
||||
}
|
||||
|
||||
pub fn grow(&mut self, bits: usize) {
|
||||
self.fixedbitset.grow(bits);
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: GetNodeIndex> visit::VisitMap<T> for MeshVisitMap {
|
||||
fn visit(&mut self, a: T) -> bool {
|
||||
!self.fixedbitset.put(a.node_index().index())
|
||||
}
|
||||
|
||||
fn is_visited(&self, a: &T) -> bool {
|
||||
self.fixedbitset.contains(a.node_index().index())
|
||||
}
|
||||
}
|
||||
|
||||
impl visit::Visitable for Mesh {
|
||||
type Map = MeshVisitMap;
|
||||
|
||||
fn visit_map(&self) -> Self::Map {
|
||||
// FIXME: This seems wrong, but pathfinding works for some reason. Investigate.
|
||||
MeshVisitMap::with_capacity(self.triangulation.num_vertices())
|
||||
}
|
||||
|
||||
fn reset_map(&self, map: &mut Self::Map) {
|
||||
map.clear();
|
||||
map.grow(self.triangulation.num_vertices());
|
||||
}
|
||||
}
|
||||
|
||||
impl visit::Data for Mesh {
|
||||
type NodeWeight = ();
|
||||
type EdgeWeight = ();
|
||||
|
|
|
|||
Loading…
Reference in New Issue