geometry: provide basic internals for storing groupings

Will develop an interface in subsequent commits.
This commit is contained in:
Mikolaj Wielgus 2024-03-25 12:41:56 +00:00
parent e23f7de07e
commit 888a4ecbad
6 changed files with 237 additions and 115 deletions

View File

@ -20,6 +20,7 @@ use crate::drawing::{
bend::{FixedBendIndex, LooseBendIndex, LooseBendWeight},
dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
graph::{GeometryIndex, GeometryWeight, MakePrimitive},
grouping::{GroupingIndex, GroupingWeight},
primitive::{GenericPrimitive, GetCore, GetInnerOuter, GetJoints, GetOtherJoint, MakeShape},
seg::{
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegIndex,
@ -72,10 +73,12 @@ pub struct Drawing<R: RulesTrait> {
DotWeight,
SegWeight,
BendWeight,
GroupingWeight,
GeometryIndex,
DotIndex,
SegIndex,
BendIndex,
GroupingIndex,
>,
rules: R,
}
@ -789,10 +792,12 @@ impl<R: RulesTrait> Drawing<R> {
DotWeight,
SegWeight,
BendWeight,
GroupingWeight,
GeometryIndex,
DotIndex,
SegIndex,
BendIndex,
GroupingIndex,
> {
self.geometry_with_rtree.geometry()
}

67
src/drawing/grouping.rs Normal file
View File

@ -0,0 +1,67 @@
use enum_dispatch::enum_dispatch;
use petgraph::stable_graph::NodeIndex;
use crate::{
drawing::{
graph::{GeometryIndex, GeometryWeight, GetLayer, GetMaybeNet, MakePrimitive, Retag},
primitive::{GenericPrimitive, Primitive},
rules::RulesTrait,
Drawing,
},
graph::{GenericIndex, GetNodeIndex},
};
#[enum_dispatch(GetNodeIndex)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum GroupingIndex {
Solid(SolidGroupingIndex),
Pour(PourGroupingIndex),
}
#[enum_dispatch(GetLayer)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum GroupingWeight {
Solid(SolidGroupingWeight),
Pour(PourGroupingWeight),
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SolidGroupingWeight {
pub layer: u64,
pub maybe_net: Option<usize>,
}
impl<'a> GetLayer for SolidGroupingWeight {
fn layer(&self) -> u64 {
self.layer
}
}
impl<'a> GetMaybeNet for SolidGroupingWeight {
fn maybe_net(&self) -> Option<usize> {
self.maybe_net
}
}
pub type SolidGroupingIndex = GenericIndex<SolidGroupingWeight>;
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct PourGroupingWeight {
pub layer: u64,
pub maybe_net: Option<usize>,
}
impl<'a> GetLayer for PourGroupingWeight {
fn layer(&self) -> u64 {
self.layer
}
}
impl<'a> GetMaybeNet for PourGroupingWeight {
fn maybe_net(&self) -> Option<usize> {
self.maybe_net
}
}
pub type PourGroupingIndex = GenericIndex<PourGroupingWeight>;

View File

@ -4,6 +4,7 @@ pub mod bend;
pub mod collect;
pub mod dot;
mod drawing;
pub mod grouping;
pub mod guide;
pub mod loose;
pub mod primitive;

View File

@ -1,24 +1,27 @@
use enum_dispatch::enum_dispatch;
use petgraph::stable_graph::NodeIndex;
use crate::drawing::{
bend::{BendIndex, FixedBendWeight, LooseBendIndex, LooseBendWeight},
dot::{DotIndex, DotWeight, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
graph::{GeometryIndex, GeometryWeight, GetLayer, GetMaybeNet, Retag},
loose::LooseIndex,
rules::{Conditions, GetConditions, RulesTrait},
seg::{
FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegIndex, SeqLooseSegIndex,
SeqLooseSegWeight,
},
Drawing,
};
use crate::geometry::{
shape::{Shape, ShapeTrait},
GetOffset, GetWidth,
};
use crate::graph::{GenericIndex, GetNodeIndex};
use crate::layout::connectivity::{BandIndex, ContinentIndex};
use crate::{
drawing::{
bend::{BendIndex, FixedBendWeight, LooseBendIndex, LooseBendWeight},
dot::{DotIndex, DotWeight, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
graph::{GeometryIndex, GeometryWeight, GetLayer, GetMaybeNet, Retag},
loose::LooseIndex,
rules::{Conditions, GetConditions, RulesTrait},
seg::{
FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegIndex, SeqLooseSegIndex,
SeqLooseSegWeight,
},
Drawing,
},
geometry::CompoundWeight,
};
#[enum_dispatch]
pub trait GetDrawing<'a, R: RulesTrait> {
@ -181,12 +184,17 @@ impl<'a, W, R: RulesTrait> GenericPrimitive<'a, W, R> {
}
fn tagged_weight(&self) -> GeometryWeight {
*self
if let CompoundWeight::Primitive(weight) = *self
.drawing
.geometry()
.graph()
.node_weight(self.index.node_index())
.unwrap()
{
weight
} else {
unreachable!()
}
}
fn primitive<WW>(&self, index: GenericIndex<WW>) -> GenericPrimitive<WW, R> {
@ -250,9 +258,15 @@ impl<'a, R: RulesTrait> FixedDot<'a, R> {
.graph()
.node_weight(ni.node_index())
.unwrap();
if matches!(weight, GeometryWeight::LoneLooseSeg(..)) {
if matches!(
weight,
CompoundWeight::Primitive(GeometryWeight::LoneLooseSeg(..))
) {
Some(LoneLooseSegIndex::new(ni.node_index()).into())
} else if matches!(weight, GeometryWeight::SeqLooseSeg(..)) {
} else if matches!(
weight,
CompoundWeight::Primitive(GeometryWeight::SeqLooseSeg(..))
) {
Some(SeqLooseSegIndex::new(ni.node_index()).into())
} else {
None

View File

@ -54,42 +54,54 @@ pub enum GeometryLabel {
Core,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum CompoundWeight<PW, XW> {
Primitive(PW),
Grouping(XW),
}
pub trait DotWeightTrait<GW>: GetPos + SetPos + GetWidth + Into<GW> + Copy {}
pub trait SegWeightTrait<GW>: GetWidth + Into<GW> + Copy {}
pub trait BendWeightTrait<GW>: GetOffset + SetOffset + GetWidth + Into<GW> + Copy {}
#[derive(Debug)]
pub struct Geometry<
GW: GetWidth + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<GI> + Copy,
DW: DotWeightTrait<GW> + Copy,
SW: SegWeightTrait<GW> + Copy,
BW: BendWeightTrait<GW> + Copy,
GI: GetNodeIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Copy,
DI: GetNodeIndex + Into<GI> + Copy,
SI: GetNodeIndex + Into<GI> + Copy,
BI: GetNodeIndex + Into<GI> + Copy,
PW: GetWidth + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
DW: DotWeightTrait<PW>,
SW: SegWeightTrait<PW>,
BW: BendWeightTrait<PW>,
GW: Copy,
PI: GetNodeIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Copy,
DI: GetNodeIndex + Into<PI> + Copy,
SI: GetNodeIndex + Into<PI> + Copy,
BI: GetNodeIndex + Into<PI> + Copy,
GI: GetNodeIndex + Copy,
> {
graph: StableDiGraph<GW, GeometryLabel, usize>,
weight_marker: PhantomData<GW>,
graph: StableDiGraph<CompoundWeight<PW, GW>, GeometryLabel, usize>,
weight_marker: PhantomData<PW>,
dot_weight_marker: PhantomData<DW>,
seg_weight_marker: PhantomData<SW>,
bend_weight_marker: PhantomData<BW>,
index_marker: PhantomData<GI>,
grouping_weight_marker: PhantomData<GW>,
index_marker: PhantomData<PI>,
dot_index_marker: PhantomData<DI>,
seg_index_marker: PhantomData<SI>,
bend_index_marker: PhantomData<BI>,
grouping_index_marker: PhantomData<GI>,
}
impl<
GW: GetWidth + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<GI> + Copy,
DW: DotWeightTrait<GW> + Copy,
SW: SegWeightTrait<GW> + Copy,
BW: BendWeightTrait<GW> + Copy,
GI: GetNodeIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Copy,
DI: GetNodeIndex + Into<GI> + Copy,
SI: GetNodeIndex + Into<GI> + Copy,
BI: GetNodeIndex + Into<GI> + Copy,
> Geometry<GW, DW, SW, BW, GI, DI, SI, BI>
PW: GetWidth + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
DW: DotWeightTrait<PW>,
SW: SegWeightTrait<PW>,
BW: BendWeightTrait<PW>,
GW: Copy,
PI: GetNodeIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Copy,
DI: GetNodeIndex + Into<PI> + Copy,
SI: GetNodeIndex + Into<PI> + Copy,
BI: GetNodeIndex + Into<PI> + Copy,
GI: GetNodeIndex + Copy,
> Geometry<PW, DW, SW, BW, GW, PI, DI, SI, BI, GI>
{
pub fn new() -> Self {
Self {
@ -98,24 +110,32 @@ impl<
dot_weight_marker: PhantomData,
seg_weight_marker: PhantomData,
bend_weight_marker: PhantomData,
grouping_weight_marker: PhantomData,
index_marker: PhantomData,
dot_index_marker: PhantomData,
seg_index_marker: PhantomData,
bend_index_marker: PhantomData,
grouping_index_marker: PhantomData,
}
}
pub fn add_dot<W: DotWeightTrait<GW>>(&mut self, weight: W) -> GenericIndex<W> {
GenericIndex::<W>::new(self.graph.add_node(weight.into()))
pub fn add_dot<W: DotWeightTrait<PW>>(&mut self, weight: W) -> GenericIndex<W> {
GenericIndex::<W>::new(
self.graph
.add_node(CompoundWeight::Primitive(weight.into())),
)
}
pub fn add_seg<W: SegWeightTrait<GW>>(
pub fn add_seg<W: SegWeightTrait<PW>>(
&mut self,
from: DI,
to: DI,
weight: W,
) -> GenericIndex<W> {
let seg = GenericIndex::<W>::new(self.graph.add_node(weight.into()));
let seg = GenericIndex::<W>::new(
self.graph
.add_node(CompoundWeight::Primitive(weight.into())),
);
self.graph
.update_edge(from.node_index(), seg.node_index(), GeometryLabel::Joined);
@ -125,14 +145,17 @@ impl<
seg
}
pub fn add_bend<W: BendWeightTrait<GW>>(
pub fn add_bend<W: BendWeightTrait<PW>>(
&mut self,
from: DI,
to: DI,
core: DI,
weight: W,
) -> GenericIndex<W> {
let bend = GenericIndex::<W>::new(self.graph.add_node(weight.into()));
let bend = GenericIndex::<W>::new(
self.graph
.add_node(CompoundWeight::Primitive(weight.into())),
);
self.graph
.update_edge(from.node_index(), bend.node_index(), GeometryLabel::Joined);
@ -144,20 +167,22 @@ impl<
bend
}
pub fn remove(&mut self, node: GI) {
pub fn remove(&mut self, node: PI) {
self.graph.remove_node(node.node_index());
}
pub fn move_dot(&mut self, dot: DI, to: Point) {
let mut weight = self.dot_weight(dot);
weight.set_pos(to);
*self.graph.node_weight_mut(dot.node_index()).unwrap() = weight.into();
*self.graph.node_weight_mut(dot.node_index()).unwrap() =
CompoundWeight::Primitive(weight.into());
}
pub fn shift_bend(&mut self, bend: BI, offset: f64) {
let mut weight = self.bend_weight(bend);
weight.set_offset(offset);
*self.graph.node_weight_mut(bend.node_index()).unwrap() = weight.into();
*self.graph.node_weight_mut(bend.node_index()).unwrap() =
CompoundWeight::Primitive(weight.into());
}
pub fn flip_bend(&mut self, bend: BI) {
@ -218,7 +243,7 @@ impl<
Shape::Seg(SegShape {
from: self.dot_weight(from).pos(),
to: self.dot_weight(to).pos(),
width: self.weight(seg.node_index()).width(),
width: self.primitive_weight(seg.node_index()).width(),
})
}
@ -232,7 +257,7 @@ impl<
pos: core_weight.pos(),
r: self.inner_radius(bend),
},
width: self.weight(bend.node_index()).width(),
width: self.primitive_weight(bend.node_index()).width(),
})
}
@ -252,24 +277,28 @@ impl<
self.core_weight(bend).width() / 2.0 + r
}
fn weight(&self, index: NodeIndex<usize>) -> GW {
*self.graph.node_weight(index).unwrap()
fn primitive_weight(&self, index: NodeIndex<usize>) -> PW {
if let CompoundWeight::Primitive(weight) = *self.graph.node_weight(index).unwrap() {
weight
} else {
unreachable!()
}
}
pub fn dot_weight(&self, dot: DI) -> DW {
self.weight(dot.node_index())
self.primitive_weight(dot.node_index())
.try_into()
.unwrap_or_else(|_| unreachable!())
}
pub fn seg_weight(&self, seg: SI) -> SW {
self.weight(seg.node_index())
self.primitive_weight(seg.node_index())
.try_into()
.unwrap_or_else(|_| unreachable!())
}
pub fn bend_weight(&self, bend: BI) -> BW {
self.weight(bend.node_index())
self.primitive_weight(bend.node_index())
.try_into()
.unwrap_or_else(|_| unreachable!())
}
@ -286,7 +315,7 @@ impl<
)
})
.map(|ni| {
self.weight(ni)
self.primitive_weight(ni)
.try_into()
.unwrap_or_else(|_| unreachable!())
})
@ -306,7 +335,7 @@ impl<
)
})
.map(|ni| {
self.weight(ni)
self.primitive_weight(ni)
.retag(ni)
.try_into()
.unwrap_or_else(|_| unreachable!())
@ -326,7 +355,7 @@ impl<
)
})
.map(|ni| {
self.weight(ni)
self.primitive_weight(ni)
.retag(ni)
.try_into()
.unwrap_or_else(|_| unreachable!())
@ -347,7 +376,7 @@ impl<
)
})
.map(|ni| {
self.weight(ni)
self.primitive_weight(ni)
.retag(ni)
.try_into()
.unwrap_or_else(|_| unreachable!())
@ -367,7 +396,7 @@ impl<
)
})
.map(|ni| {
self.weight(ni)
self.primitive_weight(ni)
.retag(ni)
.try_into()
.unwrap_or_else(|_| unreachable!())
@ -375,7 +404,7 @@ impl<
.next()
}
pub fn joineds(&self, node: GI) -> impl Iterator<Item = GI> + '_ {
pub fn joineds(&self, node: PI) -> impl Iterator<Item = PI> + '_ {
self.graph
.neighbors_undirected(node.node_index())
.filter(move |ni| {
@ -392,7 +421,7 @@ impl<
)
})
.map(|ni| {
self.weight(ni)
self.primitive_weight(ni)
.retag(ni)
.try_into()
.unwrap_or_else(|_| unreachable!())
@ -423,7 +452,7 @@ impl<
self.joineds(dot.into()).filter_map(|ni| ni.try_into().ok())
}
pub fn graph(&self) -> &StableDiGraph<GW, GeometryLabel, usize> {
pub fn graph(&self) -> &StableDiGraph<CompoundWeight<PW, GW>, GeometryLabel, usize> {
&self.graph
}
}

View File

@ -7,14 +7,14 @@ use rstar::{primitives::GeomWithData, RTree, RTreeObject, AABB};
use crate::{
drawing::graph::{GetLayer, Retag},
geometry::{
shape::{Shape, ShapeTrait},
BendWeightTrait, CompoundWeight, DotWeightTrait, Geometry, GeometryLabel, GetWidth,
SegWeightTrait,
},
graph::{GenericIndex, GetNodeIndex},
};
use super::{
shape::{Shape, ShapeTrait},
BendWeightTrait, DotWeightTrait, Geometry, GeometryLabel, GetWidth, SegWeightTrait,
};
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Bbox {
aabb: AABB<[f64; 3]>,
@ -39,23 +39,25 @@ type BboxedIndex<GI> = GeomWithData<Bbox, GI>;
#[derive(Debug)]
pub struct GeometryWithRtree<
GW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<GI> + Copy,
DW: DotWeightTrait<GW> + GetLayer + Copy,
SW: SegWeightTrait<GW> + GetLayer + Copy,
BW: BendWeightTrait<GW> + GetLayer + Copy,
GI: GetNodeIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Copy,
DI: GetNodeIndex + Into<GI> + Copy,
SI: GetNodeIndex + Into<GI> + Copy,
BI: GetNodeIndex + Into<GI> + Copy,
PW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
DW: DotWeightTrait<PW> + GetLayer,
SW: SegWeightTrait<PW> + GetLayer,
BW: BendWeightTrait<PW> + GetLayer,
GW: Copy,
PI: GetNodeIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Copy,
DI: GetNodeIndex + Into<PI> + Copy,
SI: GetNodeIndex + Into<PI> + Copy,
BI: GetNodeIndex + Into<PI> + Copy,
GI: GetNodeIndex + Copy,
> {
geometry: Geometry<GW, DW, SW, BW, GI, DI, SI, BI>,
rtree: RTree<BboxedIndex<GI>>,
geometry: Geometry<PW, DW, SW, BW, GW, PI, DI, SI, BI, GI>,
rtree: RTree<BboxedIndex<PI>>,
layer_count: u64,
weight_marker: PhantomData<GW>,
weight_marker: PhantomData<PW>,
dot_weight_marker: PhantomData<DW>,
seg_weight_marker: PhantomData<SW>,
bend_weight_marker: PhantomData<BW>,
index_marker: PhantomData<GI>,
index_marker: PhantomData<PI>,
dot_index_marker: PhantomData<DI>,
seg_index_marker: PhantomData<SI>,
bend_index_marker: PhantomData<BI>,
@ -64,19 +66,21 @@ pub struct GeometryWithRtree<
#[debug_invariant(self.test_envelopes())]
#[debug_invariant(self.geometry.graph().node_count() == self.rtree.size())]
impl<
GW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<GI> + Copy,
DW: DotWeightTrait<GW> + GetLayer + Copy,
SW: SegWeightTrait<GW> + GetLayer + Copy,
BW: BendWeightTrait<GW> + GetLayer + Copy,
GI: GetNodeIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + PartialEq + Copy,
DI: GetNodeIndex + Into<GI> + Copy,
SI: GetNodeIndex + Into<GI> + Copy,
BI: GetNodeIndex + Into<GI> + Copy,
> GeometryWithRtree<GW, DW, SW, BW, GI, DI, SI, BI>
PW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
DW: DotWeightTrait<PW> + GetLayer,
SW: SegWeightTrait<PW> + GetLayer,
BW: BendWeightTrait<PW> + GetLayer,
GW: Copy,
PI: GetNodeIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + PartialEq + Copy,
DI: GetNodeIndex + Into<PI> + Copy,
SI: GetNodeIndex + Into<PI> + Copy,
BI: GetNodeIndex + Into<PI> + Copy,
GI: GetNodeIndex + Copy,
> GeometryWithRtree<PW, DW, SW, BW, GW, PI, DI, SI, BI, GI>
{
pub fn new(layer_count: u64) -> Self {
Self {
geometry: Geometry::<GW, DW, SW, BW, GI, DI, SI, BI>::new(),
geometry: Geometry::<PW, DW, SW, BW, GW, PI, DI, SI, BI, GI>::new(),
rtree: RTree::new(),
layer_count,
weight_marker: PhantomData,
@ -90,9 +94,9 @@ impl<
}
}
pub fn add_dot<W: DotWeightTrait<GW> + GetLayer>(&mut self, weight: W) -> GenericIndex<W>
pub fn add_dot<W: DotWeightTrait<PW> + GetLayer>(&mut self, weight: W) -> GenericIndex<W>
where
GenericIndex<W>: Into<GI>,
GenericIndex<W>: Into<PI>,
{
let dot = self.geometry.add_dot(weight);
self.rtree.insert(BboxedIndex::new(
@ -107,14 +111,14 @@ impl<
dot
}
pub fn add_seg<W: SegWeightTrait<GW> + GetLayer>(
pub fn add_seg<W: SegWeightTrait<PW> + GetLayer>(
&mut self,
from: DI,
to: DI,
weight: W,
) -> GenericIndex<W>
where
GenericIndex<W>: Into<GI>,
GenericIndex<W>: Into<PI>,
{
let seg = self.geometry.add_seg(from, to, weight);
self.rtree.insert(BboxedIndex::new(
@ -129,7 +133,7 @@ impl<
seg
}
pub fn add_bend<W: BendWeightTrait<GW> + GetLayer>(
pub fn add_bend<W: BendWeightTrait<PW> + GetLayer>(
&mut self,
from: DI,
to: DI,
@ -137,7 +141,7 @@ impl<
weight: W,
) -> GenericIndex<W>
where
GenericIndex<W>: Into<GI>,
GenericIndex<W>: Into<PI>,
{
let bend = self.geometry.add_bend(from, to, core, weight);
self.rtree.insert(BboxedIndex::new(
@ -245,70 +249,72 @@ impl<
}
impl<
GW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<GI> + Copy,
DW: DotWeightTrait<GW> + GetLayer + Copy,
SW: SegWeightTrait<GW> + GetLayer + Copy,
BW: BendWeightTrait<GW> + GetLayer + Copy,
GI: GetNodeIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + PartialEq + Copy,
DI: GetNodeIndex + Into<GI> + Copy,
SI: GetNodeIndex + Into<GI> + Copy,
BI: GetNodeIndex + Into<GI> + Copy,
> GeometryWithRtree<GW, DW, SW, BW, GI, DI, SI, BI>
PW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
DW: DotWeightTrait<PW> + GetLayer,
SW: SegWeightTrait<PW> + GetLayer,
BW: BendWeightTrait<PW> + GetLayer,
GW: Copy,
PI: GetNodeIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + PartialEq + Copy,
DI: GetNodeIndex + Into<PI> + Copy,
SI: GetNodeIndex + Into<PI> + Copy,
BI: GetNodeIndex + Into<PI> + Copy,
GI: GetNodeIndex + Copy,
> GeometryWithRtree<PW, DW, SW, BW, GW, PI, DI, SI, BI, GI>
{
fn make_dot_bbox(&self, dot: DI) -> BboxedIndex<GI> {
fn make_dot_bbox(&self, dot: DI) -> BboxedIndex<PI> {
BboxedIndex::new(
Bbox::new(&self.geometry.dot_shape(dot), self.layer(dot.into())),
dot.into(),
)
}
fn make_seg_bbox(&self, seg: SI) -> BboxedIndex<GI> {
fn make_seg_bbox(&self, seg: SI) -> BboxedIndex<PI> {
BboxedIndex::new(
Bbox::new(&self.geometry.seg_shape(seg), self.layer(seg.into())),
seg.into(),
)
}
fn make_bend_bbox(&self, bend: BI) -> BboxedIndex<GI> {
fn make_bend_bbox(&self, bend: BI) -> BboxedIndex<PI> {
BboxedIndex::new(
Bbox::new(&self.geometry.bend_shape(bend), self.layer(bend.into())),
bend.into(),
)
}
fn shape(&self, index: GI) -> Shape {
if let Ok(dot) = <GI as TryInto<DI>>::try_into(index) {
fn shape(&self, index: PI) -> Shape {
if let Ok(dot) = <PI as TryInto<DI>>::try_into(index) {
self.geometry.dot_shape(dot)
} else if let Ok(seg) = <GI as TryInto<SI>>::try_into(index) {
} else if let Ok(seg) = <PI as TryInto<SI>>::try_into(index) {
self.geometry.seg_shape(seg)
} else if let Ok(bend) = <GI as TryInto<BI>>::try_into(index) {
} else if let Ok(bend) = <PI as TryInto<BI>>::try_into(index) {
self.geometry.bend_shape(bend)
} else {
unreachable!();
}
}
fn layer(&self, index: GI) -> u64 {
if let Ok(dot) = <GI as TryInto<DI>>::try_into(index) {
fn layer(&self, index: PI) -> u64 {
if let Ok(dot) = <PI as TryInto<DI>>::try_into(index) {
self.geometry.dot_weight(dot).layer()
} else if let Ok(seg) = <GI as TryInto<SI>>::try_into(index) {
} else if let Ok(seg) = <PI as TryInto<SI>>::try_into(index) {
self.geometry.seg_weight(seg).layer()
} else if let Ok(bend) = <GI as TryInto<BI>>::try_into(index) {
} else if let Ok(bend) = <PI as TryInto<BI>>::try_into(index) {
self.geometry.bend_weight(bend).layer()
} else {
unreachable!();
}
}
pub fn geometry(&self) -> &Geometry<GW, DW, SW, BW, GI, DI, SI, BI> {
pub fn geometry(&self) -> &Geometry<PW, DW, SW, BW, GW, PI, DI, SI, BI, GI> {
&self.geometry
}
pub fn rtree(&self) -> &RTree<BboxedIndex<GI>> {
pub fn rtree(&self) -> &RTree<BboxedIndex<PI>> {
&self.rtree
}
pub fn graph(&self) -> &StableDiGraph<GW, GeometryLabel, usize> {
pub fn graph(&self) -> &StableDiGraph<CompoundWeight<PW, GW>, GeometryLabel, usize> {
self.geometry.graph()
}