mirror of https://codeberg.org/topola/topola.git
triangulation: move out and make independent of layout and drawing
This commit is contained in:
parent
51c6eeea1f
commit
47b8616a40
|
|
@ -9,3 +9,4 @@ pub mod layout;
|
||||||
pub mod math;
|
pub mod math;
|
||||||
pub mod overlay;
|
pub mod overlay;
|
||||||
pub mod router;
|
pub mod router;
|
||||||
|
pub mod triangulation;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,5 @@ pub mod draw;
|
||||||
pub mod navmesh;
|
pub mod navmesh;
|
||||||
mod router;
|
mod router;
|
||||||
pub mod tracer;
|
pub mod tracer;
|
||||||
pub mod triangulation;
|
|
||||||
|
|
||||||
pub use router::*;
|
pub use router::*;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ use crate::{
|
||||||
geometry::primitive::PrimitiveShapeTrait,
|
geometry::primitive::PrimitiveShapeTrait,
|
||||||
graph::GetNodeIndex,
|
graph::GetNodeIndex,
|
||||||
layout::Layout,
|
layout::Layout,
|
||||||
router::triangulation::{GetVertexIndex, Triangulation, TriangulationEdgeReference},
|
triangulation::{GetVertexIndex, Triangulation, TriangulationEdgeReference},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[enum_dispatch(GetNodeIndex, MakePrimitive)]
|
#[enum_dispatch(GetNodeIndex, MakePrimitive)]
|
||||||
|
|
@ -85,7 +85,7 @@ pub struct Navmesh {
|
||||||
impl Navmesh {
|
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().geometry().graph().node_bound()),
|
||||||
vertex_to_triangulation_vertex: Vec::new(),
|
vertex_to_triangulation_vertex: Vec::new(),
|
||||||
};
|
};
|
||||||
this.vertex_to_triangulation_vertex
|
this.vertex_to_triangulation_vertex
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,10 @@
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use geo::{point, Point};
|
use geo::{point, Point};
|
||||||
use petgraph::visit::{self, NodeIndexable};
|
use petgraph::visit;
|
||||||
use spade::{
|
use spade::{handles::FixedVertexHandle, DelaunayTriangulation, HasPosition, InsertionError};
|
||||||
handles::FixedVertexHandle, iterators::VertexIterator, DelaunayTriangulation, HasPosition,
|
|
||||||
InsertionError,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::graph::GetNodeIndex;
|
||||||
drawing::{rules::RulesTrait, Drawing},
|
|
||||||
graph::GetNodeIndex,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub trait GetVertexIndex<I> {
|
pub trait GetVertexIndex<I> {
|
||||||
fn vertex(&self) -> I;
|
fn vertex(&self) -> I;
|
||||||
|
|
@ -26,14 +20,13 @@ pub struct Triangulation<I: Copy + PartialEq + GetNodeIndex, W: GetVertexIndex<I
|
||||||
impl<I: Copy + PartialEq + GetNodeIndex, W: GetVertexIndex<I> + HasPosition<Scalar = f64>>
|
impl<I: Copy + PartialEq + GetNodeIndex, W: GetVertexIndex<I> + HasPosition<Scalar = f64>>
|
||||||
Triangulation<I, W>
|
Triangulation<I, W>
|
||||||
{
|
{
|
||||||
pub fn new(drawing: &Drawing<impl Copy, impl RulesTrait>) -> Self {
|
pub fn new(node_bound: usize) -> Self {
|
||||||
let mut this = Self {
|
let mut this = Self {
|
||||||
triangulation: <DelaunayTriangulation<W> as spade::Triangulation>::new(),
|
triangulation: <DelaunayTriangulation<W> as spade::Triangulation>::new(),
|
||||||
vertex_to_handle: Vec::new(),
|
vertex_to_handle: Vec::new(),
|
||||||
index_marker: PhantomData,
|
index_marker: PhantomData,
|
||||||
};
|
};
|
||||||
this.vertex_to_handle
|
this.vertex_to_handle.resize(node_bound, None);
|
||||||
.resize(drawing.geometry().graph().node_bound(), None);
|
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue