mirror of https://codeberg.org/topola/topola.git
geometry: rename geometry submodule to layout, small typing changes
This commit is contained in:
parent
9f42991032
commit
3fe54290c6
|
|
@ -1,11 +1,11 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
connectivity::{BandIndex, BandWeight, ConnectivityWeight, GetNet},
|
connectivity::{BandIndex, BandWeight, ConnectivityWeight, GetNet},
|
||||||
geometry::{
|
graph::GetNodeIndex,
|
||||||
|
layout::Layout,
|
||||||
|
layout::{
|
||||||
dot::{DotIndex, FixedDotIndex},
|
dot::{DotIndex, FixedDotIndex},
|
||||||
geometry::{GeometryIndex, MakePrimitive},
|
geometry::{GeometryIndex, MakePrimitive},
|
||||||
},
|
},
|
||||||
graph::GetNodeIndex,
|
|
||||||
layout::Layout,
|
|
||||||
loose::{GetNextLoose, LooseIndex},
|
loose::{GetNextLoose, LooseIndex},
|
||||||
primitive::{GetEnds, GetOtherEnd, MakeShape},
|
primitive::{GetEnds, GetOtherEnd, MakeShape},
|
||||||
shape::ShapeTrait,
|
shape::ShapeTrait,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use enum_dispatch::enum_dispatch;
|
use enum_dispatch::enum_dispatch;
|
||||||
use petgraph::stable_graph::StableDiGraph;
|
use petgraph::stable_graph::StableDiGraph;
|
||||||
|
|
||||||
use crate::{geometry::dot::FixedDotIndex, graph::GenericIndex};
|
use crate::{graph::GenericIndex, layout::dot::FixedDotIndex};
|
||||||
|
|
||||||
#[enum_dispatch]
|
#[enum_dispatch]
|
||||||
pub trait GetNet {
|
pub trait GetNet {
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,13 @@ use geo::{EuclideanLength, Point};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
geometry::{
|
guide::{Guide, Head, HeadTrait, SegbendHead},
|
||||||
|
layout::{
|
||||||
bend::{BendIndex, LooseBendWeight},
|
bend::{BendIndex, LooseBendWeight},
|
||||||
dot::{DotIndex, FixedDotIndex, LooseDotIndex, LooseDotWeight},
|
dot::{DotIndex, FixedDotIndex, LooseDotIndex, LooseDotWeight},
|
||||||
geometry::{GetBandIndex, MakePrimitive},
|
geometry::{GetBandIndex, MakePrimitive},
|
||||||
seg::{LoneLooseSegWeight, SeqLooseSegWeight},
|
seg::{LoneLooseSegWeight, SeqLooseSegWeight},
|
||||||
},
|
},
|
||||||
guide::{Guide, Head, HeadTrait, SegbendHead},
|
|
||||||
layout::{Infringement, Layout, LayoutException},
|
layout::{Infringement, Layout, LayoutException},
|
||||||
math::{Circle, NoTangents},
|
math::{Circle, NoTangents},
|
||||||
primitive::GetOtherEnd,
|
primitive::GetOtherEnd,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
#[macro_use]
|
|
||||||
pub mod geometry;
|
|
||||||
pub mod bend;
|
|
||||||
pub mod dot;
|
|
||||||
pub mod seg;
|
|
||||||
|
|
@ -8,7 +8,7 @@ use petgraph::stable_graph::NodeIndex;
|
||||||
|
|
||||||
// Due to apparent limitations of enum_dispatch we're forced to import some types backwards.
|
// Due to apparent limitations of enum_dispatch we're forced to import some types backwards.
|
||||||
|
|
||||||
use crate::geometry::{bend::BendIndex, dot::DotIndex, geometry::GeometryIndex, seg::SegIndex};
|
use crate::layout::{bend::BendIndex, dot::DotIndex, geometry::GeometryIndex, seg::SegIndex};
|
||||||
|
|
||||||
#[enum_dispatch]
|
#[enum_dispatch]
|
||||||
pub trait GetNodeIndex {
|
pub trait GetNodeIndex {
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,12 @@ use geo::Line;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
connectivity::BandIndex,
|
connectivity::BandIndex,
|
||||||
geometry::{
|
layout::Layout,
|
||||||
|
layout::{
|
||||||
bend::BendIndex,
|
bend::BendIndex,
|
||||||
dot::{DotIndex, FixedDotIndex, LooseDotIndex},
|
dot::{DotIndex, FixedDotIndex, LooseDotIndex},
|
||||||
geometry::{GetBandIndex, MakePrimitive},
|
geometry::{GetBandIndex, MakePrimitive},
|
||||||
},
|
},
|
||||||
layout::Layout,
|
|
||||||
math::{self, Circle, NoTangents},
|
math::{self, Circle, NoTangents},
|
||||||
primitive::{GetCore, GetInnerOuter, GetOtherEnd, GetWeight, MakeShape},
|
primitive::{GetCore, GetInnerOuter, GetOtherEnd, GetWeight, MakeShape},
|
||||||
rules::{Conditions, Rules},
|
rules::{Conditions, Rules},
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
|
#[macro_use]
|
||||||
|
pub mod geometry;
|
||||||
|
pub mod bend;
|
||||||
|
pub mod dot;
|
||||||
|
pub mod seg;
|
||||||
|
|
||||||
use contracts::{debug_ensures, debug_invariant};
|
use contracts::{debug_ensures, debug_invariant};
|
||||||
use enum_dispatch::enum_dispatch;
|
use enum_dispatch::enum_dispatch;
|
||||||
use geo::Point;
|
use geo::Point;
|
||||||
|
|
@ -13,22 +19,20 @@ use crate::connectivity::{
|
||||||
BandIndex, BandWeight, ComponentIndex, ComponentWeight, ConnectivityGraph, ConnectivityLabel,
|
BandIndex, BandWeight, ComponentIndex, ComponentWeight, ConnectivityGraph, ConnectivityLabel,
|
||||||
ConnectivityWeight, GetNet,
|
ConnectivityWeight, GetNet,
|
||||||
};
|
};
|
||||||
use crate::geometry::geometry::Geometry;
|
use crate::graph::{GenericIndex, GetNodeIndex};
|
||||||
use crate::geometry::seg::SeqLooseSegWeight;
|
use crate::guide::Guide;
|
||||||
use crate::geometry::{
|
use crate::layout::bend::BendIndex;
|
||||||
bend::{BendWeight, FixedBendIndex, LooseBendIndex, LooseBendWeight},
|
use crate::layout::geometry::{BendWeight, DotWeight, Geometry, SegWeight};
|
||||||
dot::{DotIndex, DotWeight, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
|
use crate::layout::seg::{SegIndex, SeqLooseSegWeight};
|
||||||
|
use crate::layout::{
|
||||||
|
bend::{FixedBendIndex, LooseBendIndex, LooseBendWeight},
|
||||||
|
dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
|
||||||
geometry::{
|
geometry::{
|
||||||
GeometryGraph, GeometryIndex, GeometryLabel, GeometryWeight, GetComponentIndex,
|
GeometryGraph, GeometryIndex, GeometryLabel, GeometryWeight, GetComponentIndex,
|
||||||
MakePrimitive, Retag,
|
MakePrimitive, Retag,
|
||||||
},
|
},
|
||||||
seg::{
|
seg::{FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SeqLooseSegIndex},
|
||||||
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegWeight,
|
|
||||||
SeqLooseSegIndex,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
use crate::graph::{GenericIndex, GetNodeIndex};
|
|
||||||
use crate::guide::Guide;
|
|
||||||
use crate::loose::{GetNextLoose, Loose, LooseIndex};
|
use crate::loose::{GetNextLoose, Loose, LooseIndex};
|
||||||
use crate::math::NoTangents;
|
use crate::math::NoTangents;
|
||||||
use crate::primitive::{
|
use crate::primitive::{
|
||||||
|
|
@ -71,7 +75,7 @@ pub struct AlreadyConnected(pub i64, pub GeometryIndex);
|
||||||
pub struct Layout {
|
pub struct Layout {
|
||||||
rtree: RTree<RTreeWrapper>,
|
rtree: RTree<RTreeWrapper>,
|
||||||
connectivity: ConnectivityGraph,
|
connectivity: ConnectivityGraph,
|
||||||
geometry: Geometry,
|
geometry: Geometry<DotIndex, SegIndex, BendIndex>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[debug_invariant(self.geometry.graph().node_count() == self.rtree.size())]
|
#[debug_invariant(self.geometry.graph().node_count() == self.rtree.size())]
|
||||||
|
|
@ -246,7 +250,7 @@ impl Layout {
|
||||||
to: FixedDotIndex,
|
to: FixedDotIndex,
|
||||||
weight: FixedSegWeight,
|
weight: FixedSegWeight,
|
||||||
) -> Result<FixedSegIndex, Infringement> {
|
) -> Result<FixedSegIndex, Infringement> {
|
||||||
self.add_seg_infringably(from, to, weight, &[])
|
self.add_seg_infringably(from.into(), to.into(), weight, &[])
|
||||||
}
|
}
|
||||||
|
|
||||||
#[debug_ensures(ret.is_ok() -> self.geometry.graph().node_count() == old(self.geometry.graph().node_count() + 4))]
|
#[debug_ensures(ret.is_ok() -> self.geometry.graph().node_count() == old(self.geometry.graph().node_count() + 4))]
|
||||||
|
|
@ -518,7 +522,7 @@ impl Layout {
|
||||||
) -> Result<Segbend, LayoutException> {
|
) -> Result<Segbend, LayoutException> {
|
||||||
let seg_to = self.add_dot_infringably(dot_weight, infringables)?;
|
let seg_to = self.add_dot_infringably(dot_weight, infringables)?;
|
||||||
let seg = self
|
let seg = self
|
||||||
.add_seg_infringably(from, seg_to, seg_weight, infringables)
|
.add_seg_infringably(from, seg_to.into(), seg_weight, infringables)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
self.remove(seg_to.into());
|
self.remove(seg_to.into());
|
||||||
err
|
err
|
||||||
|
|
@ -557,7 +561,7 @@ impl Layout {
|
||||||
to: FixedDotIndex,
|
to: FixedDotIndex,
|
||||||
weight: LoneLooseSegWeight,
|
weight: LoneLooseSegWeight,
|
||||||
) -> Result<LoneLooseSegIndex, Infringement> {
|
) -> Result<LoneLooseSegIndex, Infringement> {
|
||||||
let seg = self.add_seg_infringably(from, to, weight, &[])?;
|
let seg = self.add_seg_infringably(from.into(), to.into(), weight, &[])?;
|
||||||
|
|
||||||
self.connectivity.update_edge(
|
self.connectivity.update_edge(
|
||||||
self.primitive(from).component().node_index(),
|
self.primitive(from).component().node_index(),
|
||||||
|
|
@ -583,7 +587,7 @@ impl Layout {
|
||||||
to: LooseDotIndex,
|
to: LooseDotIndex,
|
||||||
weight: SeqLooseSegWeight,
|
weight: SeqLooseSegWeight,
|
||||||
) -> Result<SeqLooseSegIndex, Infringement> {
|
) -> Result<SeqLooseSegIndex, Infringement> {
|
||||||
let seg = self.add_seg_infringably(from, to, weight, &[])?;
|
let seg = self.add_seg_infringably(from, to.into(), weight, &[])?;
|
||||||
|
|
||||||
if let DotIndex::Fixed(dot) = from {
|
if let DotIndex::Fixed(dot) = from {
|
||||||
self.connectivity.update_edge(
|
self.connectivity.update_edge(
|
||||||
|
|
@ -602,8 +606,8 @@ impl Layout {
|
||||||
#[debug_ensures(ret.is_err() -> self.geometry.graph().edge_count() == old(self.geometry.graph().edge_count()))]
|
#[debug_ensures(ret.is_err() -> self.geometry.graph().edge_count() == old(self.geometry.graph().edge_count()))]
|
||||||
fn add_seg_infringably<W: SegWeight>(
|
fn add_seg_infringably<W: SegWeight>(
|
||||||
&mut self,
|
&mut self,
|
||||||
from: impl GetNodeIndex,
|
from: DotIndex,
|
||||||
to: impl GetNodeIndex,
|
to: DotIndex,
|
||||||
weight: W,
|
weight: W,
|
||||||
infringables: &[GeometryIndex],
|
infringables: &[GeometryIndex],
|
||||||
) -> Result<GenericIndex<W>, Infringement>
|
) -> Result<GenericIndex<W>, Infringement>
|
||||||
|
|
@ -662,7 +666,7 @@ impl Layout {
|
||||||
|
|
||||||
match around {
|
match around {
|
||||||
WraparoundableIndex::FixedDot(core) => self
|
WraparoundableIndex::FixedDot(core) => self
|
||||||
.add_core_bend_infringably(from, to, core, weight, infringables)
|
.add_core_bend_infringably(from.into(), to.into(), core, weight, infringables)
|
||||||
.map_err(Into::into),
|
.map_err(Into::into),
|
||||||
WraparoundableIndex::FixedBend(around) => self
|
WraparoundableIndex::FixedBend(around) => self
|
||||||
.add_outer_bend_infringably(from, to, around, weight, infringables)
|
.add_outer_bend_infringably(from, to, around, weight, infringables)
|
||||||
|
|
@ -679,8 +683,8 @@ impl Layout {
|
||||||
#[debug_ensures(ret.is_err() -> self.geometry.graph().edge_count() == old(self.geometry.graph().edge_count()))]
|
#[debug_ensures(ret.is_err() -> self.geometry.graph().edge_count() == old(self.geometry.graph().edge_count()))]
|
||||||
fn add_core_bend_infringably<W: BendWeight>(
|
fn add_core_bend_infringably<W: BendWeight>(
|
||||||
&mut self,
|
&mut self,
|
||||||
from: impl GetNodeIndex,
|
from: DotIndex,
|
||||||
to: impl GetNodeIndex,
|
to: DotIndex,
|
||||||
core: FixedDotIndex,
|
core: FixedDotIndex,
|
||||||
weight: W,
|
weight: W,
|
||||||
infringables: &[GeometryIndex],
|
infringables: &[GeometryIndex],
|
||||||
|
|
@ -688,7 +692,7 @@ impl Layout {
|
||||||
where
|
where
|
||||||
GenericIndex<W>: Into<GeometryIndex> + Copy,
|
GenericIndex<W>: Into<GeometryIndex> + Copy,
|
||||||
{
|
{
|
||||||
let bend = self.geometry.add_bend(from, to, core, weight);
|
let bend = self.geometry.add_bend(from, to, core.into(), weight);
|
||||||
|
|
||||||
self.insert_into_rtree(bend.into());
|
self.insert_into_rtree(bend.into());
|
||||||
self.fail_and_remove_if_infringes_except(bend.into(), infringables)?;
|
self.fail_and_remove_if_infringes_except(bend.into(), infringables)?;
|
||||||
|
|
@ -701,8 +705,8 @@ impl Layout {
|
||||||
#[debug_ensures(ret.is_err() -> self.geometry.graph().edge_count() == old(self.geometry.graph().edge_count()))]
|
#[debug_ensures(ret.is_err() -> self.geometry.graph().edge_count() == old(self.geometry.graph().edge_count()))]
|
||||||
fn add_outer_bend_infringably<W: BendWeight>(
|
fn add_outer_bend_infringably<W: BendWeight>(
|
||||||
&mut self,
|
&mut self,
|
||||||
from: impl GetNodeIndex,
|
from: LooseDotIndex,
|
||||||
to: impl GetNodeIndex,
|
to: LooseDotIndex,
|
||||||
inner: impl GetNodeIndex,
|
inner: impl GetNodeIndex,
|
||||||
weight: W,
|
weight: W,
|
||||||
infringables: &[GeometryIndex],
|
infringables: &[GeometryIndex],
|
||||||
|
|
@ -733,7 +737,9 @@ impl Layout {
|
||||||
.first()
|
.first()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let bend = self.geometry.add_bend(from, to, core, weight);
|
let bend = self
|
||||||
|
.geometry
|
||||||
|
.add_bend(from.into(), to.into(), core.into(), weight);
|
||||||
|
|
||||||
self.geometry.graph.update_edge(
|
self.geometry.graph.update_edge(
|
||||||
inner.node_index(),
|
inner.node_index(),
|
||||||
|
|
@ -947,7 +953,7 @@ impl Layout {
|
||||||
|
|
||||||
#[debug_ensures(self.geometry.graph().node_count() == old(self.geometry.graph().node_count()))]
|
#[debug_ensures(self.geometry.graph().node_count() == old(self.geometry.graph().node_count()))]
|
||||||
#[debug_ensures(self.geometry.graph().edge_count() == old(self.geometry.graph().edge_count()))]
|
#[debug_ensures(self.geometry.graph().edge_count() == old(self.geometry.graph().edge_count()))]
|
||||||
pub fn geometry(&self) -> &Geometry {
|
pub fn geometry(&self) -> &Geometry<DotIndex, SegIndex, BendIndex> {
|
||||||
&self.geometry
|
&self.geometry
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,13 @@ use enum_dispatch::enum_dispatch;
|
||||||
use crate::{
|
use crate::{
|
||||||
connectivity::{BandIndex, ComponentIndex},
|
connectivity::{BandIndex, ComponentIndex},
|
||||||
graph::GenericIndex,
|
graph::GenericIndex,
|
||||||
layout::Layout,
|
layout::{GetNodeIndex, Layout},
|
||||||
primitive::{GenericPrimitive, Primitive},
|
primitive::{GenericPrimitive, Primitive},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::geometry::{
|
use super::geometry::{
|
||||||
GeometryIndex, GeometryWeight, GetBandIndex, GetComponentIndex, GetComponentIndexMut,
|
BendWeight, GeometryIndex, GeometryWeight, GetBandIndex, GetComponentIndex,
|
||||||
GetOffset, GetWidth, MakePrimitive, Retag,
|
GetComponentIndexMut, GetOffset, GetWidth, MakePrimitive, Retag,
|
||||||
};
|
};
|
||||||
use petgraph::stable_graph::NodeIndex;
|
use petgraph::stable_graph::NodeIndex;
|
||||||
|
|
||||||
|
|
@ -29,8 +29,6 @@ impl From<BendIndex> for GeometryIndex {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait BendWeight: Into<GeometryWeight> + Copy {}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub struct FixedBendWeight {
|
pub struct FixedBendWeight {
|
||||||
pub component: ComponentIndex,
|
pub component: ComponentIndex,
|
||||||
|
|
@ -3,14 +3,14 @@ use enum_dispatch::enum_dispatch;
|
||||||
use crate::{
|
use crate::{
|
||||||
connectivity::{BandIndex, ComponentIndex},
|
connectivity::{BandIndex, ComponentIndex},
|
||||||
graph::GenericIndex,
|
graph::GenericIndex,
|
||||||
layout::Layout,
|
layout::{GetNodeIndex, Layout},
|
||||||
math::Circle,
|
math::Circle,
|
||||||
primitive::{GenericPrimitive, Primitive},
|
primitive::{GenericPrimitive, Primitive},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::geometry::{
|
use super::geometry::{
|
||||||
GeometryIndex, GeometryWeight, GetBandIndex, GetComponentIndex, GetComponentIndexMut, GetWidth,
|
DotWeight, GeometryIndex, GeometryWeight, GetBandIndex, GetComponentIndex,
|
||||||
MakePrimitive, Retag,
|
GetComponentIndexMut, GetWidth, MakePrimitive, Retag,
|
||||||
};
|
};
|
||||||
use petgraph::stable_graph::NodeIndex;
|
use petgraph::stable_graph::NodeIndex;
|
||||||
|
|
||||||
|
|
@ -30,8 +30,6 @@ impl From<DotIndex> for GeometryIndex {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait DotWeight: GetWidth + Into<GeometryWeight> + Copy {}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub struct FixedDotWeight {
|
pub struct FixedDotWeight {
|
||||||
pub component: ComponentIndex,
|
pub component: ComponentIndex,
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use contracts::debug_invariant;
|
use contracts::debug_invariant;
|
||||||
use enum_dispatch::enum_dispatch;
|
use enum_dispatch::enum_dispatch;
|
||||||
use geo::Point;
|
use geo::Point;
|
||||||
|
|
@ -11,11 +13,11 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
bend::{BendWeight, FixedBendIndex, FixedBendWeight, LooseBendIndex, LooseBendWeight},
|
bend::{FixedBendIndex, FixedBendWeight, LooseBendIndex, LooseBendWeight},
|
||||||
dot::{DotWeight, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
|
dot::{FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
|
||||||
seg::{
|
seg::{
|
||||||
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegWeight,
|
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SeqLooseSegIndex,
|
||||||
SeqLooseSegIndex, SeqLooseSegWeight,
|
SeqLooseSegWeight,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -132,15 +134,25 @@ pub trait MakePrimitive {
|
||||||
fn primitive<'a>(&self, layout: &'a Layout) -> Primitive<'a>;
|
fn primitive<'a>(&self, layout: &'a Layout) -> Primitive<'a>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait DotWeight: GetWidth + Into<GeometryWeight> + Copy {}
|
||||||
|
pub trait SegWeight: Into<GeometryWeight> + Copy {}
|
||||||
|
pub trait BendWeight: Into<GeometryWeight> + Copy {}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Geometry {
|
pub struct Geometry<DI: GetNodeIndex, SI: GetNodeIndex, BI: GetNodeIndex> {
|
||||||
pub graph: GeometryGraph,
|
pub graph: GeometryGraph,
|
||||||
|
dot_index_marker: PhantomData<DI>,
|
||||||
|
seg_index_marker: PhantomData<SI>,
|
||||||
|
bend_index_marker: PhantomData<BI>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Geometry {
|
impl<DI: GetNodeIndex, SI: GetNodeIndex, BI: GetNodeIndex> Geometry<DI, SI, BI> {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
graph: StableDiGraph::default(),
|
graph: StableDiGraph::default(),
|
||||||
|
dot_index_marker: PhantomData,
|
||||||
|
seg_index_marker: PhantomData,
|
||||||
|
bend_index_marker: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,12 +160,7 @@ impl Geometry {
|
||||||
GenericIndex::<W>::new(self.graph.add_node(weight.into()))
|
GenericIndex::<W>::new(self.graph.add_node(weight.into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_seg<W: SegWeight>(
|
pub fn add_seg<W: SegWeight>(&mut self, from: DI, to: DI, weight: W) -> GenericIndex<W> {
|
||||||
&mut self,
|
|
||||||
from: impl GetNodeIndex,
|
|
||||||
to: impl GetNodeIndex,
|
|
||||||
weight: W,
|
|
||||||
) -> GenericIndex<W> {
|
|
||||||
let seg = GenericIndex::<W>::new(self.graph.add_node(weight.into()));
|
let seg = GenericIndex::<W>::new(self.graph.add_node(weight.into()));
|
||||||
|
|
||||||
self.graph
|
self.graph
|
||||||
|
|
@ -166,9 +173,9 @@ impl Geometry {
|
||||||
|
|
||||||
pub fn add_bend<W: BendWeight>(
|
pub fn add_bend<W: BendWeight>(
|
||||||
&mut self,
|
&mut self,
|
||||||
from: impl GetNodeIndex,
|
from: DI,
|
||||||
to: impl GetNodeIndex,
|
to: DI,
|
||||||
core: impl GetNodeIndex,
|
core: DI,
|
||||||
weight: W,
|
weight: W,
|
||||||
) -> GenericIndex<W> {
|
) -> GenericIndex<W> {
|
||||||
let bend = GenericIndex::<W>::new(self.graph.add_node(weight.into()));
|
let bend = GenericIndex::<W>::new(self.graph.add_node(weight.into()));
|
||||||
|
|
@ -3,13 +3,13 @@ use enum_dispatch::enum_dispatch;
|
||||||
use crate::{
|
use crate::{
|
||||||
connectivity::{BandIndex, ComponentIndex},
|
connectivity::{BandIndex, ComponentIndex},
|
||||||
graph::GenericIndex,
|
graph::GenericIndex,
|
||||||
layout::Layout,
|
layout::{GetNodeIndex, Layout},
|
||||||
primitive::{GenericPrimitive, Primitive},
|
primitive::{GenericPrimitive, Primitive},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::geometry::{
|
use super::geometry::{
|
||||||
GeometryIndex, GeometryWeight, GetBandIndex, GetComponentIndex, GetComponentIndexMut, GetWidth,
|
GeometryIndex, GeometryWeight, GetBandIndex, GetComponentIndex, GetComponentIndexMut, GetWidth,
|
||||||
MakePrimitive, Retag,
|
MakePrimitive, Retag, SegWeight,
|
||||||
};
|
};
|
||||||
use petgraph::stable_graph::NodeIndex;
|
use petgraph::stable_graph::NodeIndex;
|
||||||
|
|
||||||
|
|
@ -31,8 +31,6 @@ impl From<SegIndex> for GeometryIndex {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait SegWeight: Into<GeometryWeight> + Copy {}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub struct FixedSegWeight {
|
pub struct FixedSegWeight {
|
||||||
pub component: ComponentIndex,
|
pub component: ComponentIndex,
|
||||||
|
|
@ -2,14 +2,14 @@ use enum_dispatch::enum_dispatch;
|
||||||
use petgraph::stable_graph::NodeIndex;
|
use petgraph::stable_graph::NodeIndex;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
geometry::{
|
graph::GetNodeIndex,
|
||||||
|
layout::Layout,
|
||||||
|
layout::{
|
||||||
bend::LooseBendIndex,
|
bend::LooseBendIndex,
|
||||||
dot::{DotIndex, LooseDotIndex},
|
dot::{DotIndex, LooseDotIndex},
|
||||||
geometry::{GeometryIndex, MakePrimitive},
|
geometry::{GeometryIndex, MakePrimitive},
|
||||||
seg::{LoneLooseSegIndex, SeqLooseSegIndex},
|
seg::{LoneLooseSegIndex, SeqLooseSegIndex},
|
||||||
},
|
},
|
||||||
graph::GetNodeIndex,
|
|
||||||
layout::Layout,
|
|
||||||
primitive::{GetEnds, LoneLooseSeg, LooseBend, LooseDot, Primitive, SeqLooseSeg},
|
primitive::{GetEnds, LoneLooseSeg, LooseBend, LooseDot, Primitive, SeqLooseSeg},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ mod astar;
|
||||||
mod band;
|
mod band;
|
||||||
mod connectivity;
|
mod connectivity;
|
||||||
mod draw;
|
mod draw;
|
||||||
mod geometry;
|
|
||||||
mod graph;
|
mod graph;
|
||||||
mod guide;
|
mod guide;
|
||||||
mod layout;
|
mod layout;
|
||||||
|
|
@ -31,9 +30,9 @@ mod wraparoundable;
|
||||||
use connectivity::BandIndex;
|
use connectivity::BandIndex;
|
||||||
use draw::DrawException;
|
use draw::DrawException;
|
||||||
use geo::point;
|
use geo::point;
|
||||||
use geometry::dot::FixedDotWeight;
|
use layout::dot::FixedDotWeight;
|
||||||
use geometry::geometry::{GeometryIndex, MakePrimitive};
|
use layout::geometry::{GeometryIndex, MakePrimitive};
|
||||||
use geometry::seg::FixedSegWeight;
|
use layout::seg::FixedSegWeight;
|
||||||
use layout::{Infringement, Layout, LayoutException};
|
use layout::{Infringement, Layout, LayoutException};
|
||||||
use mesh::{Mesh, MeshEdgeReference, VertexIndex};
|
use mesh::{Mesh, MeshEdgeReference, VertexIndex};
|
||||||
use petgraph::visit::{EdgeRef, IntoEdgeReferences};
|
use petgraph::visit::{EdgeRef, IntoEdgeReferences};
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,13 @@ use spade::{HasPosition, InsertionError, Point2};
|
||||||
use crate::primitive::{GetCore, Primitive};
|
use crate::primitive::{GetCore, Primitive};
|
||||||
use crate::triangulation::TriangulationEdgeReference;
|
use crate::triangulation::TriangulationEdgeReference;
|
||||||
use crate::{
|
use crate::{
|
||||||
geometry::{
|
graph::GetNodeIndex,
|
||||||
|
layout::Layout,
|
||||||
|
layout::{
|
||||||
bend::{FixedBendIndex, LooseBendIndex},
|
bend::{FixedBendIndex, LooseBendIndex},
|
||||||
dot::FixedDotIndex,
|
dot::FixedDotIndex,
|
||||||
geometry::{GeometryIndex, MakePrimitive},
|
geometry::{GeometryIndex, MakePrimitive},
|
||||||
},
|
},
|
||||||
graph::GetNodeIndex,
|
|
||||||
layout::Layout,
|
|
||||||
primitive::MakeShape,
|
primitive::MakeShape,
|
||||||
shape::ShapeTrait,
|
shape::ShapeTrait,
|
||||||
triangulation::{GetVertexIndex, Triangulation},
|
triangulation::{GetVertexIndex, Triangulation},
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,13 @@ use petgraph::stable_graph::NodeIndex;
|
||||||
use petgraph::Direction::{Incoming, Outgoing};
|
use petgraph::Direction::{Incoming, Outgoing};
|
||||||
|
|
||||||
use crate::connectivity::{BandIndex, ComponentIndex, GetNet};
|
use crate::connectivity::{BandIndex, ComponentIndex, GetNet};
|
||||||
use crate::geometry::seg::{
|
use crate::graph::{GenericIndex, GetNodeIndex};
|
||||||
|
use crate::layout::seg::{
|
||||||
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegIndex,
|
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegIndex,
|
||||||
SeqLooseSegIndex, SeqLooseSegWeight,
|
SeqLooseSegIndex, SeqLooseSegWeight,
|
||||||
};
|
};
|
||||||
use crate::geometry::{
|
use crate::layout::Layout;
|
||||||
|
use crate::layout::{
|
||||||
bend::{BendIndex, FixedBendIndex, FixedBendWeight, LooseBendIndex, LooseBendWeight},
|
bend::{BendIndex, FixedBendIndex, FixedBendWeight, LooseBendIndex, LooseBendWeight},
|
||||||
dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
|
dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
|
||||||
geometry::{
|
geometry::{
|
||||||
|
|
@ -17,8 +19,6 @@ use crate::geometry::{
|
||||||
GetWidth, MakePrimitive, Retag,
|
GetWidth, MakePrimitive, Retag,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use crate::graph::{GenericIndex, GetNodeIndex};
|
|
||||||
use crate::layout::Layout;
|
|
||||||
use crate::loose::{Loose, LooseIndex};
|
use crate::loose::{Loose, LooseIndex};
|
||||||
use crate::math::{self, Circle};
|
use crate::math::{self, Circle};
|
||||||
use crate::shape::{BendShape, DotShape, SegShape, Shape, ShapeTrait};
|
use crate::shape::{BendShape, DotShape, SegShape, Shape, ShapeTrait};
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,12 @@ use thiserror::Error;
|
||||||
use crate::astar::{astar, AstarStrategy, PathTracker};
|
use crate::astar::{astar, AstarStrategy, PathTracker};
|
||||||
use crate::connectivity::BandIndex;
|
use crate::connectivity::BandIndex;
|
||||||
use crate::draw::DrawException;
|
use crate::draw::DrawException;
|
||||||
use crate::geometry::{
|
use crate::guide::HeadTrait;
|
||||||
|
use crate::layout::Layout;
|
||||||
|
use crate::layout::{
|
||||||
dot::FixedDotIndex,
|
dot::FixedDotIndex,
|
||||||
geometry::{GeometryIndex, MakePrimitive},
|
geometry::{GeometryIndex, MakePrimitive},
|
||||||
};
|
};
|
||||||
use crate::guide::HeadTrait;
|
|
||||||
use crate::layout::Layout;
|
|
||||||
|
|
||||||
use crate::mesh::{Mesh, MeshEdgeReference, VertexIndex};
|
use crate::mesh::{Mesh, MeshEdgeReference, VertexIndex};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
geometry::{
|
layout::Layout,
|
||||||
|
layout::{
|
||||||
bend::LooseBendIndex, dot::LooseDotIndex, geometry::GeometryIndex, seg::SeqLooseSegIndex,
|
bend::LooseBendIndex, dot::LooseDotIndex, geometry::GeometryIndex, seg::SeqLooseSegIndex,
|
||||||
},
|
},
|
||||||
layout::Layout,
|
|
||||||
primitive::{GetEnds, GetInterior, GetOtherEnd, LooseBend, LooseDot},
|
primitive::{GetEnds, GetInterior, GetOtherEnd, LooseBend, LooseDot},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ use contracts::debug_ensures;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
draw::{Draw, DrawException},
|
draw::{Draw, DrawException},
|
||||||
geometry::{bend::LooseBendIndex, dot::FixedDotIndex},
|
|
||||||
guide::{BareHead, Head, SegbendHead},
|
guide::{BareHead, Head, SegbendHead},
|
||||||
layout::Layout,
|
layout::Layout,
|
||||||
|
layout::{bend::LooseBendIndex, dot::FixedDotIndex},
|
||||||
mesh::{Mesh, VertexIndex},
|
mesh::{Mesh, VertexIndex},
|
||||||
rules::Rules,
|
rules::Rules,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,13 @@ use enum_dispatch::enum_dispatch;
|
||||||
use petgraph::stable_graph::NodeIndex;
|
use petgraph::stable_graph::NodeIndex;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
geometry::{
|
graph::GetNodeIndex,
|
||||||
|
layout::Layout,
|
||||||
|
layout::{
|
||||||
bend::{BendIndex, FixedBendIndex, LooseBendIndex},
|
bend::{BendIndex, FixedBendIndex, LooseBendIndex},
|
||||||
dot::FixedDotIndex,
|
dot::FixedDotIndex,
|
||||||
geometry::{GeometryIndex, MakePrimitive},
|
geometry::{GeometryIndex, MakePrimitive},
|
||||||
},
|
},
|
||||||
graph::GetNodeIndex,
|
|
||||||
layout::Layout,
|
|
||||||
primitive::{
|
primitive::{
|
||||||
FixedBend, FixedDot, GetFirstRail, GetInnerOuter, GetLayout, LooseBend, Primitive,
|
FixedBend, FixedDot, GetFirstRail, GetInnerOuter, GetLayout, LooseBend, Primitive,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue