mirror of https://codeberg.org/topola/topola.git
geometry: move into own module, move dot, seg, bend to separate files
This commit is contained in:
parent
5d1b3dff9a
commit
8c1b7d1e7e
|
|
@ -1,6 +1,9 @@
|
|||
use crate::{
|
||||
connectivity::{BandIndex, BandWeight, ConnectivityWeight, GetNet},
|
||||
geometry::{DotIndex, FixedDotIndex, GeometryIndex, MakePrimitive},
|
||||
geometry::{
|
||||
dot::{DotIndex, FixedDotIndex},
|
||||
geometry::{GeometryIndex, MakePrimitive},
|
||||
},
|
||||
graph::GetNodeIndex,
|
||||
layout::Layout,
|
||||
loose::{GetNextLoose, LooseIndex},
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use enum_dispatch::enum_dispatch;
|
||||
use petgraph::stable_graph::StableDiGraph;
|
||||
|
||||
use crate::{geometry::FixedDotIndex, graph::GenericIndex};
|
||||
use crate::{geometry::dot::FixedDotIndex, graph::GenericIndex};
|
||||
|
||||
#[enum_dispatch]
|
||||
pub trait GetNet {
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@ use thiserror::Error;
|
|||
|
||||
use crate::{
|
||||
geometry::{
|
||||
BendIndex, DotIndex, FixedDotIndex, GetBandIndex, LoneLooseSegWeight, LooseBendWeight,
|
||||
LooseDotIndex, LooseDotWeight, MakePrimitive, SeqLooseSegWeight,
|
||||
bend::{BendIndex, LooseBendWeight},
|
||||
dot::{DotIndex, FixedDotIndex, LooseDotIndex, LooseDotWeight},
|
||||
geometry::{GetBandIndex, MakePrimitive},
|
||||
seg::{LoneLooseSegWeight, SeqLooseSegWeight},
|
||||
},
|
||||
guide::{Guide, Head, HeadTrait, SegbendHead},
|
||||
layout::{Infringement, Layout, LayoutException},
|
||||
|
|
|
|||
272
src/geometry.rs
272
src/geometry.rs
|
|
@ -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>;
|
||||
}
|
||||
|
|
@ -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 {}
|
||||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
@ -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>;
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
#[macro_use]
|
||||
pub mod geometry;
|
||||
pub mod bend;
|
||||
pub mod dot;
|
||||
pub mod seg;
|
||||
|
|
@ -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 {}
|
||||
|
|
@ -8,7 +8,7 @@ use petgraph::stable_graph::NodeIndex;
|
|||
|
||||
// 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]
|
||||
pub trait GetNodeIndex {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,11 @@ use geo::Line;
|
|||
|
||||
use crate::{
|
||||
connectivity::BandIndex,
|
||||
geometry::{BendIndex, DotIndex, FixedDotIndex, GetBandIndex, LooseDotIndex, MakePrimitive},
|
||||
geometry::{
|
||||
bend::BendIndex,
|
||||
dot::{DotIndex, FixedDotIndex, LooseDotIndex},
|
||||
geometry::{GetBandIndex, MakePrimitive},
|
||||
},
|
||||
layout::Layout,
|
||||
math::{self, Circle, NoTangents},
|
||||
primitive::{GetCore, GetInnerOuter, GetOtherEnd, GetWeight, MakeShape},
|
||||
|
|
|
|||
|
|
@ -13,11 +13,18 @@ use crate::connectivity::{
|
|||
BandIndex, BandWeight, ComponentIndex, ComponentWeight, ConnectivityGraph, ConnectivityLabel,
|
||||
ConnectivityWeight, GetNet,
|
||||
};
|
||||
use crate::geometry::seg::SeqLooseSegWeight;
|
||||
use crate::geometry::{
|
||||
BendWeight, DotIndex, DotWeight, FixedBendIndex, FixedDotIndex, FixedDotWeight, FixedSegIndex,
|
||||
FixedSegWeight, GeometryGraph, GeometryIndex, GeometryLabel, GeometryWeight, GetComponentIndex,
|
||||
LoneLooseSegIndex, LoneLooseSegWeight, LooseBendIndex, LooseBendWeight, LooseDotIndex,
|
||||
LooseDotWeight, MakePrimitive, Retag, SegWeight, SeqLooseSegIndex, SeqLooseSegWeight,
|
||||
bend::{BendWeight, FixedBendIndex, LooseBendIndex, LooseBendWeight},
|
||||
dot::{DotIndex, DotWeight, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
|
||||
geometry::{
|
||||
GeometryGraph, GeometryIndex, GeometryLabel, GeometryWeight, GetComponentIndex,
|
||||
MakePrimitive, Retag,
|
||||
},
|
||||
seg::{
|
||||
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegWeight,
|
||||
SeqLooseSegIndex,
|
||||
},
|
||||
};
|
||||
use crate::graph::{GenericIndex, GetNodeIndex};
|
||||
use crate::guide::Guide;
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@ use petgraph::stable_graph::NodeIndex;
|
|||
|
||||
use crate::{
|
||||
geometry::{
|
||||
DotIndex, GeometryIndex, LoneLooseSegIndex, LooseBendIndex, LooseDotIndex, MakePrimitive,
|
||||
SeqLooseSegIndex,
|
||||
bend::LooseBendIndex,
|
||||
dot::{DotIndex, LooseDotIndex},
|
||||
geometry::{GeometryIndex, MakePrimitive},
|
||||
seg::{LoneLooseSegIndex, SeqLooseSegIndex},
|
||||
},
|
||||
graph::GetNodeIndex,
|
||||
layout::Layout,
|
||||
|
|
|
|||
|
|
@ -31,7 +31,9 @@ mod wraparoundable;
|
|||
use connectivity::BandIndex;
|
||||
use draw::DrawException;
|
||||
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 mesh::{Mesh, MeshEdgeReference, VertexIndex};
|
||||
use petgraph::visit::{EdgeRef, IntoEdgeReferences};
|
||||
|
|
@ -59,7 +61,6 @@ use pathfinder_resources::embedded::EmbeddedResourceLoader;
|
|||
use std::time::Duration;
|
||||
use tracer::{Trace, Tracer};
|
||||
|
||||
use crate::geometry::FixedDotWeight;
|
||||
use crate::math::Circle;
|
||||
use crate::router::Router;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,11 @@ use spade::{HasPosition, InsertionError, Point2};
|
|||
use crate::primitive::{GetCore, Primitive};
|
||||
use crate::triangulation::TriangulationEdgeReference;
|
||||
use crate::{
|
||||
geometry::{FixedBendIndex, FixedDotIndex, GeometryIndex, LooseBendIndex, MakePrimitive},
|
||||
geometry::{
|
||||
bend::{FixedBendIndex, LooseBendIndex},
|
||||
dot::FixedDotIndex,
|
||||
geometry::{GeometryIndex, MakePrimitive},
|
||||
},
|
||||
graph::GetNodeIndex,
|
||||
layout::Layout,
|
||||
primitive::MakeShape,
|
||||
|
|
|
|||
|
|
@ -5,13 +5,18 @@ use petgraph::stable_graph::NodeIndex;
|
|||
use petgraph::Direction::{Incoming, Outgoing};
|
||||
|
||||
use crate::connectivity::{BandIndex, ComponentIndex, GetNet};
|
||||
use crate::geometry::{
|
||||
BendIndex, DotIndex, FixedBendIndex, FixedBendWeight, FixedDotIndex, FixedDotWeight,
|
||||
FixedSegIndex, FixedSegWeight, GeometryIndex, GeometryLabel, GeometryWeight, GetBandIndex,
|
||||
GetComponentIndex, GetOffset, GetWidth, LoneLooseSegIndex, LoneLooseSegWeight, LooseBendIndex,
|
||||
LooseBendWeight, LooseDotIndex, LooseDotWeight, MakePrimitive, Retag, SegIndex,
|
||||
use crate::geometry::seg::{
|
||||
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegIndex,
|
||||
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::layout::Layout;
|
||||
use crate::loose::{Loose, LooseIndex};
|
||||
|
|
@ -317,7 +322,7 @@ pub type FixedDot<'a> = GenericPrimitive<'a, FixedDotWeight>;
|
|||
impl_fixed_primitive!(FixedDot, FixedDotWeight);
|
||||
|
||||
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| {
|
||||
let weight = self.layout.geometry().node_weight(node).unwrap();
|
||||
if matches!(weight, GeometryWeight::LoneLooseSeg(..)) {
|
||||
|
|
@ -345,13 +350,13 @@ impl<'a> GetLegs for FixedDot<'a> {
|
|||
.into_iter()
|
||||
.filter_map(
|
||||
|node| match self.layout.geometry().node_weight(node).unwrap() {
|
||||
GeometryWeight::FixedSeg(seg) => {
|
||||
GeometryWeight::FixedSeg(_seg) => {
|
||||
Some(SegIndex::Fixed(FixedSegIndex::new(node)))
|
||||
}
|
||||
GeometryWeight::LoneLooseSeg(seg) => {
|
||||
GeometryWeight::LoneLooseSeg(_seg) => {
|
||||
Some(SegIndex::LoneLoose(LoneLooseSegIndex::new(node).into()))
|
||||
}
|
||||
GeometryWeight::SeqLooseSeg(seg) => {
|
||||
GeometryWeight::SeqLooseSeg(_seg) => {
|
||||
Some(SegIndex::SeqLoose(SeqLooseSegIndex::new(node).into()))
|
||||
}
|
||||
_ => None,
|
||||
|
|
|
|||
|
|
@ -5,13 +5,15 @@ use spade::InsertionError;
|
|||
use thiserror::Error;
|
||||
|
||||
use crate::astar::{astar, AstarStrategy, PathTracker};
|
||||
use crate::connectivity::{BandIndex, GetNet};
|
||||
use crate::connectivity::BandIndex;
|
||||
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::layout::Layout;
|
||||
|
||||
use crate::math::Circle;
|
||||
use crate::mesh::{Mesh, MeshEdgeReference, VertexIndex};
|
||||
|
||||
use crate::primitive::MakeShape;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
use crate::{
|
||||
geometry::{GeometryIndex, LooseBendIndex, LooseDotIndex, SeqLooseSegIndex},
|
||||
geometry::{
|
||||
bend::LooseBendIndex, dot::LooseDotIndex, geometry::GeometryIndex, seg::SeqLooseSegIndex,
|
||||
},
|
||||
layout::Layout,
|
||||
primitive::{GetEnds, GetInterior, GetOtherEnd, LooseBend, LooseDot},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use contracts::debug_ensures;
|
|||
|
||||
use crate::{
|
||||
draw::{Draw, DrawException},
|
||||
geometry::{FixedDotIndex, LooseBendIndex},
|
||||
geometry::{bend::LooseBendIndex, dot::FixedDotIndex},
|
||||
guide::{BareHead, Head, SegbendHead},
|
||||
layout::Layout,
|
||||
mesh::{Mesh, VertexIndex},
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@ use petgraph::stable_graph::NodeIndex;
|
|||
|
||||
use crate::{
|
||||
geometry::{
|
||||
BendIndex, FixedBendIndex, FixedDotIndex, GeometryIndex, LooseBendIndex, MakePrimitive,
|
||||
bend::{BendIndex, FixedBendIndex, LooseBendIndex},
|
||||
dot::FixedDotIndex,
|
||||
geometry::{GeometryIndex, MakePrimitive},
|
||||
},
|
||||
graph::GetNodeIndex,
|
||||
layout::Layout,
|
||||
|
|
|
|||
Loading…
Reference in New Issue