geometry: move into own module, move dot, seg, bend to separate files

This commit is contained in:
Mikolaj Wielgus 2024-01-27 00:08:11 +00:00
parent 5d1b3dff9a
commit 8c1b7d1e7e
20 changed files with 391 additions and 302 deletions

View File

@ -1,6 +1,9 @@
use crate::{ use crate::{
connectivity::{BandIndex, BandWeight, ConnectivityWeight, GetNet}, connectivity::{BandIndex, BandWeight, ConnectivityWeight, GetNet},
geometry::{DotIndex, FixedDotIndex, GeometryIndex, MakePrimitive}, geometry::{
dot::{DotIndex, FixedDotIndex},
geometry::{GeometryIndex, MakePrimitive},
},
graph::GetNodeIndex, graph::GetNodeIndex,
layout::Layout, layout::Layout,
loose::{GetNextLoose, LooseIndex}, loose::{GetNextLoose, LooseIndex},

View File

@ -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::FixedDotIndex, graph::GenericIndex}; use crate::{geometry::dot::FixedDotIndex, graph::GenericIndex};
#[enum_dispatch] #[enum_dispatch]
pub trait GetNet { pub trait GetNet {

View File

@ -4,8 +4,10 @@ use thiserror::Error;
use crate::{ use crate::{
geometry::{ geometry::{
BendIndex, DotIndex, FixedDotIndex, GetBandIndex, LoneLooseSegWeight, LooseBendWeight, bend::{BendIndex, LooseBendWeight},
LooseDotIndex, LooseDotWeight, MakePrimitive, SeqLooseSegWeight, dot::{DotIndex, FixedDotIndex, LooseDotIndex, LooseDotWeight},
geometry::{GetBandIndex, MakePrimitive},
seg::{LoneLooseSegWeight, SeqLooseSegWeight},
}, },
guide::{Guide, Head, HeadTrait, SegbendHead}, guide::{Guide, Head, HeadTrait, SegbendHead},
layout::{Infringement, Layout, LayoutException}, layout::{Infringement, Layout, LayoutException},

View File

@ -1,272 +0,0 @@
use enum_dispatch::enum_dispatch;
use petgraph::stable_graph::{NodeIndex, StableDiGraph};
use crate::{
connectivity::{BandIndex, ComponentIndex},
graph::GenericIndex,
layout::Layout,
math::Circle,
primitive::{GenericPrimitive, Primitive},
};
#[enum_dispatch]
pub trait Retag {
fn retag(&self, index: NodeIndex<usize>) -> GeometryIndex;
}
#[enum_dispatch]
pub trait GetComponentIndex {
fn component(&self) -> ComponentIndex;
}
pub trait GetComponentIndexMut {
fn component_mut(&mut self) -> &mut ComponentIndex;
}
pub trait GetBandIndex {
fn band(&self) -> BandIndex;
}
#[enum_dispatch]
pub trait GetWidth {
fn width(&self) -> f64;
}
pub trait GetOffset {
fn offset(&self) -> f64;
}
macro_rules! impl_weight {
($weight_struct:ident, $weight_variant:ident, $index_struct:ident) => {
impl Retag for $weight_struct {
fn retag(&self, index: NodeIndex<usize>) -> GeometryIndex {
GeometryIndex::$weight_variant($index_struct::new(index))
}
}
pub type $index_struct = GenericIndex<$weight_struct>;
impl MakePrimitive for $index_struct {
fn primitive<'a>(&self, layout: &'a Layout) -> Primitive<'a> {
Primitive::$weight_variant(GenericPrimitive::new(*self, layout))
}
}
};
}
macro_rules! impl_fixed_weight {
($weight_struct:ident, $weight_variant:ident, $index_struct:ident) => {
impl_weight!($weight_struct, $weight_variant, $index_struct);
impl GetComponentIndex for $weight_struct {
fn component(&self) -> ComponentIndex {
self.component
}
}
impl GetComponentIndexMut for $weight_struct {
fn component_mut(&mut self) -> &mut ComponentIndex {
&mut self.component
}
}
};
}
macro_rules! impl_loose_weight {
($weight_struct:ident, $weight_variant:ident, $index_struct:ident) => {
impl_weight!($weight_struct, $weight_variant, $index_struct);
impl GetBandIndex for $weight_struct {
fn band(&self) -> BandIndex {
self.band
}
}
};
}
pub type GeometryGraph = StableDiGraph<GeometryWeight, GeometryLabel, usize>;
#[enum_dispatch(Retag)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum GeometryWeight {
FixedDot(FixedDotWeight),
LooseDot(LooseDotWeight),
FixedSeg(FixedSegWeight),
LoneLooseSeg(LoneLooseSegWeight),
SeqLooseSeg(SeqLooseSegWeight),
FixedBend(FixedBendWeight),
LooseBend(LooseBendWeight),
}
#[enum_dispatch(GetNodeIndex, MakePrimitive)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum GeometryIndex {
FixedDot(FixedDotIndex),
LooseDot(LooseDotIndex),
FixedSeg(FixedSegIndex),
LoneLooseSeg(LoneLooseSegIndex),
SeqLooseSeg(SeqLooseSegIndex),
FixedBend(FixedBendIndex),
LooseBend(LooseBendIndex),
}
#[enum_dispatch(GetNodeIndex, MakePrimitive)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum DotIndex {
Fixed(FixedDotIndex),
Loose(LooseDotIndex),
}
impl From<DotIndex> for GeometryIndex {
fn from(dot: DotIndex) -> Self {
match dot {
DotIndex::Fixed(fixed) => GeometryIndex::FixedDot(fixed),
DotIndex::Loose(loose) => GeometryIndex::LooseDot(loose),
}
}
}
#[enum_dispatch(GetNodeIndex, MakePrimitive)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum SegIndex {
Fixed(FixedSegIndex),
LoneLoose(LoneLooseSegIndex),
SeqLoose(SeqLooseSegIndex),
}
impl From<SegIndex> for GeometryIndex {
fn from(seg: SegIndex) -> Self {
match seg {
SegIndex::Fixed(seg) => GeometryIndex::FixedSeg(seg),
SegIndex::LoneLoose(seg) => GeometryIndex::LoneLooseSeg(seg),
SegIndex::SeqLoose(seg) => GeometryIndex::SeqLooseSeg(seg),
}
}
}
#[enum_dispatch(GetNodeIndex, MakePrimitive)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum BendIndex {
Fixed(FixedBendIndex),
Loose(LooseBendIndex),
}
impl From<BendIndex> for GeometryIndex {
fn from(bend: BendIndex) -> Self {
match bend {
BendIndex::Fixed(bend) => GeometryIndex::FixedBend(bend),
BendIndex::Loose(bend) => GeometryIndex::LooseBend(bend),
}
}
}
pub trait DotWeight: GetWidth + Into<GeometryWeight> + Copy {}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct FixedDotWeight {
pub component: ComponentIndex,
pub circle: Circle,
}
impl_fixed_weight!(FixedDotWeight, FixedDot, FixedDotIndex);
impl DotWeight for FixedDotWeight {}
impl GetWidth for FixedDotWeight {
fn width(&self) -> f64 {
self.circle.r * 2.0
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct LooseDotWeight {
pub band: BandIndex,
pub circle: Circle,
}
impl_loose_weight!(LooseDotWeight, LooseDot, LooseDotIndex);
impl DotWeight for LooseDotWeight {}
impl GetWidth for LooseDotWeight {
fn width(&self) -> f64 {
self.circle.r * 2.0
}
}
pub trait SegWeight: Into<GeometryWeight> + Copy {}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct FixedSegWeight {
pub component: ComponentIndex,
pub width: f64,
}
impl_fixed_weight!(FixedSegWeight, FixedSeg, FixedSegIndex);
impl SegWeight for FixedSegWeight {}
impl GetWidth for FixedSegWeight {
fn width(&self) -> f64 {
self.width
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct LoneLooseSegWeight {
pub band: BandIndex,
}
impl_loose_weight!(LoneLooseSegWeight, LoneLooseSeg, LoneLooseSegIndex);
impl SegWeight for LoneLooseSegWeight {}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SeqLooseSegWeight {
pub band: BandIndex,
}
impl_loose_weight!(SeqLooseSegWeight, SeqLooseSeg, SeqLooseSegIndex);
impl SegWeight for SeqLooseSegWeight {}
pub trait BendWeight: Into<GeometryWeight> + Copy {}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct FixedBendWeight {
pub component: ComponentIndex,
pub width: f64,
pub cw: bool,
}
impl_fixed_weight!(FixedBendWeight, FixedBend, FixedBendIndex);
impl BendWeight for FixedBendWeight {}
impl GetWidth for FixedBendWeight {
fn width(&self) -> f64 {
self.width
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct LooseBendWeight {
pub band: BandIndex,
pub offset: f64,
pub cw: bool,
}
impl GetOffset for LooseBendWeight {
fn offset(&self) -> f64 {
self.offset
}
}
impl_loose_weight!(LooseBendWeight, LooseBend, LooseBendIndex);
impl BendWeight for LooseBendWeight {}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum GeometryLabel {
Adjacent,
Outer,
Core,
}
#[enum_dispatch]
pub trait MakePrimitive {
fn primitive<'a>(&self, layout: &'a Layout) -> Primitive<'a>;
}

64
src/geometry/bend.rs Normal file
View File

@ -0,0 +1,64 @@
use enum_dispatch::enum_dispatch;
use crate::{
connectivity::{BandIndex, ComponentIndex},
graph::GenericIndex,
layout::Layout,
primitive::{GenericPrimitive, Primitive},
};
use super::geometry::{
GeometryIndex, GeometryWeight, GetBandIndex, GetComponentIndex, GetComponentIndexMut,
GetOffset, GetWidth, MakePrimitive, Retag,
};
use petgraph::stable_graph::NodeIndex;
#[enum_dispatch(GetNodeIndex, MakePrimitive)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum BendIndex {
Fixed(FixedBendIndex),
Loose(LooseBendIndex),
}
impl From<BendIndex> for GeometryIndex {
fn from(bend: BendIndex) -> Self {
match bend {
BendIndex::Fixed(bend) => GeometryIndex::FixedBend(bend),
BendIndex::Loose(bend) => GeometryIndex::LooseBend(bend),
}
}
}
pub trait BendWeight: Into<GeometryWeight> + Copy {}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct FixedBendWeight {
pub component: ComponentIndex,
pub width: f64,
pub cw: bool,
}
impl_fixed_weight!(FixedBendWeight, FixedBend, FixedBendIndex);
impl BendWeight for FixedBendWeight {}
impl GetWidth for FixedBendWeight {
fn width(&self) -> f64 {
self.width
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct LooseBendWeight {
pub band: BandIndex,
pub offset: f64,
pub cw: bool,
}
impl GetOffset for LooseBendWeight {
fn offset(&self) -> f64 {
self.offset
}
}
impl_loose_weight!(LooseBendWeight, LooseBend, LooseBendIndex);
impl BendWeight for LooseBendWeight {}

63
src/geometry/dot.rs Normal file
View File

@ -0,0 +1,63 @@
use enum_dispatch::enum_dispatch;
use crate::{
connectivity::{BandIndex, ComponentIndex},
graph::GenericIndex,
layout::Layout,
math::Circle,
primitive::{GenericPrimitive, Primitive},
};
use super::geometry::{
GeometryIndex, GeometryWeight, GetBandIndex, GetComponentIndex, GetComponentIndexMut, GetWidth,
MakePrimitive, Retag,
};
use petgraph::stable_graph::NodeIndex;
#[enum_dispatch(GetNodeIndex, MakePrimitive)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum DotIndex {
Fixed(FixedDotIndex),
Loose(LooseDotIndex),
}
impl From<DotIndex> for GeometryIndex {
fn from(dot: DotIndex) -> Self {
match dot {
DotIndex::Fixed(fixed) => GeometryIndex::FixedDot(fixed),
DotIndex::Loose(loose) => GeometryIndex::LooseDot(loose),
}
}
}
pub trait DotWeight: GetWidth + Into<GeometryWeight> + Copy {}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct FixedDotWeight {
pub component: ComponentIndex,
pub circle: Circle,
}
impl_fixed_weight!(FixedDotWeight, FixedDot, FixedDotIndex);
impl DotWeight for FixedDotWeight {}
impl GetWidth for FixedDotWeight {
fn width(&self) -> f64 {
self.circle.r * 2.0
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct LooseDotWeight {
pub band: BandIndex,
pub circle: Circle,
}
impl_loose_weight!(LooseDotWeight, LooseDot, LooseDotIndex);
impl DotWeight for LooseDotWeight {}
impl GetWidth for LooseDotWeight {
fn width(&self) -> f64 {
self.circle.r * 2.0
}
}

130
src/geometry/geometry.rs Normal file
View File

@ -0,0 +1,130 @@
use enum_dispatch::enum_dispatch;
use petgraph::stable_graph::{NodeIndex, StableDiGraph};
use crate::{
connectivity::{BandIndex, ComponentIndex},
layout::Layout,
primitive::Primitive,
};
use super::{
bend::{FixedBendIndex, FixedBendWeight, LooseBendIndex, LooseBendWeight},
dot::{FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
seg::{
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SeqLooseSegIndex,
SeqLooseSegWeight,
},
};
#[enum_dispatch]
pub trait Retag {
fn retag(&self, index: NodeIndex<usize>) -> GeometryIndex;
}
#[enum_dispatch]
pub trait GetComponentIndex {
fn component(&self) -> ComponentIndex;
}
pub trait GetComponentIndexMut {
fn component_mut(&mut self) -> &mut ComponentIndex;
}
pub trait GetBandIndex {
fn band(&self) -> BandIndex;
}
#[enum_dispatch]
pub trait GetWidth {
fn width(&self) -> f64;
}
pub trait GetOffset {
fn offset(&self) -> f64;
}
macro_rules! impl_weight {
($weight_struct:ident, $weight_variant:ident, $index_struct:ident) => {
impl Retag for $weight_struct {
fn retag(&self, index: NodeIndex<usize>) -> GeometryIndex {
GeometryIndex::$weight_variant($index_struct::new(index))
}
}
pub type $index_struct = GenericIndex<$weight_struct>;
impl MakePrimitive for $index_struct {
fn primitive<'a>(&self, layout: &'a Layout) -> Primitive<'a> {
Primitive::$weight_variant(GenericPrimitive::new(*self, layout))
}
}
};
}
macro_rules! impl_fixed_weight {
($weight_struct:ident, $weight_variant:ident, $index_struct:ident) => {
impl_weight!($weight_struct, $weight_variant, $index_struct);
impl GetComponentIndex for $weight_struct {
fn component(&self) -> ComponentIndex {
self.component
}
}
impl GetComponentIndexMut for $weight_struct {
fn component_mut(&mut self) -> &mut ComponentIndex {
&mut self.component
}
}
};
}
macro_rules! impl_loose_weight {
($weight_struct:ident, $weight_variant:ident, $index_struct:ident) => {
impl_weight!($weight_struct, $weight_variant, $index_struct);
impl GetBandIndex for $weight_struct {
fn band(&self) -> BandIndex {
self.band
}
}
};
}
pub type GeometryGraph = StableDiGraph<GeometryWeight, GeometryLabel, usize>;
#[enum_dispatch(Retag)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum GeometryWeight {
FixedDot(FixedDotWeight),
LooseDot(LooseDotWeight),
FixedSeg(FixedSegWeight),
LoneLooseSeg(LoneLooseSegWeight),
SeqLooseSeg(SeqLooseSegWeight),
FixedBend(FixedBendWeight),
LooseBend(LooseBendWeight),
}
#[enum_dispatch(GetNodeIndex, MakePrimitive)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum GeometryIndex {
FixedDot(FixedDotIndex),
LooseDot(LooseDotIndex),
FixedSeg(FixedSegIndex),
LoneLooseSeg(LoneLooseSegIndex),
SeqLooseSeg(SeqLooseSegIndex),
FixedBend(FixedBendIndex),
LooseBend(LooseBendIndex),
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum GeometryLabel {
Adjacent,
Outer,
Core,
}
#[enum_dispatch]
pub trait MakePrimitive {
fn primitive<'a>(&self, layout: &'a Layout) -> Primitive<'a>;
}

5
src/geometry/mod.rs Normal file
View File

@ -0,0 +1,5 @@
#[macro_use]
pub mod geometry;
pub mod bend;
pub mod dot;
pub mod seg;

65
src/geometry/seg.rs Normal file
View File

@ -0,0 +1,65 @@
use enum_dispatch::enum_dispatch;
use crate::{
connectivity::{BandIndex, ComponentIndex},
graph::GenericIndex,
layout::Layout,
primitive::{GenericPrimitive, Primitive},
};
use super::geometry::{
GeometryIndex, GeometryWeight, GetBandIndex, GetComponentIndex, GetComponentIndexMut, GetWidth,
MakePrimitive, Retag,
};
use petgraph::stable_graph::NodeIndex;
#[enum_dispatch(GetNodeIndex, MakePrimitive)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum SegIndex {
Fixed(FixedSegIndex),
LoneLoose(LoneLooseSegIndex),
SeqLoose(SeqLooseSegIndex),
}
impl From<SegIndex> for GeometryIndex {
fn from(seg: SegIndex) -> Self {
match seg {
SegIndex::Fixed(seg) => GeometryIndex::FixedSeg(seg),
SegIndex::LoneLoose(seg) => GeometryIndex::LoneLooseSeg(seg),
SegIndex::SeqLoose(seg) => GeometryIndex::SeqLooseSeg(seg),
}
}
}
pub trait SegWeight: Into<GeometryWeight> + Copy {}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct FixedSegWeight {
pub component: ComponentIndex,
pub width: f64,
}
impl_fixed_weight!(FixedSegWeight, FixedSeg, FixedSegIndex);
impl SegWeight for FixedSegWeight {}
impl GetWidth for FixedSegWeight {
fn width(&self) -> f64 {
self.width
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct LoneLooseSegWeight {
pub band: BandIndex,
}
impl_loose_weight!(LoneLooseSegWeight, LoneLooseSeg, LoneLooseSegIndex);
impl SegWeight for LoneLooseSegWeight {}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SeqLooseSegWeight {
pub band: BandIndex,
}
impl_loose_weight!(SeqLooseSegWeight, SeqLooseSeg, SeqLooseSegIndex);
impl SegWeight for SeqLooseSegWeight {}

View File

@ -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::{BendIndex, DotIndex, GeometryIndex, SegIndex}; use crate::geometry::{bend::BendIndex, dot::DotIndex, geometry::GeometryIndex, seg::SegIndex};
#[enum_dispatch] #[enum_dispatch]
pub trait GetNodeIndex { pub trait GetNodeIndex {

View File

@ -3,7 +3,11 @@ use geo::Line;
use crate::{ use crate::{
connectivity::BandIndex, connectivity::BandIndex,
geometry::{BendIndex, DotIndex, FixedDotIndex, GetBandIndex, LooseDotIndex, MakePrimitive}, geometry::{
bend::BendIndex,
dot::{DotIndex, FixedDotIndex, LooseDotIndex},
geometry::{GetBandIndex, MakePrimitive},
},
layout::Layout, layout::Layout,
math::{self, Circle, NoTangents}, math::{self, Circle, NoTangents},
primitive::{GetCore, GetInnerOuter, GetOtherEnd, GetWeight, MakeShape}, primitive::{GetCore, GetInnerOuter, GetOtherEnd, GetWeight, MakeShape},

View File

@ -13,11 +13,18 @@ use crate::connectivity::{
BandIndex, BandWeight, ComponentIndex, ComponentWeight, ConnectivityGraph, ConnectivityLabel, BandIndex, BandWeight, ComponentIndex, ComponentWeight, ConnectivityGraph, ConnectivityLabel,
ConnectivityWeight, GetNet, ConnectivityWeight, GetNet,
}; };
use crate::geometry::seg::SeqLooseSegWeight;
use crate::geometry::{ use crate::geometry::{
BendWeight, DotIndex, DotWeight, FixedBendIndex, FixedDotIndex, FixedDotWeight, FixedSegIndex, bend::{BendWeight, FixedBendIndex, LooseBendIndex, LooseBendWeight},
FixedSegWeight, GeometryGraph, GeometryIndex, GeometryLabel, GeometryWeight, GetComponentIndex, dot::{DotIndex, DotWeight, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
LoneLooseSegIndex, LoneLooseSegWeight, LooseBendIndex, LooseBendWeight, LooseDotIndex, geometry::{
LooseDotWeight, MakePrimitive, Retag, SegWeight, SeqLooseSegIndex, SeqLooseSegWeight, GeometryGraph, GeometryIndex, GeometryLabel, GeometryWeight, GetComponentIndex,
MakePrimitive, Retag,
},
seg::{
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegWeight,
SeqLooseSegIndex,
},
}; };
use crate::graph::{GenericIndex, GetNodeIndex}; use crate::graph::{GenericIndex, GetNodeIndex};
use crate::guide::Guide; use crate::guide::Guide;

View File

@ -3,8 +3,10 @@ use petgraph::stable_graph::NodeIndex;
use crate::{ use crate::{
geometry::{ geometry::{
DotIndex, GeometryIndex, LoneLooseSegIndex, LooseBendIndex, LooseDotIndex, MakePrimitive, bend::LooseBendIndex,
SeqLooseSegIndex, dot::{DotIndex, LooseDotIndex},
geometry::{GeometryIndex, MakePrimitive},
seg::{LoneLooseSegIndex, SeqLooseSegIndex},
}, },
graph::GetNodeIndex, graph::GetNodeIndex,
layout::Layout, layout::Layout,

View File

@ -31,7 +31,9 @@ mod wraparoundable;
use connectivity::BandIndex; use connectivity::BandIndex;
use draw::DrawException; use draw::DrawException;
use geo::point; use geo::point;
use geometry::{FixedDotIndex, FixedSegWeight, GeometryIndex, LooseDotIndex, MakePrimitive}; use geometry::dot::FixedDotWeight;
use geometry::geometry::{GeometryIndex, MakePrimitive};
use geometry::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};
@ -59,7 +61,6 @@ use pathfinder_resources::embedded::EmbeddedResourceLoader;
use std::time::Duration; use std::time::Duration;
use tracer::{Trace, Tracer}; use tracer::{Trace, Tracer};
use crate::geometry::FixedDotWeight;
use crate::math::Circle; use crate::math::Circle;
use crate::router::Router; use crate::router::Router;

View File

@ -10,7 +10,11 @@ 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::{FixedBendIndex, FixedDotIndex, GeometryIndex, LooseBendIndex, MakePrimitive}, geometry::{
bend::{FixedBendIndex, LooseBendIndex},
dot::FixedDotIndex,
geometry::{GeometryIndex, MakePrimitive},
},
graph::GetNodeIndex, graph::GetNodeIndex,
layout::Layout, layout::Layout,
primitive::MakeShape, primitive::MakeShape,

View File

@ -5,13 +5,18 @@ 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::{ use crate::geometry::seg::{
BendIndex, DotIndex, FixedBendIndex, FixedBendWeight, FixedDotIndex, FixedDotWeight, FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegIndex,
FixedSegIndex, FixedSegWeight, GeometryIndex, GeometryLabel, GeometryWeight, GetBandIndex,
GetComponentIndex, GetOffset, GetWidth, LoneLooseSegIndex, LoneLooseSegWeight, LooseBendIndex,
LooseBendWeight, LooseDotIndex, LooseDotWeight, MakePrimitive, Retag, SegIndex,
SeqLooseSegIndex, SeqLooseSegWeight, SeqLooseSegIndex, SeqLooseSegWeight,
}; };
use crate::geometry::{
bend::{BendIndex, FixedBendIndex, FixedBendWeight, LooseBendIndex, LooseBendWeight},
dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
geometry::{
GeometryIndex, GeometryLabel, GeometryWeight, GetBandIndex, GetComponentIndex, GetOffset,
GetWidth, MakePrimitive, Retag,
},
};
use crate::graph::{GenericIndex, GetNodeIndex}; use crate::graph::{GenericIndex, GetNodeIndex};
use crate::layout::Layout; use crate::layout::Layout;
use crate::loose::{Loose, LooseIndex}; use crate::loose::{Loose, LooseIndex};
@ -317,7 +322,7 @@ pub type FixedDot<'a> = GenericPrimitive<'a, FixedDotWeight>;
impl_fixed_primitive!(FixedDot, FixedDotWeight); impl_fixed_primitive!(FixedDot, FixedDotWeight);
impl<'a> FixedDot<'a> { impl<'a> FixedDot<'a> {
pub fn first_loose(&self, band: BandIndex) -> Option<LooseIndex> { pub fn first_loose(&self, _band: BandIndex) -> Option<LooseIndex> {
self.adjacents().into_iter().find_map(|node| { self.adjacents().into_iter().find_map(|node| {
let weight = self.layout.geometry().node_weight(node).unwrap(); let weight = self.layout.geometry().node_weight(node).unwrap();
if matches!(weight, GeometryWeight::LoneLooseSeg(..)) { if matches!(weight, GeometryWeight::LoneLooseSeg(..)) {
@ -345,13 +350,13 @@ impl<'a> GetLegs for FixedDot<'a> {
.into_iter() .into_iter()
.filter_map( .filter_map(
|node| match self.layout.geometry().node_weight(node).unwrap() { |node| match self.layout.geometry().node_weight(node).unwrap() {
GeometryWeight::FixedSeg(seg) => { GeometryWeight::FixedSeg(_seg) => {
Some(SegIndex::Fixed(FixedSegIndex::new(node))) Some(SegIndex::Fixed(FixedSegIndex::new(node)))
} }
GeometryWeight::LoneLooseSeg(seg) => { GeometryWeight::LoneLooseSeg(_seg) => {
Some(SegIndex::LoneLoose(LoneLooseSegIndex::new(node).into())) Some(SegIndex::LoneLoose(LoneLooseSegIndex::new(node).into()))
} }
GeometryWeight::SeqLooseSeg(seg) => { GeometryWeight::SeqLooseSeg(_seg) => {
Some(SegIndex::SeqLoose(SeqLooseSegIndex::new(node).into())) Some(SegIndex::SeqLoose(SeqLooseSegIndex::new(node).into()))
} }
_ => None, _ => None,

View File

@ -5,13 +5,15 @@ use spade::InsertionError;
use thiserror::Error; use thiserror::Error;
use crate::astar::{astar, AstarStrategy, PathTracker}; use crate::astar::{astar, AstarStrategy, PathTracker};
use crate::connectivity::{BandIndex, GetNet}; use crate::connectivity::BandIndex;
use crate::draw::DrawException; use crate::draw::DrawException;
use crate::geometry::{FixedDotIndex, FixedDotWeight, GeometryIndex, MakePrimitive}; use crate::geometry::{
dot::FixedDotIndex,
geometry::{GeometryIndex, MakePrimitive},
};
use crate::guide::HeadTrait; use crate::guide::HeadTrait;
use crate::layout::Layout; use crate::layout::Layout;
use crate::math::Circle;
use crate::mesh::{Mesh, MeshEdgeReference, VertexIndex}; use crate::mesh::{Mesh, MeshEdgeReference, VertexIndex};
use crate::primitive::MakeShape; use crate::primitive::MakeShape;

View File

@ -1,5 +1,7 @@
use crate::{ use crate::{
geometry::{GeometryIndex, LooseBendIndex, LooseDotIndex, SeqLooseSegIndex}, geometry::{
bend::LooseBendIndex, dot::LooseDotIndex, geometry::GeometryIndex, seg::SeqLooseSegIndex,
},
layout::Layout, layout::Layout,
primitive::{GetEnds, GetInterior, GetOtherEnd, LooseBend, LooseDot}, primitive::{GetEnds, GetInterior, GetOtherEnd, LooseBend, LooseDot},
}; };

View File

@ -2,7 +2,7 @@ use contracts::debug_ensures;
use crate::{ use crate::{
draw::{Draw, DrawException}, draw::{Draw, DrawException},
geometry::{FixedDotIndex, LooseBendIndex}, geometry::{bend::LooseBendIndex, dot::FixedDotIndex},
guide::{BareHead, Head, SegbendHead}, guide::{BareHead, Head, SegbendHead},
layout::Layout, layout::Layout,
mesh::{Mesh, VertexIndex}, mesh::{Mesh, VertexIndex},

View File

@ -3,7 +3,9 @@ use petgraph::stable_graph::NodeIndex;
use crate::{ use crate::{
geometry::{ geometry::{
BendIndex, FixedBendIndex, FixedDotIndex, GeometryIndex, LooseBendIndex, MakePrimitive, bend::{BendIndex, FixedBendIndex, LooseBendIndex},
dot::FixedDotIndex,
geometry::{GeometryIndex, MakePrimitive},
}, },
graph::GetNodeIndex, graph::GetNodeIndex,
layout::Layout, layout::Layout,