mirror of https://codeberg.org/topola/topola.git
autorouter,router: shorten and clarify terminology
Rename "triangulation vertex" to just "trianvertex". Rename "navigation vertex" to just "navvertex". The standalone word "vertex" was overused and in some cases confusing.
This commit is contained in:
parent
02a5e13e23
commit
a80dfc10be
|
|
@ -15,7 +15,7 @@ use thiserror::Error;
|
||||||
use crate::{
|
use crate::{
|
||||||
autorouter::{
|
autorouter::{
|
||||||
board::Board,
|
board::Board,
|
||||||
ratsnest::{Ratsnest, RatsnestVertexIndex},
|
ratsnest::{Ratsnest, RatvertexIndex},
|
||||||
selection::Selection,
|
selection::Selection,
|
||||||
},
|
},
|
||||||
drawing::{
|
drawing::{
|
||||||
|
|
@ -28,7 +28,7 @@ use crate::{
|
||||||
navmesh::{Navmesh, NavmeshError},
|
navmesh::{Navmesh, NavmeshError},
|
||||||
Router, RouterError, RouterObserverTrait,
|
Router, RouterError, RouterObserverTrait,
|
||||||
},
|
},
|
||||||
triangulation::GetVertexIndex,
|
triangulation::GetTrianvertexIndex,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Error, Debug, Clone)]
|
#[derive(Error, Debug, Clone)]
|
||||||
|
|
@ -180,10 +180,10 @@ impl<R: RulesTrait> Autorouter<R> {
|
||||||
.graph()
|
.graph()
|
||||||
.node_weight(source)
|
.node_weight(source)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.vertex_index()
|
.trianvertex_index()
|
||||||
{
|
{
|
||||||
RatsnestVertexIndex::FixedDot(dot) => dot,
|
RatvertexIndex::FixedDot(dot) => dot,
|
||||||
RatsnestVertexIndex::Zone(zone) => self.board.layout_mut().zone_apex(zone),
|
RatvertexIndex::Zone(zone) => self.board.layout_mut().zone_apex(zone),
|
||||||
};
|
};
|
||||||
|
|
||||||
let target_dot = match self
|
let target_dot = match self
|
||||||
|
|
@ -191,10 +191,10 @@ impl<R: RulesTrait> Autorouter<R> {
|
||||||
.graph()
|
.graph()
|
||||||
.node_weight(target)
|
.node_weight(target)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.vertex_index()
|
.trianvertex_index()
|
||||||
{
|
{
|
||||||
RatsnestVertexIndex::FixedDot(dot) => dot,
|
RatvertexIndex::FixedDot(dot) => dot,
|
||||||
RatsnestVertexIndex::Zone(zone) => self.board.layout_mut().zone_apex(zone),
|
RatvertexIndex::Zone(zone) => self.board.layout_mut().zone_apex(zone),
|
||||||
};
|
};
|
||||||
|
|
||||||
(source_dot, target_dot)
|
(source_dot, target_dot)
|
||||||
|
|
@ -212,13 +212,13 @@ impl<R: RulesTrait> Autorouter<R> {
|
||||||
.graph()
|
.graph()
|
||||||
.node_weight(source)
|
.node_weight(source)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.vertex_index();
|
.trianvertex_index();
|
||||||
let to_vertex = self
|
let to_vertex = self
|
||||||
.ratsnest
|
.ratsnest
|
||||||
.graph()
|
.graph()
|
||||||
.node_weight(target)
|
.node_weight(target)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.vertex_index();
|
.trianvertex_index();
|
||||||
|
|
||||||
selection.contains_node(&self.board, source_vertex.into())
|
selection.contains_node(&self.board, source_vertex.into())
|
||||||
&& selection.contains_node(&self.board, to_vertex.into())
|
&& selection.contains_node(&self.board, to_vertex.into())
|
||||||
|
|
|
||||||
|
|
@ -24,38 +24,38 @@ use crate::{
|
||||||
zone::{MakePolyShape, ZoneWeight},
|
zone::{MakePolyShape, ZoneWeight},
|
||||||
Layout,
|
Layout,
|
||||||
},
|
},
|
||||||
triangulation::{GetVertexIndex, Triangulation},
|
triangulation::{GetTrianvertexIndex, Triangulation},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[enum_dispatch(GetNodeIndex)]
|
#[enum_dispatch(GetNodeIndex)]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub enum RatsnestVertexIndex {
|
pub enum RatvertexIndex {
|
||||||
FixedDot(FixedDotIndex),
|
FixedDot(FixedDotIndex),
|
||||||
Zone(GenericIndex<ZoneWeight>),
|
Zone(GenericIndex<ZoneWeight>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<RatsnestVertexIndex> for crate::layout::NodeIndex {
|
impl From<RatvertexIndex> for crate::layout::NodeIndex {
|
||||||
fn from(vertex: RatsnestVertexIndex) -> crate::layout::NodeIndex {
|
fn from(vertex: RatvertexIndex) -> crate::layout::NodeIndex {
|
||||||
match vertex {
|
match vertex {
|
||||||
RatsnestVertexIndex::FixedDot(dot) => crate::layout::NodeIndex::Primitive(dot.into()),
|
RatvertexIndex::FixedDot(dot) => crate::layout::NodeIndex::Primitive(dot.into()),
|
||||||
RatsnestVertexIndex::Zone(zone) => crate::layout::NodeIndex::Compound(zone.into()),
|
RatvertexIndex::Zone(zone) => crate::layout::NodeIndex::Compound(zone.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct VertexWeight {
|
pub struct RatvertexWeight {
|
||||||
vertex: RatsnestVertexIndex,
|
vertex: RatvertexIndex,
|
||||||
pub pos: Point,
|
pub pos: Point,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetVertexIndex<RatsnestVertexIndex> for VertexWeight {
|
impl GetTrianvertexIndex<RatvertexIndex> for RatvertexWeight {
|
||||||
fn vertex_index(&self) -> RatsnestVertexIndex {
|
fn trianvertex_index(&self) -> RatvertexIndex {
|
||||||
self.vertex
|
self.vertex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasPosition for VertexWeight {
|
impl HasPosition for RatvertexWeight {
|
||||||
type Scalar = f64;
|
type Scalar = f64;
|
||||||
fn position(&self) -> Point2<Self::Scalar> {
|
fn position(&self) -> Point2<Self::Scalar> {
|
||||||
Point2::new(self.pos.x(), self.pos.y())
|
Point2::new(self.pos.x(), self.pos.y())
|
||||||
|
|
@ -63,12 +63,12 @@ impl HasPosition for VertexWeight {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Copy)]
|
#[derive(Debug, Default, Clone, Copy)]
|
||||||
pub struct EdgeWeight {
|
pub struct RatlineWeight {
|
||||||
pub band: Option<BandIndex>,
|
pub band: Option<BandIndex>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Ratsnest {
|
pub struct Ratsnest {
|
||||||
graph: UnGraph<VertexWeight, EdgeWeight, usize>,
|
graph: UnGraph<RatvertexWeight, RatlineWeight, usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Ratsnest {
|
impl Ratsnest {
|
||||||
|
|
@ -101,8 +101,8 @@ impl Ratsnest {
|
||||||
}
|
}
|
||||||
|
|
||||||
triangulations.get_mut(&(layer, net)).unwrap().add_vertex(
|
triangulations.get_mut(&(layer, net)).unwrap().add_vertex(
|
||||||
VertexWeight {
|
RatvertexWeight {
|
||||||
vertex: RatsnestVertexIndex::FixedDot(dot),
|
vertex: RatvertexIndex::FixedDot(dot),
|
||||||
pos: node.primitive(layout.drawing()).shape().center(),
|
pos: node.primitive(layout.drawing()).shape().center(),
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
|
|
@ -125,8 +125,8 @@ impl Ratsnest {
|
||||||
triangulations
|
triangulations
|
||||||
.get_mut(&(layer, net))
|
.get_mut(&(layer, net))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.add_vertex(VertexWeight {
|
.add_vertex(RatvertexWeight {
|
||||||
vertex: RatsnestVertexIndex::Zone(zone),
|
vertex: RatvertexIndex::Zone(zone),
|
||||||
pos: layout.zone(zone).shape().center(),
|
pos: layout.zone(zone).shape().center(),
|
||||||
})?
|
})?
|
||||||
}
|
}
|
||||||
|
|
@ -154,8 +154,16 @@ impl Ratsnest {
|
||||||
|
|
||||||
this.graph.retain_edges(|g, i| {
|
this.graph.retain_edges(|g, i| {
|
||||||
if let Some((source, target)) = g.edge_endpoints(i) {
|
if let Some((source, target)) = g.edge_endpoints(i) {
|
||||||
let source_index = g.node_weight(source).unwrap().vertex_index().node_index();
|
let source_index = g
|
||||||
let target_index = g.node_weight(target).unwrap().vertex_index().node_index();
|
.node_weight(source)
|
||||||
|
.unwrap()
|
||||||
|
.trianvertex_index()
|
||||||
|
.node_index();
|
||||||
|
let target_index = g
|
||||||
|
.node_weight(target)
|
||||||
|
.unwrap()
|
||||||
|
.trianvertex_index()
|
||||||
|
.node_index();
|
||||||
!unionfind.equiv(source_index, target_index)
|
!unionfind.equiv(source_index, target_index)
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
|
|
@ -169,7 +177,7 @@ impl Ratsnest {
|
||||||
self.graph.edge_weight_mut(ratline).unwrap().band = Some(band);
|
self.graph.edge_weight_mut(ratline).unwrap().band = Some(band);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn graph(&self) -> &UnGraph<VertexWeight, EdgeWeight, usize> {
|
pub fn graph(&self) -> &UnGraph<RatvertexWeight, RatlineWeight, usize> {
|
||||||
&self.graph
|
&self.graph
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ use topola::{
|
||||||
math::Circle,
|
math::Circle,
|
||||||
router::{
|
router::{
|
||||||
draw::DrawException,
|
draw::DrawException,
|
||||||
navmesh::{Navmesh, NavmeshEdgeReference, VertexIndex},
|
navmesh::{Navmesh, NavmeshEdgeReference, NavvertexIndex},
|
||||||
tracer::{Trace, Tracer},
|
tracer::{Trace, Tracer},
|
||||||
EmptyRouterObserver, RouterObserverTrait,
|
EmptyRouterObserver, RouterObserverTrait,
|
||||||
},
|
},
|
||||||
|
|
@ -46,7 +46,7 @@ struct SharedData {
|
||||||
pub from: Option<FixedDotIndex>,
|
pub from: Option<FixedDotIndex>,
|
||||||
pub to: Option<FixedDotIndex>,
|
pub to: Option<FixedDotIndex>,
|
||||||
pub navmesh: Option<Navmesh>,
|
pub navmesh: Option<Navmesh>,
|
||||||
pub path: Vec<VertexIndex>,
|
pub path: Vec<NavvertexIndex>,
|
||||||
pub ghosts: Vec<PrimitiveShape>,
|
pub ghosts: Vec<PrimitiveShape>,
|
||||||
pub highlighteds: Vec<PrimitiveIndex>,
|
pub highlighteds: Vec<PrimitiveIndex>,
|
||||||
}
|
}
|
||||||
|
|
@ -144,7 +144,7 @@ impl<R: RulesTrait + std::fmt::Debug> RouterObserverTrait<R> for DebugRouterObse
|
||||||
shared_data.highlighteds = highlighteds;
|
shared_data.highlighteds = highlighteds;
|
||||||
std::thread::sleep_ms(delay);
|
std::thread::sleep_ms(delay);
|
||||||
}
|
}
|
||||||
fn on_estimate(&mut self, _tracer: &Tracer<R>, _vertex: VertexIndex) {
|
fn on_estimate(&mut self, _tracer: &Tracer<R>, _vertex: NavvertexIndex) {
|
||||||
//dbg!(_tracer, _vertex);
|
//dbg!(_tracer, _vertex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ use topola::geometry::shape::ShapeTrait;
|
||||||
use topola::layout::zone::MakePolyShape;
|
use topola::layout::zone::MakePolyShape;
|
||||||
use topola::layout::Layout;
|
use topola::layout::Layout;
|
||||||
use topola::router::draw::DrawException;
|
use topola::router::draw::DrawException;
|
||||||
use topola::router::navmesh::{Navmesh, NavmeshEdgeReference, VertexIndex};
|
use topola::router::navmesh::{Navmesh, NavmeshEdgeReference, NavvertexIndex};
|
||||||
use topola::router::tracer::{Trace, Tracer};
|
use topola::router::tracer::{Trace, Tracer};
|
||||||
use topola::router::RouterObserverTrait;
|
use topola::router::RouterObserverTrait;
|
||||||
|
|
||||||
|
|
@ -185,7 +185,7 @@ impl<'a, R: RulesTrait> RouterObserverTrait<R> for DebugRouterObserver<'a> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_estimate(&mut self, _tracer: &Tracer<R>, _vertex: VertexIndex) {}
|
fn on_estimate(&mut self, _tracer: &Tracer<R>, _vertex: NavvertexIndex) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<(), anyhow::Error> {
|
fn main() -> Result<(), anyhow::Error> {
|
||||||
|
|
@ -353,7 +353,7 @@ fn render_times(
|
||||||
mut router_or_layout: RouterOrLayout<impl RulesTrait>,
|
mut router_or_layout: RouterOrLayout<impl RulesTrait>,
|
||||||
_unused: Option<()>,
|
_unused: Option<()>,
|
||||||
mut maybe_navmesh: Option<Navmesh>,
|
mut maybe_navmesh: Option<Navmesh>,
|
||||||
path: &[VertexIndex],
|
path: &[NavvertexIndex],
|
||||||
ghosts: &[PrimitiveShape],
|
ghosts: &[PrimitiveShape],
|
||||||
highlighteds: &[PrimitiveIndex],
|
highlighteds: &[PrimitiveIndex],
|
||||||
times: i64,
|
times: i64,
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,12 @@ use crate::{
|
||||||
},
|
},
|
||||||
graph::GetNodeIndex,
|
graph::GetNodeIndex,
|
||||||
layout::Layout,
|
layout::Layout,
|
||||||
triangulation::{GetVertexIndex, Triangulation, TriangulationEdgeReference},
|
triangulation::{GetTrianvertexIndex, Triangulation, TriangulationEdgeReference},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[enum_dispatch(GetNodeIndex, MakePrimitive)]
|
#[enum_dispatch(GetNodeIndex, MakePrimitive)]
|
||||||
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum VertexIndex {
|
pub enum NavvertexIndex {
|
||||||
FixedDot(FixedDotIndex),
|
FixedDot(FixedDotIndex),
|
||||||
FixedBend(FixedBendIndex),
|
FixedBend(FixedBendIndex),
|
||||||
LooseBend(LooseBendIndex),
|
LooseBend(LooseBendIndex),
|
||||||
|
|
@ -34,44 +34,44 @@ pub enum VertexIndex {
|
||||||
|
|
||||||
#[enum_dispatch(GetNodeIndex, MakePrimitive)]
|
#[enum_dispatch(GetNodeIndex, MakePrimitive)]
|
||||||
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq)]
|
||||||
enum TriangulationVertexIndex {
|
enum TrianvertexIndex {
|
||||||
FixedDot(FixedDotIndex),
|
FixedDot(FixedDotIndex),
|
||||||
FixedBend(FixedBendIndex),
|
FixedBend(FixedBendIndex),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<VertexIndex> for PrimitiveIndex {
|
impl From<NavvertexIndex> for PrimitiveIndex {
|
||||||
fn from(vertex: VertexIndex) -> Self {
|
fn from(vertex: NavvertexIndex) -> Self {
|
||||||
match vertex {
|
match vertex {
|
||||||
VertexIndex::FixedDot(dot) => PrimitiveIndex::FixedDot(dot),
|
NavvertexIndex::FixedDot(dot) => PrimitiveIndex::FixedDot(dot),
|
||||||
VertexIndex::FixedBend(bend) => PrimitiveIndex::FixedBend(bend),
|
NavvertexIndex::FixedBend(bend) => PrimitiveIndex::FixedBend(bend),
|
||||||
VertexIndex::LooseBend(bend) => PrimitiveIndex::LooseBend(bend),
|
NavvertexIndex::LooseBend(bend) => PrimitiveIndex::LooseBend(bend),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<TriangulationVertexIndex> for VertexIndex {
|
impl From<TrianvertexIndex> for NavvertexIndex {
|
||||||
fn from(vertex: TriangulationVertexIndex) -> Self {
|
fn from(vertex: TrianvertexIndex) -> Self {
|
||||||
match vertex {
|
match vertex {
|
||||||
TriangulationVertexIndex::FixedDot(dot) => VertexIndex::FixedDot(dot),
|
TrianvertexIndex::FixedDot(dot) => NavvertexIndex::FixedDot(dot),
|
||||||
TriangulationVertexIndex::FixedBend(bend) => VertexIndex::FixedBend(bend),
|
TrianvertexIndex::FixedBend(bend) => NavvertexIndex::FixedBend(bend),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct TriangulationVertexWeight {
|
struct TrianvertexWeight {
|
||||||
vertex: TriangulationVertexIndex,
|
trianvertex: TrianvertexIndex,
|
||||||
rails: Vec<LooseBendIndex>,
|
rails: Vec<LooseBendIndex>,
|
||||||
pos: Point,
|
pos: Point,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetVertexIndex<TriangulationVertexIndex> for TriangulationVertexWeight {
|
impl GetTrianvertexIndex<TrianvertexIndex> for TrianvertexWeight {
|
||||||
fn vertex_index(&self) -> TriangulationVertexIndex {
|
fn trianvertex_index(&self) -> TrianvertexIndex {
|
||||||
self.vertex
|
self.trianvertex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasPosition for TriangulationVertexWeight {
|
impl HasPosition for TrianvertexWeight {
|
||||||
type Scalar = f64;
|
type Scalar = f64;
|
||||||
fn position(&self) -> Point2<Self::Scalar> {
|
fn position(&self) -> Point2<Self::Scalar> {
|
||||||
Point2::new(self.pos.x(), self.pos.y())
|
Point2::new(self.pos.x(), self.pos.y())
|
||||||
|
|
@ -80,8 +80,8 @@ impl HasPosition for TriangulationVertexWeight {
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Navmesh {
|
pub struct Navmesh {
|
||||||
triangulation: Triangulation<TriangulationVertexIndex, TriangulationVertexWeight, ()>,
|
triangulation: Triangulation<TrianvertexIndex, TrianvertexWeight, ()>,
|
||||||
vertex_to_triangulation_vertex: Vec<Option<TriangulationVertexIndex>>,
|
navvertex_to_trianvertex: Vec<Option<TrianvertexIndex>>,
|
||||||
from: FixedDotIndex,
|
from: FixedDotIndex,
|
||||||
to: FixedDotIndex,
|
to: FixedDotIndex,
|
||||||
}
|
}
|
||||||
|
|
@ -100,11 +100,11 @@ impl Navmesh {
|
||||||
) -> Result<Self, NavmeshError> {
|
) -> Result<Self, NavmeshError> {
|
||||||
let mut this = Self {
|
let mut this = Self {
|
||||||
triangulation: Triangulation::new(layout.drawing().geometry().graph().node_bound()),
|
triangulation: Triangulation::new(layout.drawing().geometry().graph().node_bound()),
|
||||||
vertex_to_triangulation_vertex: Vec::new(),
|
navvertex_to_trianvertex: Vec::new(),
|
||||||
from,
|
from,
|
||||||
to,
|
to,
|
||||||
};
|
};
|
||||||
this.vertex_to_triangulation_vertex
|
this.navvertex_to_trianvertex
|
||||||
.resize(layout.drawing().geometry().graph().node_bound(), None);
|
.resize(layout.drawing().geometry().graph().node_bound(), None);
|
||||||
|
|
||||||
let layer = layout.drawing().primitive(from).layer();
|
let layer = layout.drawing().primitive(from).layer();
|
||||||
|
|
@ -117,15 +117,15 @@ impl Navmesh {
|
||||||
if node == from.into() || node == to.into() || Some(primitive_net) != maybe_net {
|
if node == from.into() || node == to.into() || Some(primitive_net) != maybe_net {
|
||||||
match node {
|
match node {
|
||||||
PrimitiveIndex::FixedDot(dot) => {
|
PrimitiveIndex::FixedDot(dot) => {
|
||||||
this.triangulation.add_vertex(TriangulationVertexWeight {
|
this.triangulation.add_vertex(TrianvertexWeight {
|
||||||
vertex: dot.into(),
|
trianvertex: dot.into(),
|
||||||
rails: vec![],
|
rails: vec![],
|
||||||
pos: primitive.shape().center(),
|
pos: primitive.shape().center(),
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
PrimitiveIndex::FixedBend(bend) => {
|
PrimitiveIndex::FixedBend(bend) => {
|
||||||
this.triangulation.add_vertex(TriangulationVertexWeight {
|
this.triangulation.add_vertex(TrianvertexWeight {
|
||||||
vertex: bend.into(),
|
trianvertex: bend.into(),
|
||||||
rails: vec![],
|
rails: vec![],
|
||||||
pos: primitive.shape().center(),
|
pos: primitive.shape().center(),
|
||||||
})?;
|
})?;
|
||||||
|
|
@ -144,7 +144,7 @@ impl Navmesh {
|
||||||
.weight_mut(layout.drawing().primitive(bend).core().into())
|
.weight_mut(layout.drawing().primitive(bend).core().into())
|
||||||
.rails
|
.rails
|
||||||
.push(bend.into());
|
.push(bend.into());
|
||||||
this.vertex_to_triangulation_vertex[bend.node_index().index()] =
|
this.navvertex_to_trianvertex[bend.node_index().index()] =
|
||||||
Some(layout.drawing().primitive(bend).core().into());
|
Some(layout.drawing().primitive(bend).core().into());
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
|
|
@ -154,12 +154,12 @@ impl Navmesh {
|
||||||
Ok(this)
|
Ok(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn triangulation_vertex(&self, vertex: VertexIndex) -> TriangulationVertexIndex {
|
fn triangulation_vertex(&self, vertex: NavvertexIndex) -> TrianvertexIndex {
|
||||||
match vertex {
|
match vertex {
|
||||||
VertexIndex::FixedDot(dot) => TriangulationVertexIndex::FixedDot(dot),
|
NavvertexIndex::FixedDot(dot) => TrianvertexIndex::FixedDot(dot),
|
||||||
VertexIndex::FixedBend(bend) => TriangulationVertexIndex::FixedBend(bend),
|
NavvertexIndex::FixedBend(bend) => TrianvertexIndex::FixedBend(bend),
|
||||||
VertexIndex::LooseBend(bend) => {
|
NavvertexIndex::LooseBend(bend) => {
|
||||||
self.vertex_to_triangulation_vertex[bend.node_index().index()].unwrap()
|
self.navvertex_to_trianvertex[bend.node_index().index()].unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -174,8 +174,8 @@ impl Navmesh {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl visit::GraphBase for Navmesh {
|
impl visit::GraphBase for Navmesh {
|
||||||
type NodeId = VertexIndex;
|
type NodeId = NavvertexIndex;
|
||||||
type EdgeId = (VertexIndex, VertexIndex);
|
type EdgeId = (NavvertexIndex, NavvertexIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl visit::Data for Navmesh {
|
impl visit::Data for Navmesh {
|
||||||
|
|
@ -185,13 +185,13 @@ impl visit::Data for Navmesh {
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct NavmeshEdgeReference {
|
pub struct NavmeshEdgeReference {
|
||||||
from: VertexIndex,
|
from: NavvertexIndex,
|
||||||
to: VertexIndex,
|
to: NavvertexIndex,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl visit::EdgeRef for NavmeshEdgeReference {
|
impl visit::EdgeRef for NavmeshEdgeReference {
|
||||||
type NodeId = VertexIndex;
|
type NodeId = NavvertexIndex;
|
||||||
type EdgeId = (VertexIndex, VertexIndex);
|
type EdgeId = (NavvertexIndex, NavvertexIndex);
|
||||||
type Weight = ();
|
type Weight = ();
|
||||||
|
|
||||||
fn source(&self) -> Self::NodeId {
|
fn source(&self) -> Self::NodeId {
|
||||||
|
|
@ -212,7 +212,7 @@ impl visit::EdgeRef for NavmeshEdgeReference {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> visit::IntoNeighbors for &'a Navmesh {
|
impl<'a> visit::IntoNeighbors for &'a Navmesh {
|
||||||
type Neighbors = Box<dyn Iterator<Item = VertexIndex> + 'a>;
|
type Neighbors = Box<dyn Iterator<Item = NavvertexIndex> + 'a>;
|
||||||
|
|
||||||
fn neighbors(self, vertex: Self::NodeId) -> Self::Neighbors {
|
fn neighbors(self, vertex: Self::NodeId) -> Self::Neighbors {
|
||||||
Box::new(
|
Box::new(
|
||||||
|
|
@ -224,7 +224,7 @@ impl<'a> visit::IntoNeighbors for &'a Navmesh {
|
||||||
.weight(neighbor)
|
.weight(neighbor)
|
||||||
.rails
|
.rails
|
||||||
.iter()
|
.iter()
|
||||||
.map(|index| VertexIndex::from(*index)),
|
.map(|index| NavvertexIndex::from(*index)),
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
@ -232,8 +232,8 @@ impl<'a> visit::IntoNeighbors for &'a Navmesh {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn edge_with_near_edges(
|
fn edge_with_near_edges(
|
||||||
triangulation: &Triangulation<TriangulationVertexIndex, TriangulationVertexWeight, ()>,
|
triangulation: &Triangulation<TrianvertexIndex, TrianvertexWeight, ()>,
|
||||||
edge: TriangulationEdgeReference<TriangulationVertexIndex, ()>,
|
edge: TriangulationEdgeReference<TrianvertexIndex, ()>,
|
||||||
) -> impl Iterator<Item = NavmeshEdgeReference> {
|
) -> impl Iterator<Item = NavmeshEdgeReference> {
|
||||||
let mut from_vertices = vec![edge.source().into()];
|
let mut from_vertices = vec![edge.source().into()];
|
||||||
|
|
||||||
|
|
@ -243,7 +243,7 @@ fn edge_with_near_edges(
|
||||||
.weight(edge.source())
|
.weight(edge.source())
|
||||||
.rails
|
.rails
|
||||||
.iter()
|
.iter()
|
||||||
.map(|bend| VertexIndex::from(*bend)),
|
.map(|bend| NavvertexIndex::from(*bend)),
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut to_vertices = vec![edge.target().into()];
|
let mut to_vertices = vec![edge.target().into()];
|
||||||
|
|
@ -254,7 +254,7 @@ fn edge_with_near_edges(
|
||||||
.weight(edge.target())
|
.weight(edge.target())
|
||||||
.rails
|
.rails
|
||||||
.iter()
|
.iter()
|
||||||
.map(|bend| VertexIndex::from(*bend)),
|
.map(|bend| NavvertexIndex::from(*bend)),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Return cartesian product.
|
// Return cartesian product.
|
||||||
|
|
@ -281,9 +281,9 @@ impl<'a> visit::IntoEdgeReferences for &'a Navmesh {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vertex_edges(
|
fn vertex_edges(
|
||||||
triangulation: &Triangulation<TriangulationVertexIndex, TriangulationVertexWeight, ()>,
|
triangulation: &Triangulation<TrianvertexIndex, TrianvertexWeight, ()>,
|
||||||
from: VertexIndex,
|
from: NavvertexIndex,
|
||||||
to: TriangulationVertexIndex,
|
to: TrianvertexIndex,
|
||||||
) -> impl Iterator<Item = NavmeshEdgeReference> {
|
) -> impl Iterator<Item = NavmeshEdgeReference> {
|
||||||
let from_vertices = vec![from];
|
let from_vertices = vec![from];
|
||||||
let mut to_vertices = vec![to.into()];
|
let mut to_vertices = vec![to.into()];
|
||||||
|
|
@ -294,7 +294,7 @@ fn vertex_edges(
|
||||||
.weight(to)
|
.weight(to)
|
||||||
.rails
|
.rails
|
||||||
.iter()
|
.iter()
|
||||||
.map(|bend| VertexIndex::from(*bend)),
|
.map(|bend| NavvertexIndex::from(*bend)),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Return cartesian product.
|
// Return cartesian product.
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ use crate::{
|
||||||
router::{
|
router::{
|
||||||
astar::{astar, AstarError, AstarStrategy, PathTracker},
|
astar::{astar, AstarError, AstarStrategy, PathTracker},
|
||||||
draw::DrawException,
|
draw::DrawException,
|
||||||
navmesh::{Navmesh, NavmeshEdgeReference, NavmeshError, VertexIndex},
|
navmesh::{Navmesh, NavmeshEdgeReference, NavmeshError, NavvertexIndex},
|
||||||
tracer::{Trace, Tracer},
|
tracer::{Trace, Tracer},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -42,7 +42,7 @@ pub trait RouterObserverTrait<R: RulesTrait> {
|
||||||
edge: NavmeshEdgeReference,
|
edge: NavmeshEdgeReference,
|
||||||
result: Result<(), DrawException>,
|
result: Result<(), DrawException>,
|
||||||
);
|
);
|
||||||
fn on_estimate(&mut self, tracer: &Tracer<R>, vertex: VertexIndex);
|
fn on_estimate(&mut self, tracer: &Tracer<R>, vertex: NavvertexIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct EmptyRouterObserver;
|
pub struct EmptyRouterObserver;
|
||||||
|
|
@ -58,7 +58,7 @@ impl<R: RulesTrait> RouterObserverTrait<R> for EmptyRouterObserver {
|
||||||
_result: Result<(), DrawException>,
|
_result: Result<(), DrawException>,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
fn on_estimate(&mut self, _tracer: &Tracer<R>, _vertex: VertexIndex) {}
|
fn on_estimate(&mut self, _tracer: &Tracer<R>, _vertex: NavvertexIndex) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Router<'a, R: RulesTrait> {
|
pub struct Router<'a, R: RulesTrait> {
|
||||||
|
|
@ -94,7 +94,7 @@ impl<'a, RO: RouterObserverTrait<R>, R: RulesTrait> AstarStrategy<&Navmesh, f64,
|
||||||
{
|
{
|
||||||
fn is_goal(
|
fn is_goal(
|
||||||
&mut self,
|
&mut self,
|
||||||
vertex: VertexIndex,
|
vertex: NavvertexIndex,
|
||||||
tracker: &PathTracker<&Navmesh>,
|
tracker: &PathTracker<&Navmesh>,
|
||||||
) -> Option<BandIndex> {
|
) -> Option<BandIndex> {
|
||||||
let new_path = tracker.reconstruct_path_to(vertex);
|
let new_path = tracker.reconstruct_path_to(vertex);
|
||||||
|
|
@ -131,7 +131,7 @@ impl<'a, RO: RouterObserverTrait<R>, R: RulesTrait> AstarStrategy<&Navmesh, f64,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn estimate_cost(&mut self, vertex: VertexIndex) -> f64 {
|
fn estimate_cost(&mut self, vertex: NavvertexIndex) -> f64 {
|
||||||
self.observer.on_estimate(&self.tracer, vertex);
|
self.observer.on_estimate(&self.tracer, vertex);
|
||||||
|
|
||||||
let start_point = PrimitiveIndex::from(vertex)
|
let start_point = PrimitiveIndex::from(vertex)
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,13 @@ use crate::{
|
||||||
layout::Layout,
|
layout::Layout,
|
||||||
router::{
|
router::{
|
||||||
draw::{Draw, DrawException},
|
draw::{Draw, DrawException},
|
||||||
navmesh::{Navmesh, VertexIndex},
|
navmesh::{Navmesh, NavvertexIndex},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Trace {
|
pub struct Trace {
|
||||||
pub path: Vec<VertexIndex>,
|
pub path: Vec<NavvertexIndex>,
|
||||||
pub head: Head,
|
pub head: Head,
|
||||||
pub width: f64,
|
pub width: f64,
|
||||||
}
|
}
|
||||||
|
|
@ -55,7 +55,7 @@ impl<'a, R: RulesTrait> Tracer<'a, R> {
|
||||||
pub fn rework_path(
|
pub fn rework_path(
|
||||||
&mut self,
|
&mut self,
|
||||||
trace: &mut Trace,
|
trace: &mut Trace,
|
||||||
path: &[VertexIndex],
|
path: &[NavvertexIndex],
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<(), DrawException> {
|
) -> Result<(), DrawException> {
|
||||||
let prefix_length = trace
|
let prefix_length = trace
|
||||||
|
|
@ -74,7 +74,7 @@ impl<'a, R: RulesTrait> Tracer<'a, R> {
|
||||||
pub fn path(
|
pub fn path(
|
||||||
&mut self,
|
&mut self,
|
||||||
trace: &mut Trace,
|
trace: &mut Trace,
|
||||||
path: &[VertexIndex],
|
path: &[NavvertexIndex],
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<(), DrawException> {
|
) -> Result<(), DrawException> {
|
||||||
for (i, vertex) in path.iter().enumerate() {
|
for (i, vertex) in path.iter().enumerate() {
|
||||||
|
|
@ -99,7 +99,7 @@ impl<'a, R: RulesTrait> Tracer<'a, R> {
|
||||||
pub fn step(
|
pub fn step(
|
||||||
&mut self,
|
&mut self,
|
||||||
trace: &mut Trace,
|
trace: &mut Trace,
|
||||||
to: VertexIndex,
|
to: NavvertexIndex,
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<(), DrawException> {
|
) -> Result<(), DrawException> {
|
||||||
trace.head = self.wrap(trace.head, to, width)?.into();
|
trace.head = self.wrap(trace.head, to, width)?.into();
|
||||||
|
|
@ -111,13 +111,13 @@ impl<'a, R: RulesTrait> Tracer<'a, R> {
|
||||||
fn wrap(
|
fn wrap(
|
||||||
&mut self,
|
&mut self,
|
||||||
head: Head,
|
head: Head,
|
||||||
around: VertexIndex,
|
around: NavvertexIndex,
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<SegbendHead, DrawException> {
|
) -> Result<SegbendHead, DrawException> {
|
||||||
match around {
|
match around {
|
||||||
VertexIndex::FixedDot(dot) => self.wrap_around_fixed_dot(head, dot, width),
|
NavvertexIndex::FixedDot(dot) => self.wrap_around_fixed_dot(head, dot, width),
|
||||||
VertexIndex::FixedBend(_fixed_bend) => todo!(),
|
NavvertexIndex::FixedBend(_fixed_bend) => todo!(),
|
||||||
VertexIndex::LooseBend(loose_bend) => {
|
NavvertexIndex::LooseBend(loose_bend) => {
|
||||||
self.wrap_around_loose_bend(head, loose_bend, width)
|
self.wrap_around_loose_bend(head, loose_bend, width)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,40 +6,40 @@ use spade::{handles::FixedVertexHandle, DelaunayTriangulation, HasPosition, Inse
|
||||||
|
|
||||||
use crate::graph::GetNodeIndex;
|
use crate::graph::GetNodeIndex;
|
||||||
|
|
||||||
pub trait GetVertexIndex<I> {
|
pub trait GetTrianvertexIndex<I> {
|
||||||
fn vertex_index(&self) -> I;
|
fn trianvertex_index(&self) -> I;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Triangulation<
|
pub struct Triangulation<
|
||||||
I: Copy + PartialEq + GetNodeIndex,
|
I: Copy + PartialEq + GetNodeIndex,
|
||||||
VW: GetVertexIndex<I> + HasPosition,
|
VW: GetTrianvertexIndex<I> + HasPosition,
|
||||||
EW: Copy + Default,
|
EW: Copy + Default,
|
||||||
> {
|
> {
|
||||||
triangulation: DelaunayTriangulation<VW, EW>,
|
triangulation: DelaunayTriangulation<VW, EW>,
|
||||||
vertex_to_handle: Vec<Option<FixedVertexHandle>>,
|
trianvertex_to_handle: Vec<Option<FixedVertexHandle>>,
|
||||||
index_marker: PhantomData<I>,
|
index_marker: PhantomData<I>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<
|
impl<
|
||||||
I: Copy + PartialEq + GetNodeIndex,
|
I: Copy + PartialEq + GetNodeIndex,
|
||||||
VW: GetVertexIndex<I> + HasPosition<Scalar = f64>,
|
VW: GetTrianvertexIndex<I> + HasPosition<Scalar = f64>,
|
||||||
EW: Copy + Default,
|
EW: Copy + Default,
|
||||||
> Triangulation<I, VW, EW>
|
> Triangulation<I, VW, EW>
|
||||||
{
|
{
|
||||||
pub fn new(node_bound: usize) -> Self {
|
pub fn new(node_bound: usize) -> Self {
|
||||||
let mut this = Self {
|
let mut this = Self {
|
||||||
triangulation: <DelaunayTriangulation<VW, EW> as spade::Triangulation>::new(),
|
triangulation: <DelaunayTriangulation<VW, EW> as spade::Triangulation>::new(),
|
||||||
vertex_to_handle: Vec::new(),
|
trianvertex_to_handle: Vec::new(),
|
||||||
index_marker: PhantomData,
|
index_marker: PhantomData,
|
||||||
};
|
};
|
||||||
this.vertex_to_handle.resize(node_bound, None);
|
this.trianvertex_to_handle.resize(node_bound, None);
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_vertex(&mut self, weight: VW) -> Result<(), InsertionError> {
|
pub fn add_vertex(&mut self, weight: VW) -> Result<(), InsertionError> {
|
||||||
let index = weight.vertex_index().node_index().index();
|
let index = weight.trianvertex_index().node_index().index();
|
||||||
self.vertex_to_handle[index] = Some(spade::Triangulation::insert(
|
self.trianvertex_to_handle[index] = Some(spade::Triangulation::insert(
|
||||||
&mut self.triangulation,
|
&mut self.triangulation,
|
||||||
weight,
|
weight,
|
||||||
)?);
|
)?);
|
||||||
|
|
@ -48,13 +48,13 @@ impl<
|
||||||
|
|
||||||
pub fn weight(&self, vertex: I) -> &VW {
|
pub fn weight(&self, vertex: I) -> &VW {
|
||||||
spade::Triangulation::s(&self.triangulation)
|
spade::Triangulation::s(&self.triangulation)
|
||||||
.vertex_data(self.vertex_to_handle[vertex.node_index().index()].unwrap())
|
.vertex_data(self.trianvertex_to_handle[vertex.node_index().index()].unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn weight_mut(&mut self, vertex: I) -> &mut VW {
|
pub fn weight_mut(&mut self, vertex: I) -> &mut VW {
|
||||||
spade::Triangulation::vertex_data_mut(
|
spade::Triangulation::vertex_data_mut(
|
||||||
&mut self.triangulation,
|
&mut self.triangulation,
|
||||||
self.vertex_to_handle[vertex.node_index().index()].unwrap(),
|
self.trianvertex_to_handle[vertex.node_index().index()].unwrap(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,17 +67,17 @@ impl<
|
||||||
fn vertex(&self, handle: FixedVertexHandle) -> I {
|
fn vertex(&self, handle: FixedVertexHandle) -> I {
|
||||||
spade::Triangulation::vertex(&self.triangulation, handle)
|
spade::Triangulation::vertex(&self.triangulation, handle)
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.vertex_index()
|
.trianvertex_index()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle(&self, vertex: I) -> FixedVertexHandle {
|
fn handle(&self, vertex: I) -> FixedVertexHandle {
|
||||||
self.vertex_to_handle[vertex.node_index().index()].unwrap()
|
self.trianvertex_to_handle[vertex.node_index().index()].unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<
|
impl<
|
||||||
I: Copy + PartialEq + GetNodeIndex,
|
I: Copy + PartialEq + GetNodeIndex,
|
||||||
VW: GetVertexIndex<I> + HasPosition<Scalar = f64>,
|
VW: GetTrianvertexIndex<I> + HasPosition<Scalar = f64>,
|
||||||
EW: Copy + Default,
|
EW: Copy + Default,
|
||||||
> visit::GraphBase for Triangulation<I, VW, EW>
|
> visit::GraphBase for Triangulation<I, VW, EW>
|
||||||
{
|
{
|
||||||
|
|
@ -105,7 +105,7 @@ impl<EW: Copy + Default> PartialOrd for TriangulationEdgeWeightWrapper<EW> {
|
||||||
|
|
||||||
impl<
|
impl<
|
||||||
I: Copy + PartialEq + GetNodeIndex,
|
I: Copy + PartialEq + GetNodeIndex,
|
||||||
VW: GetVertexIndex<I> + HasPosition<Scalar = f64>,
|
VW: GetTrianvertexIndex<I> + HasPosition<Scalar = f64>,
|
||||||
EW: Copy + Default,
|
EW: Copy + Default,
|
||||||
> visit::Data for Triangulation<I, VW, EW>
|
> visit::Data for Triangulation<I, VW, EW>
|
||||||
{
|
{
|
||||||
|
|
@ -145,7 +145,7 @@ impl<I: Copy, EW: Copy + Default> visit::EdgeRef for TriangulationEdgeReference<
|
||||||
impl<
|
impl<
|
||||||
'a,
|
'a,
|
||||||
I: Copy + PartialEq + GetNodeIndex,
|
I: Copy + PartialEq + GetNodeIndex,
|
||||||
VW: GetVertexIndex<I> + HasPosition<Scalar = f64>,
|
VW: GetTrianvertexIndex<I> + HasPosition<Scalar = f64>,
|
||||||
EW: Copy + Default,
|
EW: Copy + Default,
|
||||||
> visit::IntoNeighbors for &'a Triangulation<I, VW, EW>
|
> visit::IntoNeighbors for &'a Triangulation<I, VW, EW>
|
||||||
{
|
{
|
||||||
|
|
@ -163,7 +163,7 @@ impl<
|
||||||
impl<
|
impl<
|
||||||
'a,
|
'a,
|
||||||
I: Copy + PartialEq + GetNodeIndex,
|
I: Copy + PartialEq + GetNodeIndex,
|
||||||
VW: GetVertexIndex<I> + HasPosition<Scalar = f64>,
|
VW: GetTrianvertexIndex<I> + HasPosition<Scalar = f64>,
|
||||||
EW: Copy + Default,
|
EW: Copy + Default,
|
||||||
> visit::IntoEdgeReferences for &'a Triangulation<I, VW, EW>
|
> visit::IntoEdgeReferences for &'a Triangulation<I, VW, EW>
|
||||||
{
|
{
|
||||||
|
|
@ -192,7 +192,7 @@ impl<
|
||||||
impl<
|
impl<
|
||||||
'a,
|
'a,
|
||||||
I: Copy + PartialEq + GetNodeIndex,
|
I: Copy + PartialEq + GetNodeIndex,
|
||||||
VW: GetVertexIndex<I> + HasPosition<Scalar = f64>,
|
VW: GetTrianvertexIndex<I> + HasPosition<Scalar = f64>,
|
||||||
EW: Copy + Default,
|
EW: Copy + Default,
|
||||||
> visit::IntoEdges for &'a Triangulation<I, VW, EW>
|
> visit::IntoEdges for &'a Triangulation<I, VW, EW>
|
||||||
{
|
{
|
||||||
|
|
@ -222,7 +222,7 @@ impl<
|
||||||
impl<
|
impl<
|
||||||
'a,
|
'a,
|
||||||
I: Copy + PartialEq + GetNodeIndex,
|
I: Copy + PartialEq + GetNodeIndex,
|
||||||
VW: GetVertexIndex<I> + HasPosition<Scalar = f64>,
|
VW: GetTrianvertexIndex<I> + HasPosition<Scalar = f64>,
|
||||||
EW: Copy + Default,
|
EW: Copy + Default,
|
||||||
> visit::IntoNodeIdentifiers for &'a Triangulation<I, VW, EW>
|
> visit::IntoNodeIdentifiers for &'a Triangulation<I, VW, EW>
|
||||||
{
|
{
|
||||||
|
|
@ -233,7 +233,7 @@ impl<
|
||||||
spade::Triangulation::fixed_vertices(&self.triangulation).map(|vertex| {
|
spade::Triangulation::fixed_vertices(&self.triangulation).map(|vertex| {
|
||||||
spade::Triangulation::s(&self.triangulation)
|
spade::Triangulation::s(&self.triangulation)
|
||||||
.vertex_data(vertex)
|
.vertex_data(vertex)
|
||||||
.vertex_index()
|
.trianvertex_index()
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -261,7 +261,7 @@ impl<'a, I: Copy, VW: Copy> visit::NodeRef for TriangulationVertexReference<'a,
|
||||||
impl<
|
impl<
|
||||||
'a,
|
'a,
|
||||||
I: Copy + PartialEq + GetNodeIndex,
|
I: Copy + PartialEq + GetNodeIndex,
|
||||||
VW: Copy + GetVertexIndex<I> + HasPosition<Scalar = f64>,
|
VW: Copy + GetTrianvertexIndex<I> + HasPosition<Scalar = f64>,
|
||||||
EW: Copy + Default,
|
EW: Copy + Default,
|
||||||
> visit::IntoNodeReferences for &'a Triangulation<I, VW, EW>
|
> visit::IntoNodeReferences for &'a Triangulation<I, VW, EW>
|
||||||
{
|
{
|
||||||
|
|
@ -273,7 +273,7 @@ impl<
|
||||||
spade::Triangulation::fixed_vertices(&self.triangulation).map(|vertex| {
|
spade::Triangulation::fixed_vertices(&self.triangulation).map(|vertex| {
|
||||||
let weight = spade::Triangulation::s(&self.triangulation).vertex_data(vertex);
|
let weight = spade::Triangulation::s(&self.triangulation).vertex_data(vertex);
|
||||||
TriangulationVertexReference {
|
TriangulationVertexReference {
|
||||||
index: weight.vertex_index(),
|
index: weight.trianvertex_index(),
|
||||||
weight,
|
weight,
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
@ -284,13 +284,13 @@ impl<
|
||||||
impl<
|
impl<
|
||||||
'a,
|
'a,
|
||||||
I: Copy + PartialEq + GetNodeIndex + std::fmt::Debug,
|
I: Copy + PartialEq + GetNodeIndex + std::fmt::Debug,
|
||||||
VW: GetVertexIndex<I> + HasPosition<Scalar = f64>,
|
VW: GetTrianvertexIndex<I> + HasPosition<Scalar = f64>,
|
||||||
EW: Copy + Default,
|
EW: Copy + Default,
|
||||||
> visit::NodeIndexable for &'a Triangulation<I, VW, EW>
|
> visit::NodeIndexable for &'a Triangulation<I, VW, EW>
|
||||||
{
|
{
|
||||||
fn node_bound(&self) -> usize {
|
fn node_bound(&self) -> usize {
|
||||||
//spade::Triangulation::num_vertices(&self.triangulation)
|
//spade::Triangulation::num_vertices(&self.triangulation)
|
||||||
self.vertex_to_handle.len()
|
self.trianvertex_to_handle.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_index(&self, node: I) -> usize {
|
fn to_index(&self, node: I) -> usize {
|
||||||
|
|
@ -299,7 +299,7 @@ impl<
|
||||||
|
|
||||||
fn from_index(&self, index: usize) -> I {
|
fn from_index(&self, index: usize) -> I {
|
||||||
spade::Triangulation::s(&self.triangulation)
|
spade::Triangulation::s(&self.triangulation)
|
||||||
.vertex_data(self.vertex_to_handle[index].unwrap())
|
.vertex_data(self.trianvertex_to_handle[index].unwrap())
|
||||||
.vertex_index()
|
.trianvertex_index()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ use topola::{
|
||||||
dsn::design::DsnDesign,
|
dsn::design::DsnDesign,
|
||||||
graph::GetNodeIndex,
|
graph::GetNodeIndex,
|
||||||
router::EmptyRouterObserver,
|
router::EmptyRouterObserver,
|
||||||
triangulation::GetVertexIndex,
|
triangulation::GetTrianvertexIndex,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -63,7 +63,7 @@ fn test() {
|
||||||
.graph()
|
.graph()
|
||||||
.node_weight(ratline.source())
|
.node_weight(ratline.source())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.vertex_index()
|
.trianvertex_index()
|
||||||
.node_index();
|
.node_index();
|
||||||
let to_index = invoker
|
let to_index = invoker
|
||||||
.autorouter()
|
.autorouter()
|
||||||
|
|
@ -71,7 +71,7 @@ fn test() {
|
||||||
.graph()
|
.graph()
|
||||||
.node_weight(ratline.target())
|
.node_weight(ratline.target())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.vertex_index()
|
.trianvertex_index()
|
||||||
.node_index();
|
.node_index();
|
||||||
assert_eq!(unionfind.find(from_index), unionfind.find(to_index));
|
assert_eq!(unionfind.find(from_index), unionfind.find(to_index));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use topola::{
|
||||||
drawing::graph::GetMaybeNet,
|
drawing::graph::GetMaybeNet,
|
||||||
dsn::design::DsnDesign,
|
dsn::design::DsnDesign,
|
||||||
graph::GetNodeIndex,
|
graph::GetNodeIndex,
|
||||||
triangulation::GetVertexIndex,
|
triangulation::GetTrianvertexIndex,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use topola::{
|
||||||
drawing::graph::GetMaybeNet,
|
drawing::graph::GetMaybeNet,
|
||||||
dsn::design::DsnDesign,
|
dsn::design::DsnDesign,
|
||||||
graph::GetNodeIndex,
|
graph::GetNodeIndex,
|
||||||
triangulation::GetVertexIndex,
|
triangulation::GetTrianvertexIndex,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue