fix(geometry/compound): rename CompoundEntryKind -> CompoundEntryLabel

This commit is contained in:
Ellen Emilia Anna Zscheile 2025-04-30 14:18:22 +02:00
parent e74f5e009a
commit 83d9fce38c
18 changed files with 290 additions and 283 deletions

View File

@ -23,7 +23,7 @@ use crate::{
}, },
geometry::{edit::ApplyGeometryEdit, GenericNode, GetLayer}, geometry::{edit::ApplyGeometryEdit, GenericNode, GetLayer},
graph::{GenericIndex, MakeRef}, graph::{GenericIndex, MakeRef},
layout::{poly::PolyWeight, CompoundEntryKind, CompoundWeight, Layout, LayoutEdit, NodeIndex}, layout::{poly::PolyWeight, CompoundEntryLabel, CompoundWeight, Layout, LayoutEdit, NodeIndex},
}; };
/// Represents a band between two pins. /// Represents a band between two pins.
@ -225,7 +225,7 @@ impl<M: AccessMesadata>
SegWeight, SegWeight,
BendWeight, BendWeight,
CompoundWeight, CompoundWeight,
CompoundEntryKind, CompoundEntryLabel,
PrimitiveIndex, PrimitiveIndex,
DotIndex, DotIndex,
SegIndex, SegIndex,

View File

@ -37,28 +37,28 @@ impl From<BandTermsegIndex> for LooseIndex {
} }
} }
impl<'a, CW: 'a, Cek: 'a, R: 'a> MakeRef<'a, Drawing<CW, Cek, R>> for BandTermsegIndex { impl<'a, CW: 'a, Cel: 'a, R: 'a> MakeRef<'a, Drawing<CW, Cel, R>> for BandTermsegIndex {
type Output = BandRef<'a, CW, Cek, R>; type Output = BandRef<'a, CW, Cel, R>;
fn ref_(&self, drawing: &'a Drawing<CW, Cek, R>) -> BandRef<'a, CW, Cek, R> { fn ref_(&self, drawing: &'a Drawing<CW, Cel, R>) -> BandRef<'a, CW, Cel, R> {
BandRef::new(*self, drawing) BandRef::new(*self, drawing)
} }
} }
pub struct BandRef<'a, CW, Cek, R> { pub struct BandRef<'a, CW, Cel, R> {
first_seg: BandTermsegIndex, first_seg: BandTermsegIndex,
drawing: &'a Drawing<CW, Cek, R>, drawing: &'a Drawing<CW, Cel, R>,
} }
impl<'a, CW: 'a, Cek: 'a, R: 'a> BandRef<'a, CW, Cek, R> { impl<'a, CW: 'a, Cel: 'a, R: 'a> BandRef<'a, CW, Cel, R> {
pub fn new( pub fn new(
first_seg: BandTermsegIndex, first_seg: BandTermsegIndex,
drawing: &'a Drawing<CW, Cek, R>, drawing: &'a Drawing<CW, Cel, R>,
) -> BandRef<'a, CW, Cek, R> { ) -> BandRef<'a, CW, Cel, R> {
Self { first_seg, drawing } Self { first_seg, drawing }
} }
} }
impl<CW: Clone, Cek: Copy, R: AccessRules> MeasureLength for BandRef<'_, CW, Cek, R> { impl<CW: Clone, Cel: Copy, R: AccessRules> MeasureLength for BandRef<'_, CW, Cel, R> {
fn length(&self) -> f64 { fn length(&self) -> f64 {
match self.first_seg { match self.first_seg {
BandTermsegIndex::Straight(seg) => { BandTermsegIndex::Straight(seg) => {

View File

@ -25,7 +25,7 @@ pub trait Collect {
fn wraparounded_bows(&self, around: GearIndex) -> Vec<PrimitiveIndex>; fn wraparounded_bows(&self, around: GearIndex) -> Vec<PrimitiveIndex>;
} }
impl<CW: Clone, Cek: Copy, R: AccessRules> Collect for Drawing<CW, Cek, R> { impl<CW: Clone, Cel: Copy, R: AccessRules> Collect for Drawing<CW, Cel, R> {
fn loose_band_uid(&self, start_loose: LooseIndex) -> BandUid { fn loose_band_uid(&self, start_loose: LooseIndex) -> BandUid {
BandUid::from(( BandUid::from((
self.loose_band_first_seg(start_loose), self.loose_band_first_seg(start_loose),
@ -92,7 +92,7 @@ trait CollectPrivate {
fn loose_band_last_seg(&self, start_loose: LooseIndex) -> BandTermsegIndex; fn loose_band_last_seg(&self, start_loose: LooseIndex) -> BandTermsegIndex;
} }
impl<CW: Clone, Cek: Copy, R: AccessRules> CollectPrivate for Drawing<CW, Cek, R> { impl<CW: Clone, Cel: Copy, R: AccessRules> CollectPrivate for Drawing<CW, Cel, R> {
fn loose_band_first_seg(&self, start_loose: LooseIndex) -> BandTermsegIndex { fn loose_band_first_seg(&self, start_loose: LooseIndex) -> BandTermsegIndex {
if let LooseIndex::LoneSeg(seg) = start_loose { if let LooseIndex::LoneSeg(seg) = start_loose {
return BandTermsegIndex::Straight(seg); return BandTermsegIndex::Straight(seg);

View File

@ -93,12 +93,12 @@ pub struct Collision(pub PrimitiveShape, pub PrimitiveIndex);
#[error("{1:?} is already connected to net {0}")] #[error("{1:?} is already connected to net {0}")]
pub struct AlreadyConnected(pub usize, pub PrimitiveIndex); pub struct AlreadyConnected(pub usize, pub PrimitiveIndex);
pub type DrawingEdit<CW, Cek> = GeometryEdit< pub type DrawingEdit<CW, Cel> = GeometryEdit<
DotWeight, DotWeight,
SegWeight, SegWeight,
BendWeight, BendWeight,
CW, CW,
Cek, Cel,
PrimitiveIndex, PrimitiveIndex,
DotIndex, DotIndex,
SegIndex, SegIndex,
@ -106,14 +106,14 @@ pub type DrawingEdit<CW, Cek> = GeometryEdit<
>; >;
#[derive(Clone, Debug, Getters)] #[derive(Clone, Debug, Getters)]
pub struct Drawing<CW, Cek, R> { pub struct Drawing<CW, Cel, R> {
recording_geometry_with_rtree: RecordingGeometryWithRtree< recording_geometry_with_rtree: RecordingGeometryWithRtree<
PrimitiveWeight, PrimitiveWeight,
DotWeight, DotWeight,
SegWeight, SegWeight,
BendWeight, BendWeight,
CW, CW,
Cek, Cel,
PrimitiveIndex, PrimitiveIndex,
DotIndex, DotIndex,
SegIndex, SegIndex,
@ -122,7 +122,7 @@ pub struct Drawing<CW, Cek, R> {
rules: R, rules: R,
} }
impl<CW, Cek, R> Drawing<CW, Cek, R> { impl<CW, Cel, R> Drawing<CW, Cel, R> {
pub fn geometry( pub fn geometry(
&self, &self,
) -> &Geometry< ) -> &Geometry<
@ -131,7 +131,7 @@ impl<CW, Cek, R> Drawing<CW, Cek, R> {
SegWeight, SegWeight,
BendWeight, BendWeight,
CW, CW,
Cek, Cel,
PrimitiveIndex, PrimitiveIndex,
DotIndex, DotIndex,
SegIndex, SegIndex,
@ -148,11 +148,11 @@ impl<CW, Cek, R> Drawing<CW, Cek, R> {
&mut self.rules &mut self.rules
} }
pub fn primitive<W>(&self, index: GenericIndex<W>) -> GenericPrimitive<'_, W, CW, Cek, R> { pub fn primitive<W>(&self, index: GenericIndex<W>) -> GenericPrimitive<'_, W, CW, Cel, R> {
GenericPrimitive::new(index, self) GenericPrimitive::new(index, self)
} }
pub fn loose(&self, index: LooseIndex) -> Loose<'_, CW, Cek, R> { pub fn loose(&self, index: LooseIndex) -> Loose<'_, CW, Cel, R> {
Loose::new(index, self) Loose::new(index, self)
} }
@ -165,7 +165,7 @@ impl<CW, Cek, R> Drawing<CW, Cek, R> {
} }
} }
impl<CW: Clone, Cek: Copy, R> Drawing<CW, Cek, R> { impl<CW: Clone, Cel: Copy, R> Drawing<CW, Cel, R> {
pub fn compound_weight(&self, compound: GenericIndex<CW>) -> &CW { pub fn compound_weight(&self, compound: GenericIndex<CW>) -> &CW {
self.recording_geometry_with_rtree.compound_weight(compound) self.recording_geometry_with_rtree.compound_weight(compound)
} }
@ -173,13 +173,13 @@ impl<CW: Clone, Cek: Copy, R> Drawing<CW, Cek, R> {
pub fn compounds<'a, W: 'a>( pub fn compounds<'a, W: 'a>(
&'a self, &'a self,
node: GenericIndex<W>, node: GenericIndex<W>,
) -> impl Iterator<Item = (Cek, GenericIndex<CW>)> + 'a { ) -> impl Iterator<Item = (Cel, GenericIndex<CW>)> + 'a {
self.recording_geometry_with_rtree.compounds(node) self.recording_geometry_with_rtree.compounds(node)
} }
} }
#[debug_invariant(self.test_if_looses_dont_infringe_each_other())] #[debug_invariant(self.test_if_looses_dont_infringe_each_other())]
impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> { impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
pub fn new(rules: R, layer_count: usize) -> Self { pub fn new(rules: R, layer_count: usize) -> Self {
Self { Self {
recording_geometry_with_rtree: RecordingGeometryWithRtree::new(layer_count), recording_geometry_with_rtree: RecordingGeometryWithRtree::new(layer_count),
@ -189,7 +189,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
pub fn remove_band( pub fn remove_band(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
band: BandTermsegIndex, band: BandTermsegIndex,
) -> Result<(), DrawingException> { ) -> Result<(), DrawingException> {
match band { match band {
@ -266,7 +266,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] #[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))]
pub fn add_fixed_dot( pub fn add_fixed_dot(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
weight: FixedDotWeight, weight: FixedDotWeight,
) -> Result<FixedDotIndex, Infringement> { ) -> Result<FixedDotIndex, Infringement> {
self.add_dot_with_infringables(recorder, weight, Some(&[])) self.add_dot_with_infringables(recorder, weight, Some(&[]))
@ -274,7 +274,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(self.recording_geometry_with_rtree.graph().node_count() == old(self.recording_geometry_with_rtree.graph().node_count() - 1))] #[debug_ensures(self.recording_geometry_with_rtree.graph().node_count() == old(self.recording_geometry_with_rtree.graph().node_count() - 1))]
#[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] #[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))]
pub fn remove_fixed_dot(&mut self, recorder: &mut DrawingEdit<CW, Cek>, dot: FixedDotIndex) { pub fn remove_fixed_dot(&mut self, recorder: &mut DrawingEdit<CW, Cel>, dot: FixedDotIndex) {
self.recording_geometry_with_rtree self.recording_geometry_with_rtree
.remove_dot(recorder, dot.into()); .remove_dot(recorder, dot.into());
} }
@ -283,7 +283,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] #[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))]
pub fn add_fixed_dot_infringably( pub fn add_fixed_dot_infringably(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
weight: FixedDotWeight, weight: FixedDotWeight,
) -> FixedDotIndex { ) -> FixedDotIndex {
self.add_dot_infringably(recorder, weight) self.add_dot_infringably(recorder, weight)
@ -293,7 +293,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().node_count() == old(self.recording_geometry_with_rtree.graph().node_count()))] #[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().node_count() == old(self.recording_geometry_with_rtree.graph().node_count()))]
fn add_dot_with_infringables<W: AccessDotWeight + Into<PrimitiveWeight> + GetLayer>( fn add_dot_with_infringables<W: AccessDotWeight + Into<PrimitiveWeight> + GetLayer>(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
weight: W, weight: W,
infringables: Option<&[PrimitiveIndex]>, infringables: Option<&[PrimitiveIndex]>,
) -> Result<GenericIndex<W>, Infringement> ) -> Result<GenericIndex<W>, Infringement>
@ -311,7 +311,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] #[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))]
pub fn add_fixed_seg( pub fn add_fixed_seg(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
from: FixedDotIndex, from: FixedDotIndex,
to: FixedDotIndex, to: FixedDotIndex,
weight: FixedSegWeight, weight: FixedSegWeight,
@ -323,7 +323,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count() + 2))] #[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count() + 2))]
pub fn add_fixed_seg_infringably( pub fn add_fixed_seg_infringably(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
from: FixedDotIndex, from: FixedDotIndex,
to: FixedDotIndex, to: FixedDotIndex,
weight: FixedSegWeight, weight: FixedSegWeight,
@ -337,7 +337,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] #[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))]
pub fn add_lone_loose_seg( pub fn add_lone_loose_seg(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
from: FixedDotIndex, from: FixedDotIndex,
to: FixedDotIndex, to: FixedDotIndex,
weight: LoneLooseSegWeight, weight: LoneLooseSegWeight,
@ -353,7 +353,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] #[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))]
pub fn add_seq_loose_seg( pub fn add_seq_loose_seg(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
from: DotIndex, from: DotIndex,
to: LooseDotIndex, to: LooseDotIndex,
weight: SeqLooseSegWeight, weight: SeqLooseSegWeight,
@ -368,7 +368,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] #[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))]
fn add_seg_with_infringables<W: AccessSegWeight + Into<PrimitiveWeight> + GetLayer>( fn add_seg_with_infringables<W: AccessSegWeight + Into<PrimitiveWeight> + GetLayer>(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
from: DotIndex, from: DotIndex,
to: DotIndex, to: DotIndex,
weight: W, weight: W,
@ -390,7 +390,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] #[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))]
fn add_loose_bend_with_infringables( fn add_loose_bend_with_infringables(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
from: LooseDotIndex, from: LooseDotIndex,
to: LooseDotIndex, to: LooseDotIndex,
around: GearIndex, around: GearIndex,
@ -455,7 +455,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] #[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))]
fn add_core_bend_with_infringables<W: AccessBendWeight + Into<PrimitiveWeight> + GetLayer>( fn add_core_bend_with_infringables<W: AccessBendWeight + Into<PrimitiveWeight> + GetLayer>(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
from: DotIndex, from: DotIndex,
to: DotIndex, to: DotIndex,
core: FixedDotIndex, core: FixedDotIndex,
@ -479,7 +479,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] #[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))]
fn add_outer_bend_with_infringables( fn add_outer_bend_with_infringables(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
from: LooseDotIndex, from: LooseDotIndex,
to: LooseDotIndex, to: LooseDotIndex,
inner: BendIndex, inner: BendIndex,
@ -525,7 +525,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(self.recording_geometry_with_rtree.graph().node_count() == old(self.recording_geometry_with_rtree.graph().node_count()))] #[debug_ensures(self.recording_geometry_with_rtree.graph().node_count() == old(self.recording_geometry_with_rtree.graph().node_count()))]
#[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] #[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))]
pub fn flip_bend(&mut self, recorder: &mut DrawingEdit<CW, Cek>, bend: FixedBendIndex) { pub fn flip_bend(&mut self, recorder: &mut DrawingEdit<CW, Cel>, bend: FixedBendIndex) {
self.recording_geometry_with_rtree self.recording_geometry_with_rtree
.flip_bend(recorder, bend.into()); .flip_bend(recorder, bend.into());
} }
@ -536,7 +536,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
|| self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count() + 1))] || self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count() + 1))]
fn reattach_bend( fn reattach_bend(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
bend: LooseBendIndex, bend: LooseBendIndex,
maybe_new_inner: Option<LooseBendIndex>, maybe_new_inner: Option<LooseBendIndex>,
) { ) {
@ -553,7 +553,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] #[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))]
pub fn insert_cane( pub fn insert_cane(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
from: DotIndex, from: DotIndex,
around: GearIndex, around: GearIndex,
dot_weight: LooseDotWeight, dot_weight: LooseDotWeight,
@ -597,7 +597,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
fn update_this_and_outward_bows_intern( fn update_this_and_outward_bows_intern(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
around: LooseBendIndex, around: LooseBendIndex,
) -> Result<(), DrawingException> { ) -> Result<(), DrawingException> {
let mut maybe_rail = Some(around); let mut maybe_rail = Some(around);
@ -676,7 +676,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] #[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))]
fn update_this_and_outward_bows( fn update_this_and_outward_bows(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
around: LooseBendIndex, around: LooseBendIndex,
) -> Result<(), DrawingException> { ) -> Result<(), DrawingException> {
let mut temp_recorder = DrawingEdit::new(); let mut temp_recorder = DrawingEdit::new();
@ -696,7 +696,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] #[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))]
pub fn add_cane( pub fn add_cane(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
from: DotIndex, from: DotIndex,
around: GearIndex, around: GearIndex,
dot_weight: LooseDotWeight, dot_weight: LooseDotWeight,
@ -722,7 +722,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] #[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))]
fn add_cane_with_infringables( fn add_cane_with_infringables(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
from: DotIndex, from: DotIndex,
around: GearIndex, around: GearIndex,
dot_weight: LooseDotWeight, dot_weight: LooseDotWeight,
@ -781,7 +781,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(self.recording_geometry_with_rtree.graph().node_count() == old(self.recording_geometry_with_rtree.graph().node_count() - 4))] #[debug_ensures(self.recording_geometry_with_rtree.graph().node_count() == old(self.recording_geometry_with_rtree.graph().node_count() - 4))]
pub fn remove_cane( pub fn remove_cane(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
cane: &Cane, cane: &Cane,
face: LooseDotIndex, face: LooseDotIndex,
) { ) {
@ -818,7 +818,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] #[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))]
pub fn move_dot( pub fn move_dot(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
dot: DotIndex, dot: DotIndex,
to: Point, to: Point,
) -> Result<(), Infringement> { ) -> Result<(), Infringement> {
@ -832,7 +832,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] #[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))]
fn move_dot_with_infringables( fn move_dot_with_infringables(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
dot: DotIndex, dot: DotIndex,
to: Point, to: Point,
infringables: Option<&[PrimitiveIndex]>, infringables: Option<&[PrimitiveIndex]>,
@ -868,7 +868,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] #[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))]
fn shift_bend_with_infringables( fn shift_bend_with_infringables(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
bend: BendIndex, bend: BendIndex,
offset: f64, offset: f64,
infringables: Option<&[PrimitiveIndex]>, infringables: Option<&[PrimitiveIndex]>,
@ -910,12 +910,12 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
} }
} }
impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> { impl<CW: Clone, Cel: Copy, R: AccessRules> Drawing<CW, Cel, R> {
#[debug_ensures(self.recording_geometry_with_rtree.graph().node_count() == old(self.recording_geometry_with_rtree.graph().node_count() + 1))] #[debug_ensures(self.recording_geometry_with_rtree.graph().node_count() == old(self.recording_geometry_with_rtree.graph().node_count() + 1))]
#[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] #[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))]
fn add_dot_infringably<W: AccessDotWeight + Into<PrimitiveWeight> + GetLayer>( fn add_dot_infringably<W: AccessDotWeight + Into<PrimitiveWeight> + GetLayer>(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
weight: W, weight: W,
) -> GenericIndex<W> ) -> GenericIndex<W>
where where
@ -928,7 +928,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count() + 2))] #[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count() + 2))]
fn add_seg_infringably<W: AccessSegWeight + Into<PrimitiveWeight> + GetLayer>( fn add_seg_infringably<W: AccessSegWeight + Into<PrimitiveWeight> + GetLayer>(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
from: DotIndex, from: DotIndex,
to: DotIndex, to: DotIndex,
weight: W, weight: W,
@ -942,7 +942,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
pub fn add_compound( pub fn add_compound(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
weight: CW, weight: CW,
) -> GenericIndex<CW> { ) -> GenericIndex<CW> {
self.recording_geometry_with_rtree self.recording_geometry_with_rtree
@ -951,7 +951,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
pub fn remove_compound( pub fn remove_compound(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
compound: GenericIndex<CW>, compound: GenericIndex<CW>,
) { ) {
self.recording_geometry_with_rtree self.recording_geometry_with_rtree
@ -960,13 +960,17 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
pub fn add_to_compound<W>( pub fn add_to_compound<W>(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
primitive: GenericIndex<W>, primitive: GenericIndex<W>,
entry_kind: Cek, entry_label: Cel,
compound: GenericIndex<CW>, compound: GenericIndex<CW>,
) { ) {
self.recording_geometry_with_rtree self.recording_geometry_with_rtree.add_to_compound(
.add_to_compound(recorder, primitive, entry_kind, compound); recorder,
primitive,
entry_label,
compound,
);
} }
#[debug_ensures(ret.is_ok() -> self.recording_geometry_with_rtree.graph().node_count() == old(self.recording_geometry_with_rtree.graph().node_count()))] #[debug_ensures(ret.is_ok() -> self.recording_geometry_with_rtree.graph().node_count() == old(self.recording_geometry_with_rtree.graph().node_count()))]
@ -974,7 +978,7 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
#[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().node_count() == old(self.recording_geometry_with_rtree.graph().node_count() - 1))] #[debug_ensures(ret.is_err() -> self.recording_geometry_with_rtree.graph().node_count() == old(self.recording_geometry_with_rtree.graph().node_count() - 1))]
fn fail_and_remove_if_infringes_except( fn fail_and_remove_if_infringes_except(
&mut self, &mut self,
recorder: &mut DrawingEdit<CW, Cek>, recorder: &mut DrawingEdit<CW, Cel>,
node: PrimitiveIndex, node: PrimitiveIndex,
maybe_except: Option<&[PrimitiveIndex]>, maybe_except: Option<&[PrimitiveIndex]>,
) -> Result<(), Infringement> { ) -> Result<(), Infringement> {
@ -1172,20 +1176,20 @@ impl<CW: Clone, Cek: Copy, R: AccessRules> Drawing<CW, Cek, R> {
} }
} }
impl<CW: Clone, Cek: Copy, R: AccessRules> impl<CW: Clone, Cel: Copy, R: AccessRules>
ApplyGeometryEdit< ApplyGeometryEdit<
DotWeight, DotWeight,
SegWeight, SegWeight,
BendWeight, BendWeight,
CW, CW,
Cek, Cel,
PrimitiveIndex, PrimitiveIndex,
DotIndex, DotIndex,
SegIndex, SegIndex,
BendIndex, BendIndex,
> for Drawing<CW, Cek, R> > for Drawing<CW, Cel, R>
{ {
fn apply(&mut self, edit: &DrawingEdit<CW, Cek>) { fn apply(&mut self, edit: &DrawingEdit<CW, Cel>) {
self.recording_geometry_with_rtree.apply(edit); self.recording_geometry_with_rtree.apply(edit);
} }
} }

View File

@ -30,10 +30,10 @@ pub enum GearIndex {
LooseBend(LooseBendIndex), LooseBend(LooseBendIndex),
} }
impl<'a, CW: 'a, Cek: 'a, R: 'a> MakeRef<'a, Drawing<CW, Cek, R>> for GearIndex { impl<'a, CW: 'a, Cel: 'a, R: 'a> MakeRef<'a, Drawing<CW, Cel, R>> for GearIndex {
type Output = GearRef<'a, CW, Cek, R>; type Output = GearRef<'a, CW, Cel, R>;
fn ref_(&self, drawing: &'a Drawing<CW, Cek, R>) -> GearRef<'a, CW, Cek, R> { fn ref_(&self, drawing: &'a Drawing<CW, Cel, R>) -> GearRef<'a, CW, Cel, R> {
GearRef::<'a, CW, Cek, R>::new(*self, drawing) GearRef::<'a, CW, Cel, R>::new(*self, drawing)
} }
} }
@ -57,14 +57,14 @@ impl From<BendIndex> for GearIndex {
} }
#[enum_dispatch(GetNextGear, GetDrawing, GetPetgraphIndex)] #[enum_dispatch(GetNextGear, GetDrawing, GetPetgraphIndex)]
pub enum GearRef<'a, CW, Cek, R> { pub enum GearRef<'a, CW, Cel, R> {
FixedDot(FixedDot<'a, CW, Cek, R>), FixedDot(FixedDot<'a, CW, Cel, R>),
FixedBend(FixedBend<'a, CW, Cek, R>), FixedBend(FixedBend<'a, CW, Cel, R>),
LooseBend(LooseBend<'a, CW, Cek, R>), LooseBend(LooseBend<'a, CW, Cel, R>),
} }
impl<'a, CW, Cek, R> GearRef<'a, CW, Cek, R> { impl<'a, CW, Cel, R> GearRef<'a, CW, Cel, R> {
pub fn new(index: GearIndex, drawing: &'a Drawing<CW, Cek, R>) -> Self { pub fn new(index: GearIndex, drawing: &'a Drawing<CW, Cel, R>) -> Self {
match index { match index {
GearIndex::FixedDot(dot) => drawing.primitive(dot).into(), GearIndex::FixedDot(dot) => drawing.primitive(dot).into(),
GearIndex::FixedBend(bend) => drawing.primitive(bend).into(), GearIndex::FixedBend(bend) => drawing.primitive(bend).into(),
@ -73,19 +73,19 @@ impl<'a, CW, Cek, R> GearRef<'a, CW, Cek, R> {
} }
} }
impl<CW, Cek, R> GetNextGear for FixedDot<'_, CW, Cek, R> { impl<CW, Cel, R> GetNextGear for FixedDot<'_, CW, Cel, R> {
fn next_gear(&self) -> Option<LooseBendIndex> { fn next_gear(&self) -> Option<LooseBendIndex> {
self.first_gear() self.first_gear()
} }
} }
impl<CW, Cek, R> GetNextGear for LooseBend<'_, CW, Cek, R> { impl<CW, Cel, R> GetNextGear for LooseBend<'_, CW, Cel, R> {
fn next_gear(&self) -> Option<LooseBendIndex> { fn next_gear(&self) -> Option<LooseBendIndex> {
self.outer() self.outer()
} }
} }
impl<CW, Cek, R> GetNextGear for FixedBend<'_, CW, Cek, R> { impl<CW, Cel, R> GetNextGear for FixedBend<'_, CW, Cel, R> {
fn next_gear(&self) -> Option<LooseBendIndex> { fn next_gear(&self) -> Option<LooseBendIndex> {
self.first_gear() self.first_gear()
} }

View File

@ -47,10 +47,10 @@ pub trait GetMaybeNet {
#[enum_dispatch] #[enum_dispatch]
pub trait MakePrimitive { pub trait MakePrimitive {
fn primitive<'a, CW: Clone, Cek: Copy, R: AccessRules>( fn primitive<'a, CW: Clone, Cel: Copy, R: AccessRules>(
&self, &self,
drawing: &'a Drawing<CW, Cek, R>, drawing: &'a Drawing<CW, Cel, R>,
) -> Primitive<'a, CW, Cek, R>; ) -> Primitive<'a, CW, Cel, R>;
} }
macro_rules! impl_weight_forward { macro_rules! impl_weight_forward {
@ -76,10 +76,10 @@ macro_rules! impl_weight_forward {
pub type $index_struct = GenericIndex<$weight_struct>; pub type $index_struct = GenericIndex<$weight_struct>;
impl MakePrimitive for $index_struct { impl MakePrimitive for $index_struct {
fn primitive<'a, CW: Clone, Cek: Copy, R: AccessRules>( fn primitive<'a, CW: Clone, Cel: Copy, R: AccessRules>(
&self, &self,
drawing: &'a crate::drawing::Drawing<CW, Cek, R>, drawing: &'a crate::drawing::Drawing<CW, Cel, R>,
) -> Primitive<'a, CW, Cek, R> { ) -> Primitive<'a, CW, Cel, R> {
Primitive::$weight_variant(GenericPrimitive::new(*self, drawing)) Primitive::$weight_variant(GenericPrimitive::new(*self, drawing))
} }
} }

View File

@ -73,7 +73,7 @@ pub trait Guide {
fn head(&self, face: DotIndex) -> Head; fn head(&self, face: DotIndex) -> Head;
} }
impl<CW: Clone, Cek: Copy, R: AccessRules> Guide for Drawing<CW, Cek, R> { impl<CW: Clone, Cel: Copy, R: AccessRules> Guide for Drawing<CW, Cel, R> {
fn head_into_dot_segment( fn head_into_dot_segment(
&self, &self,
head: &Head, head: &Head,
@ -223,7 +223,7 @@ trait GuidePrivate {
fn conditions(&self, node: PrimitiveIndex) -> Option<Conditions<'_>>; fn conditions(&self, node: PrimitiveIndex) -> Option<Conditions<'_>>;
} }
impl<CW: Clone, Cek: Copy, R: AccessRules> GuidePrivate for Drawing<CW, Cek, R> { impl<CW: Clone, Cel: Copy, R: AccessRules> GuidePrivate for Drawing<CW, Cel, R> {
fn clearance(&self, lhs: Option<&Conditions<'_>>, rhs: Option<&Conditions<'_>>) -> f64 { fn clearance(&self, lhs: Option<&Conditions<'_>>, rhs: Option<&Conditions<'_>>) -> f64 {
match (lhs, rhs) { match (lhs, rhs) {
(None, _) | (_, None) => 0.0, (None, _) | (_, None) => 0.0,

View File

@ -29,9 +29,9 @@ pub enum Head {
Cane(CaneHead), Cane(CaneHead),
} }
impl<'a, CW: 'a, Cek: 'a, R: 'a> MakeRef<'a, Drawing<CW, Cek, R>> for Head { impl<'a, CW: 'a, Cel: 'a, R: 'a> MakeRef<'a, Drawing<CW, Cel, R>> for Head {
type Output = HeadRef<'a, CW, Cek, R>; type Output = HeadRef<'a, CW, Cel, R>;
fn ref_(&self, drawing: &'a Drawing<CW, Cek, R>) -> HeadRef<'a, CW, Cek, R> { fn ref_(&self, drawing: &'a Drawing<CW, Cel, R>) -> HeadRef<'a, CW, Cel, R> {
HeadRef::new(*self, drawing) HeadRef::new(*self, drawing)
} }
} }
@ -72,24 +72,24 @@ impl GetFace for CaneHead {
} }
} }
pub struct HeadRef<'a, CW, Cek, R> { pub struct HeadRef<'a, CW, Cel, R> {
head: Head, head: Head,
drawing: &'a Drawing<CW, Cek, R>, drawing: &'a Drawing<CW, Cel, R>,
} }
impl<'a, CW, Cek, R> HeadRef<'a, CW, Cek, R> { impl<'a, CW, Cel, R> HeadRef<'a, CW, Cel, R> {
pub fn new(head: Head, drawing: &'a Drawing<CW, Cek, R>) -> Self { pub fn new(head: Head, drawing: &'a Drawing<CW, Cel, R>) -> Self {
Self { drawing, head } Self { drawing, head }
} }
} }
impl<CW, Cek, R> GetFace for HeadRef<'_, CW, Cek, R> { impl<CW, Cel, R> GetFace for HeadRef<'_, CW, Cel, R> {
fn face(&self) -> DotIndex { fn face(&self) -> DotIndex {
self.head.face() self.head.face()
} }
} }
impl<CW: Clone, Cek: Copy, R: AccessRules> MeasureLength for HeadRef<'_, CW, Cek, R> { impl<CW: Clone, Cel: Copy, R: AccessRules> MeasureLength for HeadRef<'_, CW, Cel, R> {
fn length(&self) -> f64 { fn length(&self) -> f64 {
match self.head { match self.head {
Head::Bare(..) => 0.0, Head::Bare(..) => 0.0,

View File

@ -70,15 +70,15 @@ impl TryFrom<PrimitiveIndex> for LooseIndex {
} }
#[enum_dispatch(GetPrevNextLoose, GetDrawing, GetPetgraphIndex)] #[enum_dispatch(GetPrevNextLoose, GetDrawing, GetPetgraphIndex)]
pub enum Loose<'a, CW, Cek, R> { pub enum Loose<'a, CW, Cel, R> {
Dot(LooseDot<'a, CW, Cek, R>), Dot(LooseDot<'a, CW, Cel, R>),
LoneSeg(LoneLooseSeg<'a, CW, Cek, R>), LoneSeg(LoneLooseSeg<'a, CW, Cel, R>),
SeqSeg(SeqLooseSeg<'a, CW, Cek, R>), SeqSeg(SeqLooseSeg<'a, CW, Cel, R>),
Bend(LooseBend<'a, CW, Cek, R>), Bend(LooseBend<'a, CW, Cel, R>),
} }
impl<'a, CW, Cek, R> Loose<'a, CW, Cek, R> { impl<'a, CW, Cel, R> Loose<'a, CW, Cel, R> {
pub fn new(index: LooseIndex, drawing: &'a Drawing<CW, Cek, R>) -> Self { pub fn new(index: LooseIndex, drawing: &'a Drawing<CW, Cel, R>) -> Self {
match index { match index {
LooseIndex::Dot(dot) => drawing.primitive(dot).into(), LooseIndex::Dot(dot) => drawing.primitive(dot).into(),
LooseIndex::LoneSeg(seg) => drawing.primitive(seg).into(), LooseIndex::LoneSeg(seg) => drawing.primitive(seg).into(),
@ -88,7 +88,7 @@ impl<'a, CW, Cek, R> Loose<'a, CW, Cek, R> {
} }
} }
impl<CW, Cek, R> GetPrevNextLoose for LooseDot<'_, CW, Cek, R> { impl<CW, Cel, R> GetPrevNextLoose for LooseDot<'_, CW, Cel, R> {
fn next_loose(&self, maybe_prev: Option<LooseIndex>) -> Option<LooseIndex> { fn next_loose(&self, maybe_prev: Option<LooseIndex>) -> Option<LooseIndex> {
let bend = self.bend(); let bend = self.bend();
@ -104,13 +104,13 @@ impl<CW, Cek, R> GetPrevNextLoose for LooseDot<'_, CW, Cek, R> {
} }
} }
impl<CW, Cek, R> GetPrevNextLoose for LoneLooseSeg<'_, CW, Cek, R> { impl<CW, Cel, R> GetPrevNextLoose for LoneLooseSeg<'_, CW, Cel, R> {
fn next_loose(&self, _maybe_prev: Option<LooseIndex>) -> Option<LooseIndex> { fn next_loose(&self, _maybe_prev: Option<LooseIndex>) -> Option<LooseIndex> {
None None
} }
} }
impl<CW, Cek, R> GetPrevNextLoose for SeqLooseSeg<'_, CW, Cek, R> { impl<CW, Cel, R> GetPrevNextLoose for SeqLooseSeg<'_, CW, Cel, R> {
fn next_loose(&self, maybe_prev: Option<LooseIndex>) -> Option<LooseIndex> { fn next_loose(&self, maybe_prev: Option<LooseIndex>) -> Option<LooseIndex> {
let joints = self.joints(); let joints = self.joints();
let Some(prev) = maybe_prev else { let Some(prev) = maybe_prev else {
@ -128,7 +128,7 @@ impl<CW, Cek, R> GetPrevNextLoose for SeqLooseSeg<'_, CW, Cek, R> {
} }
} }
impl<CW, Cek, R> GetPrevNextLoose for LooseBend<'_, CW, Cek, R> { impl<CW, Cel, R> GetPrevNextLoose for LooseBend<'_, CW, Cel, R> {
fn next_loose(&self, maybe_prev: Option<LooseIndex>) -> Option<LooseIndex> { fn next_loose(&self, maybe_prev: Option<LooseIndex>) -> Option<LooseIndex> {
let joints = self.joints(); let joints = self.joints();

View File

@ -20,9 +20,9 @@ use crate::{
pub trait GetDrawing { pub trait GetDrawing {
type CompoundWeight; type CompoundWeight;
type CompoundEntryKind; type CompoundEntryLabel;
type Rules; type Rules;
fn drawing(&self) -> &Drawing<Self::CompoundWeight, Self::CompoundEntryKind, Self::Rules>; fn drawing(&self) -> &Drawing<Self::CompoundWeight, Self::CompoundEntryLabel, Self::Rules>;
} }
#[enum_dispatch] #[enum_dispatch]
@ -108,7 +108,7 @@ impl<S: GetDrawing + GetBendIndex> GetCore for S {
macro_rules! impl_primitive { macro_rules! impl_primitive {
($primitive_struct:ident, $weight_struct:ident) => { ($primitive_struct:ident, $weight_struct:ident) => {
impl<CW, Cek, R> GetWeight<$weight_struct> for $primitive_struct<'_, CW, Cek, R> { impl<CW, Cel, R> GetWeight<$weight_struct> for $primitive_struct<'_, CW, Cel, R> {
fn weight(&self) -> $weight_struct { fn weight(&self) -> $weight_struct {
if let PrimitiveWeight::$primitive_struct(weight) = self.tagged_weight() { if let PrimitiveWeight::$primitive_struct(weight) = self.tagged_weight() {
weight weight
@ -118,13 +118,13 @@ macro_rules! impl_primitive {
} }
} }
impl<CW, Cek, R> GetLayer for $primitive_struct<'_, CW, Cek, R> { impl<CW, Cel, R> GetLayer for $primitive_struct<'_, CW, Cel, R> {
fn layer(&self) -> usize { fn layer(&self) -> usize {
self.weight().layer() self.weight().layer()
} }
} }
impl<CW, Cek, R> GetMaybeNet for $primitive_struct<'_, CW, Cek, R> { impl<CW, Cel, R> GetMaybeNet for $primitive_struct<'_, CW, Cel, R> {
fn maybe_net(&self) -> Option<usize> { fn maybe_net(&self) -> Option<usize> {
self.weight().maybe_net() self.weight().maybe_net()
} }
@ -152,17 +152,17 @@ macro_rules! impl_loose_primitive {
MakePrimitiveShape, MakePrimitiveShape,
GetLimbs GetLimbs
)] )]
pub enum Primitive<'a, CW, Cek, R> { pub enum Primitive<'a, CW, Cel, R> {
FixedDot(FixedDot<'a, CW, Cek, R>), FixedDot(FixedDot<'a, CW, Cel, R>),
LooseDot(LooseDot<'a, CW, Cek, R>), LooseDot(LooseDot<'a, CW, Cel, R>),
FixedSeg(FixedSeg<'a, CW, Cek, R>), FixedSeg(FixedSeg<'a, CW, Cel, R>),
LoneLooseSeg(LoneLooseSeg<'a, CW, Cek, R>), LoneLooseSeg(LoneLooseSeg<'a, CW, Cel, R>),
SeqLooseSeg(SeqLooseSeg<'a, CW, Cek, R>), SeqLooseSeg(SeqLooseSeg<'a, CW, Cel, R>),
FixedBend(FixedBend<'a, CW, Cek, R>), FixedBend(FixedBend<'a, CW, Cel, R>),
LooseBend(LooseBend<'a, CW, Cek, R>), LooseBend(LooseBend<'a, CW, Cel, R>),
} }
impl<'a, CW, Cek, R: AccessRules> GetConditions<'a> for &Primitive<'a, CW, Cek, R> { impl<'a, CW, Cel, R: AccessRules> GetConditions<'a> for &Primitive<'a, CW, Cel, R> {
fn conditions(self) -> Option<Conditions<'a>> { fn conditions(self) -> Option<Conditions<'a>> {
match self { match self {
Primitive::FixedDot(x) => x.conditions(), Primitive::FixedDot(x) => x.conditions(),
@ -177,13 +177,13 @@ impl<'a, CW, Cek, R: AccessRules> GetConditions<'a> for &Primitive<'a, CW, Cek,
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct GenericPrimitive<'a, W, CW, Cek, R> { pub struct GenericPrimitive<'a, W, CW, Cel, R> {
pub index: GenericIndex<W>, pub index: GenericIndex<W>,
drawing: &'a Drawing<CW, Cek, R>, drawing: &'a Drawing<CW, Cel, R>,
} }
impl<'a, W, CW, Cek, R> GenericPrimitive<'a, W, CW, Cek, R> { impl<'a, W, CW, Cel, R> GenericPrimitive<'a, W, CW, Cel, R> {
pub fn new(index: GenericIndex<W>, drawing: &'a Drawing<CW, Cek, R>) -> Self { pub fn new(index: GenericIndex<W>, drawing: &'a Drawing<CW, Cel, R>) -> Self {
Self { index, drawing } Self { index, drawing }
} }
@ -202,39 +202,39 @@ impl<'a, W, CW, Cek, R> GenericPrimitive<'a, W, CW, Cek, R> {
} }
} }
impl<W, CW, Cek, R> GetInterior<PrimitiveIndex> for GenericPrimitive<'_, W, CW, Cek, R> { impl<W, CW, Cel, R> GetInterior<PrimitiveIndex> for GenericPrimitive<'_, W, CW, Cel, R> {
fn interior(&self) -> Vec<PrimitiveIndex> { fn interior(&self) -> Vec<PrimitiveIndex> {
vec![self.tagged_weight().retag(self.index.petgraph_index())] vec![self.tagged_weight().retag(self.index.petgraph_index())]
} }
} }
impl<W, CW, Cek, R> GetDrawing for GenericPrimitive<'_, W, CW, Cek, R> { impl<W, CW, Cel, R> GetDrawing for GenericPrimitive<'_, W, CW, Cel, R> {
type CompoundWeight = CW; type CompoundWeight = CW;
type CompoundEntryKind = Cek; type CompoundEntryLabel = Cel;
type Rules = R; type Rules = R;
fn drawing(&self) -> &Drawing<CW, Cek, R> { fn drawing(&self) -> &Drawing<CW, Cel, R> {
self.drawing self.drawing
} }
} }
impl<W, CW, Cek, R> GetPetgraphIndex for GenericPrimitive<'_, W, CW, Cek, R> { impl<W, CW, Cel, R> GetPetgraphIndex for GenericPrimitive<'_, W, CW, Cel, R> {
fn petgraph_index(&self) -> NodeIndex<usize> { fn petgraph_index(&self) -> NodeIndex<usize> {
self.index.petgraph_index() self.index.petgraph_index()
} }
} }
impl<'a, W: GetWidth, CW, Cek, R> GetWidth for GenericPrimitive<'a, W, CW, Cek, R> impl<'a, W: GetWidth, CW, Cel, R> GetWidth for GenericPrimitive<'a, W, CW, Cel, R>
where where
GenericPrimitive<'a, W, CW, Cek, R>: GetWeight<W>, GenericPrimitive<'a, W, CW, Cel, R>: GetWeight<W>,
{ {
fn width(&self) -> f64 { fn width(&self) -> f64 {
self.weight().width() self.weight().width()
} }
} }
impl<'a, W, CW, Cek, R> GetConditions<'a> for &GenericPrimitive<'a, W, CW, Cek, R> impl<'a, W, CW, Cel, R> GetConditions<'a> for &GenericPrimitive<'a, W, CW, Cel, R>
where where
GenericPrimitive<'a, W, CW, Cek, R>: GetMaybeNet, GenericPrimitive<'a, W, CW, Cel, R>: GetMaybeNet,
{ {
fn conditions(self) -> Option<Conditions<'a>> { fn conditions(self) -> Option<Conditions<'a>> {
self.maybe_net().map(|net| Conditions { self.maybe_net().map(|net| Conditions {
@ -245,16 +245,16 @@ where
} }
} }
pub type FixedDot<'a, CW, Cek, R> = GenericPrimitive<'a, FixedDotWeight, CW, Cek, R>; pub type FixedDot<'a, CW, Cel, R> = GenericPrimitive<'a, FixedDotWeight, CW, Cel, R>;
impl_fixed_primitive!(FixedDot, FixedDotWeight); impl_fixed_primitive!(FixedDot, FixedDotWeight);
impl<CW, Cek, R> MakePrimitiveShape for FixedDot<'_, CW, Cek, R> { impl<CW, Cel, R> MakePrimitiveShape for FixedDot<'_, CW, Cel, R> {
fn shape(&self) -> PrimitiveShape { fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().dot_shape(self.index.into()) self.drawing.geometry().dot_shape(self.index.into())
} }
} }
impl<CW, Cek, R> GetLimbs for FixedDot<'_, CW, Cek, R> { impl<CW, Cel, R> GetLimbs for FixedDot<'_, CW, Cel, R> {
fn segs(&self) -> Vec<SegIndex> { fn segs(&self) -> Vec<SegIndex> {
self.drawing self.drawing
.geometry() .geometry()
@ -270,12 +270,12 @@ impl<CW, Cek, R> GetLimbs for FixedDot<'_, CW, Cek, R> {
} }
} }
impl<CW, Cek, R> GetFirstGear for FixedDot<'_, CW, Cek, R> {} impl<CW, Cel, R> GetFirstGear for FixedDot<'_, CW, Cel, R> {}
pub type LooseDot<'a, CW, Cek, R> = GenericPrimitive<'a, LooseDotWeight, CW, Cek, R>; pub type LooseDot<'a, CW, Cel, R> = GenericPrimitive<'a, LooseDotWeight, CW, Cel, R>;
impl_loose_primitive!(LooseDot, LooseDotWeight); impl_loose_primitive!(LooseDot, LooseDotWeight);
impl<CW, Cek, R> LooseDot<'_, CW, Cek, R> { impl<CW, Cel, R> LooseDot<'_, CW, Cel, R> {
pub fn seg(&self) -> Option<SeqLooseSegIndex> { pub fn seg(&self) -> Option<SeqLooseSegIndex> {
self.drawing self.drawing
.geometry() .geometry()
@ -294,13 +294,13 @@ impl<CW, Cek, R> LooseDot<'_, CW, Cek, R> {
} }
} }
impl<CW, Cek, R> MakePrimitiveShape for LooseDot<'_, CW, Cek, R> { impl<CW, Cel, R> MakePrimitiveShape for LooseDot<'_, CW, Cel, R> {
fn shape(&self) -> PrimitiveShape { fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().dot_shape(self.index.into()) self.drawing.geometry().dot_shape(self.index.into())
} }
} }
impl<CW, Cek, R> GetLimbs for LooseDot<'_, CW, Cek, R> { impl<CW, Cel, R> GetLimbs for LooseDot<'_, CW, Cel, R> {
fn segs(&self) -> Vec<SegIndex> { fn segs(&self) -> Vec<SegIndex> {
if let Some(seg) = self.seg() { if let Some(seg) = self.seg() {
vec![seg.into()] vec![seg.into()]
@ -314,18 +314,18 @@ impl<CW, Cek, R> GetLimbs for LooseDot<'_, CW, Cek, R> {
} }
} }
pub type FixedSeg<'a, CW, Cek, R> = GenericPrimitive<'a, FixedSegWeight, CW, Cek, R>; pub type FixedSeg<'a, CW, Cel, R> = GenericPrimitive<'a, FixedSegWeight, CW, Cel, R>;
impl_fixed_primitive!(FixedSeg, FixedSegWeight); impl_fixed_primitive!(FixedSeg, FixedSegWeight);
impl<CW, Cek, R> MakePrimitiveShape for FixedSeg<'_, CW, Cek, R> { impl<CW, Cel, R> MakePrimitiveShape for FixedSeg<'_, CW, Cel, R> {
fn shape(&self) -> PrimitiveShape { fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().seg_shape(self.index.into()) self.drawing.geometry().seg_shape(self.index.into())
} }
} }
impl<CW, Cek, R> GetLimbs for FixedSeg<'_, CW, Cek, R> {} impl<CW, Cel, R> GetLimbs for FixedSeg<'_, CW, Cel, R> {}
impl<CW, Cek, R> GetJoints<FixedDotIndex, FixedDotIndex> for FixedSeg<'_, CW, Cek, R> { impl<CW, Cel, R> GetJoints<FixedDotIndex, FixedDotIndex> for FixedSeg<'_, CW, Cel, R> {
fn joints(&self) -> (FixedDotIndex, FixedDotIndex) { fn joints(&self) -> (FixedDotIndex, FixedDotIndex) {
let (from, to) = self.drawing.geometry().seg_joints(self.index.into()); let (from, to) = self.drawing.geometry().seg_joints(self.index.into());
( (
@ -335,18 +335,18 @@ impl<CW, Cek, R> GetJoints<FixedDotIndex, FixedDotIndex> for FixedSeg<'_, CW, Ce
} }
} }
pub type LoneLooseSeg<'a, CW, Cek, R> = GenericPrimitive<'a, LoneLooseSegWeight, CW, Cek, R>; pub type LoneLooseSeg<'a, CW, Cel, R> = GenericPrimitive<'a, LoneLooseSegWeight, CW, Cel, R>;
impl_loose_primitive!(LoneLooseSeg, LoneLooseSegWeight); impl_loose_primitive!(LoneLooseSeg, LoneLooseSegWeight);
impl<CW, Cek, R> MakePrimitiveShape for LoneLooseSeg<'_, CW, Cek, R> { impl<CW, Cel, R> MakePrimitiveShape for LoneLooseSeg<'_, CW, Cel, R> {
fn shape(&self) -> PrimitiveShape { fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().seg_shape(self.index.into()) self.drawing.geometry().seg_shape(self.index.into())
} }
} }
impl<CW, Cek, R> GetLimbs for LoneLooseSeg<'_, CW, Cek, R> {} impl<CW, Cel, R> GetLimbs for LoneLooseSeg<'_, CW, Cel, R> {}
impl<CW, Cek, R> GetJoints<FixedDotIndex, FixedDotIndex> for LoneLooseSeg<'_, CW, Cek, R> { impl<CW, Cel, R> GetJoints<FixedDotIndex, FixedDotIndex> for LoneLooseSeg<'_, CW, Cel, R> {
fn joints(&self) -> (FixedDotIndex, FixedDotIndex) { fn joints(&self) -> (FixedDotIndex, FixedDotIndex) {
let (from, to) = self.drawing.geometry().seg_joints(self.index.into()); let (from, to) = self.drawing.geometry().seg_joints(self.index.into());
( (
@ -356,18 +356,18 @@ impl<CW, Cek, R> GetJoints<FixedDotIndex, FixedDotIndex> for LoneLooseSeg<'_, CW
} }
} }
pub type SeqLooseSeg<'a, CW, Cek, R> = GenericPrimitive<'a, SeqLooseSegWeight, CW, Cek, R>; pub type SeqLooseSeg<'a, CW, Cel, R> = GenericPrimitive<'a, SeqLooseSegWeight, CW, Cel, R>;
impl_loose_primitive!(SeqLooseSeg, SeqLooseSegWeight); impl_loose_primitive!(SeqLooseSeg, SeqLooseSegWeight);
impl<CW, Cek, R> MakePrimitiveShape for SeqLooseSeg<'_, CW, Cek, R> { impl<CW, Cel, R> MakePrimitiveShape for SeqLooseSeg<'_, CW, Cel, R> {
fn shape(&self) -> PrimitiveShape { fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().seg_shape(self.index.into()) self.drawing.geometry().seg_shape(self.index.into())
} }
} }
impl<CW, Cek, R> GetLimbs for SeqLooseSeg<'_, CW, Cek, R> {} impl<CW, Cel, R> GetLimbs for SeqLooseSeg<'_, CW, Cel, R> {}
impl<CW, Cek, R> GetJoints<DotIndex, LooseDotIndex> for SeqLooseSeg<'_, CW, Cek, R> { impl<CW, Cel, R> GetJoints<DotIndex, LooseDotIndex> for SeqLooseSeg<'_, CW, Cel, R> {
fn joints(&self) -> (DotIndex, LooseDotIndex) { fn joints(&self) -> (DotIndex, LooseDotIndex) {
let joints = self.drawing.geometry().seg_joints(self.index.into()); let joints = self.drawing.geometry().seg_joints(self.index.into());
if let DotWeight::Fixed(..) = self.drawing.geometry().dot_weight(joints.0) { if let DotWeight::Fixed(..) = self.drawing.geometry().dot_weight(joints.0) {
@ -389,24 +389,24 @@ impl<CW, Cek, R> GetJoints<DotIndex, LooseDotIndex> for SeqLooseSeg<'_, CW, Cek,
} }
} }
pub type FixedBend<'a, CW, Cek, R> = GenericPrimitive<'a, FixedBendWeight, CW, Cek, R>; pub type FixedBend<'a, CW, Cel, R> = GenericPrimitive<'a, FixedBendWeight, CW, Cel, R>;
impl_fixed_primitive!(FixedBend, FixedBendWeight); impl_fixed_primitive!(FixedBend, FixedBendWeight);
impl<CW, Cek, R> GetBendIndex for FixedBend<'_, CW, Cek, R> { impl<CW, Cel, R> GetBendIndex for FixedBend<'_, CW, Cel, R> {
fn bend_index(&self) -> BendIndex { fn bend_index(&self) -> BendIndex {
self.index.into() self.index.into()
} }
} }
impl<CW, Cek, R> MakePrimitiveShape for FixedBend<'_, CW, Cek, R> { impl<CW, Cel, R> MakePrimitiveShape for FixedBend<'_, CW, Cel, R> {
fn shape(&self) -> PrimitiveShape { fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().bend_shape(self.index.into()) self.drawing.geometry().bend_shape(self.index.into())
} }
} }
impl<CW, Cek, R> GetLimbs for FixedBend<'_, CW, Cek, R> {} impl<CW, Cel, R> GetLimbs for FixedBend<'_, CW, Cel, R> {}
impl<CW, Cek, R> GetJoints<FixedDotIndex, FixedDotIndex> for FixedBend<'_, CW, Cek, R> { impl<CW, Cel, R> GetJoints<FixedDotIndex, FixedDotIndex> for FixedBend<'_, CW, Cel, R> {
fn joints(&self) -> (FixedDotIndex, FixedDotIndex) { fn joints(&self) -> (FixedDotIndex, FixedDotIndex) {
let (from, to) = self.drawing.geometry().bend_joints(self.index.into()); let (from, to) = self.drawing.geometry().bend_joints(self.index.into());
( (
@ -416,39 +416,39 @@ impl<CW, Cek, R> GetJoints<FixedDotIndex, FixedDotIndex> for FixedBend<'_, CW, C
} }
} }
impl<CW, Cek, R> GetFirstGear for FixedBend<'_, CW, Cek, R> {} impl<CW, Cel, R> GetFirstGear for FixedBend<'_, CW, Cel, R> {}
//impl<'a, R: QueryRules> GetInnerOuter for FixedBend<'a, CW, Cek, R> {} //impl<'a, R: QueryRules> GetInnerOuter for FixedBend<'a, CW, Cel, R> {}
pub type LooseBend<'a, CW, Cek, R> = GenericPrimitive<'a, LooseBendWeight, CW, Cek, R>; pub type LooseBend<'a, CW, Cel, R> = GenericPrimitive<'a, LooseBendWeight, CW, Cel, R>;
impl_loose_primitive!(LooseBend, LooseBendWeight); impl_loose_primitive!(LooseBend, LooseBendWeight);
impl<CW, Cek, R> GetBendIndex for LooseBend<'_, CW, Cek, R> { impl<CW, Cel, R> GetBendIndex for LooseBend<'_, CW, Cel, R> {
fn bend_index(&self) -> BendIndex { fn bend_index(&self) -> BendIndex {
self.index.into() self.index.into()
} }
} }
impl<'a, CW: Clone, Cek: Copy, R: AccessRules> From<LooseBend<'a, CW, Cek, R>> for BendIndex { impl<'a, CW: Clone, Cel: Copy, R: AccessRules> From<LooseBend<'a, CW, Cel, R>> for BendIndex {
fn from(bend: LooseBend<'a, CW, Cek, R>) -> BendIndex { fn from(bend: LooseBend<'a, CW, Cel, R>) -> BendIndex {
bend.index.into() bend.index.into()
} }
} }
impl<CW, Cek, R> MakePrimitiveShape for LooseBend<'_, CW, Cek, R> { impl<CW, Cel, R> MakePrimitiveShape for LooseBend<'_, CW, Cel, R> {
fn shape(&self) -> PrimitiveShape { fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().bend_shape(self.index.into()) self.drawing.geometry().bend_shape(self.index.into())
} }
} }
impl<CW, Cek, R> GetLimbs for LooseBend<'_, CW, Cek, R> {} impl<CW, Cel, R> GetLimbs for LooseBend<'_, CW, Cel, R> {}
impl<CW, Cek, R> GetOffset for LooseBend<'_, CW, Cek, R> { impl<CW, Cel, R> GetOffset for LooseBend<'_, CW, Cel, R> {
fn offset(&self) -> f64 { fn offset(&self) -> f64 {
self.weight().offset() self.weight().offset()
} }
} }
impl<CW, Cek, R> GetJoints<LooseDotIndex, LooseDotIndex> for LooseBend<'_, CW, Cek, R> { impl<CW, Cel, R> GetJoints<LooseDotIndex, LooseDotIndex> for LooseBend<'_, CW, Cel, R> {
fn joints(&self) -> (LooseDotIndex, LooseDotIndex) { fn joints(&self) -> (LooseDotIndex, LooseDotIndex) {
let (from, to) = self.drawing.geometry().bend_joints(self.index.into()); let (from, to) = self.drawing.geometry().bend_joints(self.index.into());
( (
@ -458,7 +458,7 @@ impl<CW, Cek, R> GetJoints<LooseDotIndex, LooseDotIndex> for LooseBend<'_, CW, C
} }
} }
impl<CW, Cek, R> LooseBend<'_, CW, Cek, R> { impl<CW, Cel, R> LooseBend<'_, CW, Cel, R> {
pub fn inner(&self) -> Option<LooseBendIndex> { pub fn inner(&self) -> Option<LooseBendIndex> {
self.drawing() self.drawing()
.geometry() .geometry()

View File

@ -6,11 +6,11 @@ use crate::graph::{GenericIndex, GetPetgraphIndex};
pub trait ManageCompounds<CW: Clone> { pub trait ManageCompounds<CW: Clone> {
type GeneralIndex: Copy; type GeneralIndex: Copy;
type EntryKind: Copy; type EntryLabel: Copy;
fn add_compound(&mut self, weight: CW) -> GenericIndex<CW>; fn add_compound(&mut self, weight: CW) -> GenericIndex<CW>;
fn remove_compound(&mut self, compound: GenericIndex<CW>); fn remove_compound(&mut self, compound: GenericIndex<CW>);
fn add_to_compound<I>(&mut self, node: I, kind: Self::EntryKind, compound: GenericIndex<CW>) fn add_to_compound<I>(&mut self, node: I, label: Self::EntryLabel, compound: GenericIndex<CW>)
where where
I: Copy + GetPetgraphIndex; I: Copy + GetPetgraphIndex;
@ -19,9 +19,9 @@ pub trait ManageCompounds<CW: Clone> {
fn compound_members( fn compound_members(
&self, &self,
compound: GenericIndex<CW>, compound: GenericIndex<CW>,
) -> impl Iterator<Item = (Self::EntryKind, Self::GeneralIndex)> + '_; ) -> impl Iterator<Item = (Self::EntryLabel, Self::GeneralIndex)> + '_;
fn compounds<I>(&self, node: I) -> impl Iterator<Item = (Self::EntryKind, GenericIndex<CW>)> fn compounds<I>(&self, node: I) -> impl Iterator<Item = (Self::EntryLabel, GenericIndex<CW>)>
where where
I: Copy + GetPetgraphIndex; I: Copy + GetPetgraphIndex;
} }

View File

@ -13,23 +13,23 @@ pub trait ApplyGeometryEdit<
SW: AccessSegWeight + GetLayer, SW: AccessSegWeight + GetLayer,
BW: AccessBendWeight + GetLayer, BW: AccessBendWeight + GetLayer,
CW: Clone, CW: Clone,
Cek: Copy, Cel: Copy,
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Eq + Ord + Copy, PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Eq + Ord + Copy,
DI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy, DI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy,
SI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy, SI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy,
BI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy, BI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy,
> >
{ {
fn apply(&mut self, edit: &GeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI>); fn apply(&mut self, edit: &GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>);
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct GeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI> { pub struct GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI> {
pub(super) dots: BTreeMap<DI, (Option<DW>, Option<DW>)>, pub(super) dots: BTreeMap<DI, (Option<DW>, Option<DW>)>,
pub(super) segs: BTreeMap<SI, (Option<((DI, DI), SW)>, Option<((DI, DI), SW)>)>, pub(super) segs: BTreeMap<SI, (Option<((DI, DI), SW)>, Option<((DI, DI), SW)>)>,
pub(super) bends: BTreeMap<BI, (Option<((DI, DI, DI), BW)>, Option<((DI, DI, DI), BW)>)>, pub(super) bends: BTreeMap<BI, (Option<((DI, DI, DI), BW)>, Option<((DI, DI, DI), BW)>)>,
pub(super) compounds: pub(super) compounds:
BTreeMap<GenericIndex<CW>, (Option<(Vec<(Cek, PI)>, CW)>, Option<(Vec<(Cek, PI)>, CW)>)>, BTreeMap<GenericIndex<CW>, (Option<(Vec<(Cel, PI)>, CW)>, Option<(Vec<(Cel, PI)>, CW)>)>,
} }
fn swap_tuple_inplace<D>(x: &mut (D, D)) { fn swap_tuple_inplace<D>(x: &mut (D, D)) {
@ -41,12 +41,12 @@ impl<
SW: AccessSegWeight + GetLayer, SW: AccessSegWeight + GetLayer,
BW: AccessBendWeight + GetLayer, BW: AccessBendWeight + GetLayer,
CW: Clone, CW: Clone,
Cek: Copy, Cel: Copy,
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Eq + Ord + Copy, PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Eq + Ord + Copy,
DI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy, DI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy,
SI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy, SI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy,
BI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy, BI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy,
> GeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI> > GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>
{ {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
@ -93,15 +93,15 @@ impl<
SW: AccessSegWeight + GetLayer, SW: AccessSegWeight + GetLayer,
BW: AccessBendWeight + GetLayer, BW: AccessBendWeight + GetLayer,
CW: Clone, CW: Clone,
Cek: Copy, Cel: Copy,
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Eq + Ord + Copy, PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Eq + Ord + Copy,
DI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy, DI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy,
SI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy, SI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy,
BI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy, BI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy,
> ApplyGeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI> > ApplyGeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>
for GeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI> for GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>
{ {
fn apply(&mut self, edit: &GeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI>) { fn apply(&mut self, edit: &GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>) {
apply_btmap(&mut self.dots, &edit.dots); apply_btmap(&mut self.dots, &edit.dots);
apply_btmap(&mut self.segs, &edit.segs); apply_btmap(&mut self.segs, &edit.segs);
apply_btmap(&mut self.bends, &edit.bends); apply_btmap(&mut self.bends, &edit.bends);

View File

@ -60,11 +60,11 @@ pub trait SetOffset: GetOffset {
} }
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum GeometryLabel<Cek> { pub enum GeometryLabel<Cel> {
Joined, Joined,
Outer, Outer,
Core, Core,
Compound(Cek), Compound(Cel),
} }
#[derive(Clone, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)] #[derive(Clone, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
@ -83,8 +83,8 @@ pub trait AccessBendWeight: SetOffset + GetWidth + Copy {}
impl<T: SetOffset + GetWidth + Copy> AccessBendWeight for T {} impl<T: SetOffset + GetWidth + Copy> AccessBendWeight for T {}
#[derive(Debug)] #[derive(Debug)]
pub struct Geometry<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> { pub struct Geometry<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI> {
graph: StableDiGraph<GenericNode<PW, CW>, GeometryLabel<Cek>, usize>, graph: StableDiGraph<GenericNode<PW, CW>, GeometryLabel<Cel>, usize>,
primitive_weight_marker: PhantomData<PW>, primitive_weight_marker: PhantomData<PW>,
dot_weight_marker: PhantomData<DW>, dot_weight_marker: PhantomData<DW>,
seg_weight_marker: PhantomData<SW>, seg_weight_marker: PhantomData<SW>,
@ -96,8 +96,8 @@ pub struct Geometry<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> {
bend_index_marker: PhantomData<BI>, bend_index_marker: PhantomData<BI>,
} }
impl<PW: Clone, DW, SW, BW, CW: Clone, Cek: Clone, PI, DI, SI, BI> Clone impl<PW: Clone, DW, SW, BW, CW: Clone, Cel: Clone, PI, DI, SI, BI> Clone
for Geometry<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> for Geometry<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI>
{ {
fn clone(&self) -> Self { fn clone(&self) -> Self {
Self { Self {
@ -107,15 +107,15 @@ impl<PW: Clone, DW, SW, BW, CW: Clone, Cek: Clone, PI, DI, SI, BI> Clone
} }
} }
impl<PW, DW, SW, BW, CW, Cek: Clone, PI, DI, SI, BI> Default impl<PW, DW, SW, BW, CW, Cel: Clone, PI, DI, SI, BI> Default
for Geometry<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> for Geometry<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI>
{ {
fn default() -> Self { fn default() -> Self {
Self::new() Self::new()
} }
} }
impl<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> Geometry<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> { impl<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI> Geometry<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI> {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
graph: StableDiGraph::default(), graph: StableDiGraph::default(),
@ -135,7 +135,7 @@ impl<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> Geometry<PW, DW, SW, BW, CW, Cek,
// field that actually contains data... // field that actually contains data...
#[inline(always)] #[inline(always)]
pub fn graph(&self) -> &StableDiGraph<GenericNode<PW, CW>, GeometryLabel<Cek>, usize> { pub fn graph(&self) -> &StableDiGraph<GenericNode<PW, CW>, GeometryLabel<Cel>, usize> {
&self.graph &self.graph
} }
@ -157,12 +157,12 @@ impl<
SW: AccessSegWeight + Into<PW>, SW: AccessSegWeight + Into<PW>,
BW: AccessBendWeight + Into<PW>, BW: AccessBendWeight + Into<PW>,
CW, CW,
Cek, Cel,
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Copy, PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Copy,
DI: GetPetgraphIndex + Into<PI> + Copy, DI: GetPetgraphIndex + Into<PI> + Copy,
SI: GetPetgraphIndex + Into<PI> + Copy, SI: GetPetgraphIndex + Into<PI> + Copy,
BI: GetPetgraphIndex + Into<PI> + Copy, BI: GetPetgraphIndex + Into<PI> + Copy,
> Geometry<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> > Geometry<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI>
{ {
pub fn add_dot<W: AccessDotWeight + Into<PW>>(&mut self, weight: W) -> GenericIndex<W> { pub fn add_dot<W: AccessDotWeight + Into<PW>>(&mut self, weight: W) -> GenericIndex<W> {
GenericIndex::<W>::new(self.graph.add_node(GenericNode::Primitive(weight.into()))) GenericIndex::<W>::new(self.graph.add_node(GenericNode::Primitive(weight.into())))
@ -484,8 +484,8 @@ impl<
} }
} }
impl<PW: Copy + Retag<Index = PI>, DW, SW, BW, CW, Cek, PI, DI, SI, BI> impl<PW: Copy + Retag<Index = PI>, DW, SW, BW, CW, Cel, PI, DI, SI, BI>
Geometry<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> Geometry<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI>
{ {
fn primitive_index(&self, index: NodeIndex<usize>) -> PI { fn primitive_index(&self, index: NodeIndex<usize>) -> PI {
self.primitive_weight(index).retag(index) self.primitive_weight(index).retag(index)
@ -498,12 +498,12 @@ impl<
SW, SW,
BW, BW,
CW, CW,
Cek, Cel,
PI: TryInto<DI> + TryInto<SI> + TryInto<BI>, PI: TryInto<DI> + TryInto<SI> + TryInto<BI>,
DI, DI,
SI, SI,
BI: GetPetgraphIndex, BI: GetPetgraphIndex,
> Geometry<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> > Geometry<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI>
{ {
pub fn first_rail(&self, node: NodeIndex<usize>) -> Option<BI> { pub fn first_rail(&self, node: NodeIndex<usize>) -> Option<BI> {
self.graph self.graph
@ -551,11 +551,11 @@ impl<
} }
} }
impl<PW: Copy + Retag<Index = PI>, DW, SW, BW, CW: Clone, Cek: Copy, PI: Copy, DI, SI, BI> impl<PW: Copy + Retag<Index = PI>, DW, SW, BW, CW: Clone, Cel: Copy, PI: Copy, DI, SI, BI>
ManageCompounds<CW> for Geometry<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> ManageCompounds<CW> for Geometry<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI>
{ {
type GeneralIndex = PI; type GeneralIndex = PI;
type EntryKind = Cek; type EntryLabel = Cel;
fn add_compound(&mut self, weight: CW) -> GenericIndex<CW> { fn add_compound(&mut self, weight: CW) -> GenericIndex<CW> {
GenericIndex::<CW>::new(self.graph.add_node(GenericNode::Compound(weight))) GenericIndex::<CW>::new(self.graph.add_node(GenericNode::Compound(weight)))
@ -565,14 +565,14 @@ impl<PW: Copy + Retag<Index = PI>, DW, SW, BW, CW: Clone, Cek: Copy, PI: Copy, D
self.graph.remove_node(compound.petgraph_index()); self.graph.remove_node(compound.petgraph_index());
} }
fn add_to_compound<I>(&mut self, primitive: I, entry_kind: Cek, compound: GenericIndex<CW>) fn add_to_compound<I>(&mut self, primitive: I, entry_label: Cel, compound: GenericIndex<CW>)
where where
I: Copy + GetPetgraphIndex, I: Copy + GetPetgraphIndex,
{ {
self.graph.update_edge( self.graph.update_edge(
primitive.petgraph_index(), primitive.petgraph_index(),
compound.petgraph_index(), compound.petgraph_index(),
GeometryLabel::Compound(entry_kind), GeometryLabel::Compound(entry_label),
); );
} }
@ -589,27 +589,27 @@ impl<PW: Copy + Retag<Index = PI>, DW, SW, BW, CW: Clone, Cek: Copy, PI: Copy, D
fn compound_members( fn compound_members(
&self, &self,
compound: GenericIndex<CW>, compound: GenericIndex<CW>,
) -> impl Iterator<Item = (Cek, Self::GeneralIndex)> + '_ { ) -> impl Iterator<Item = (Cel, Self::GeneralIndex)> + '_ {
self.graph self.graph
.edges_directed(compound.petgraph_index(), Incoming) .edges_directed(compound.petgraph_index(), Incoming)
.filter_map(|edge| { .filter_map(|edge| {
if let GeometryLabel::Compound(entry_kind) = *edge.weight() { if let GeometryLabel::Compound(entry_label) = *edge.weight() {
Some((entry_kind, self.primitive_index(edge.source()))) Some((entry_label, self.primitive_index(edge.source())))
} else { } else {
None None
} }
}) })
} }
fn compounds<I>(&self, node: I) -> impl Iterator<Item = (Cek, GenericIndex<CW>)> fn compounds<I>(&self, node: I) -> impl Iterator<Item = (Cel, GenericIndex<CW>)>
where where
I: Copy + GetPetgraphIndex, I: Copy + GetPetgraphIndex,
{ {
self.graph self.graph
.edges_directed(node.petgraph_index(), Outgoing) .edges_directed(node.petgraph_index(), Outgoing)
.filter_map(|edge| { .filter_map(|edge| {
if let GeometryLabel::Compound(entry_kind) = *edge.weight() { if let GeometryLabel::Compound(entry_label) = *edge.weight() {
Some((entry_kind, GenericIndex::new(edge.target()))) Some((entry_label, GenericIndex::new(edge.target())))
} else { } else {
None None
} }

View File

@ -19,12 +19,12 @@ use super::{
}; };
#[derive(Debug)] #[derive(Debug)]
pub struct RecordingGeometryWithRtree<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> { pub struct RecordingGeometryWithRtree<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI> {
geometry_with_rtree: GeometryWithRtree<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI>, geometry_with_rtree: GeometryWithRtree<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI>,
} }
impl<PW: Clone, DW, SW, BW, CW: Clone, Cek: Clone, PI: Clone, DI, SI, BI> Clone impl<PW: Clone, DW, SW, BW, CW: Clone, Cel: Clone, PI: Clone, DI, SI, BI> Clone
for RecordingGeometryWithRtree<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> for RecordingGeometryWithRtree<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI>
{ {
fn clone(&self) -> Self { fn clone(&self) -> Self {
Self { Self {
@ -33,10 +33,10 @@ impl<PW: Clone, DW, SW, BW, CW: Clone, Cek: Clone, PI: Clone, DI, SI, BI> Clone
} }
} }
impl<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> impl<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI>
RecordingGeometryWithRtree<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> RecordingGeometryWithRtree<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI>
{ {
pub fn geometry(&self) -> &Geometry<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> { pub fn geometry(&self) -> &Geometry<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI> {
self.geometry_with_rtree.geometry() self.geometry_with_rtree.geometry()
} }
@ -48,7 +48,7 @@ impl<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI>
*self.geometry_with_rtree.layer_count() *self.geometry_with_rtree.layer_count()
} }
pub fn graph(&self) -> &StableDiGraph<GenericNode<PW, CW>, GeometryLabel<Cek>, usize> { pub fn graph(&self) -> &StableDiGraph<GenericNode<PW, CW>, GeometryLabel<Cel>, usize> {
self.geometry_with_rtree.graph() self.geometry_with_rtree.graph()
} }
} }
@ -59,12 +59,12 @@ impl<
SW: AccessSegWeight + Into<PW> + GetLayer, SW: AccessSegWeight + Into<PW> + GetLayer,
BW: AccessBendWeight + Into<PW> + GetLayer, BW: AccessBendWeight + Into<PW> + GetLayer,
CW: Clone, CW: Clone,
Cek: Copy, Cel: Copy,
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Eq + Ord + Copy, PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Eq + Ord + Copy,
DI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy, DI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy,
SI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy, SI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy,
BI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy, BI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy,
> RecordingGeometryWithRtree<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> > RecordingGeometryWithRtree<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI>
{ {
pub fn new(layer_count: usize) -> Self { pub fn new(layer_count: usize) -> Self {
Self { Self {
@ -74,7 +74,7 @@ impl<
pub fn add_dot<W: AccessDotWeight + Into<PW> + GetLayer>( pub fn add_dot<W: AccessDotWeight + Into<PW> + GetLayer>(
&mut self, &mut self,
recorder: &mut GeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI>, recorder: &mut GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>,
weight: W, weight: W,
) -> GenericIndex<W> ) -> GenericIndex<W>
where where
@ -95,7 +95,7 @@ impl<
pub fn add_seg<W: AccessSegWeight + Into<PW> + GetLayer>( pub fn add_seg<W: AccessSegWeight + Into<PW> + GetLayer>(
&mut self, &mut self,
recorder: &mut GeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI>, recorder: &mut GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>,
from: DI, from: DI,
to: DI, to: DI,
weight: W, weight: W,
@ -121,7 +121,7 @@ impl<
pub fn add_bend<W: AccessBendWeight + Into<PW> + GetLayer>( pub fn add_bend<W: AccessBendWeight + Into<PW> + GetLayer>(
&mut self, &mut self,
recorder: &mut GeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI>, recorder: &mut GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>,
from: DI, from: DI,
to: DI, to: DI,
core: DI, core: DI,
@ -148,7 +148,7 @@ impl<
pub fn add_compound( pub fn add_compound(
&mut self, &mut self,
recorder: &mut GeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI>, recorder: &mut GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>,
weight: CW, weight: CW,
) -> GenericIndex<CW> { ) -> GenericIndex<CW> {
let compound = self.geometry_with_rtree.add_compound(weight.clone()); let compound = self.geometry_with_rtree.add_compound(weight.clone());
@ -160,9 +160,9 @@ impl<
pub fn add_to_compound<W>( pub fn add_to_compound<W>(
&mut self, &mut self,
recorder: &mut GeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI>, recorder: &mut GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>,
primitive: GenericIndex<W>, primitive: GenericIndex<W>,
entry_kind: Cek, entry_label: Cel,
compound: GenericIndex<CW>, compound: GenericIndex<CW>,
) { ) {
let geometry = self.geometry_with_rtree.geometry(); let geometry = self.geometry_with_rtree.geometry();
@ -170,7 +170,7 @@ impl<
let old_weight = geometry.compound_weight(compound).clone(); let old_weight = geometry.compound_weight(compound).clone();
self.geometry_with_rtree self.geometry_with_rtree
.add_to_compound(primitive, entry_kind, compound); .add_to_compound(primitive, entry_label, compound);
let geometry = self.geometry_with_rtree.geometry(); let geometry = self.geometry_with_rtree.geometry();
let new_members = geometry.compound_members(compound).collect(); let new_members = geometry.compound_members(compound).collect();
@ -185,7 +185,7 @@ impl<
pub fn remove_dot( pub fn remove_dot(
&mut self, &mut self,
recorder: &mut GeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI>, recorder: &mut GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>,
dot: DI, dot: DI,
) -> Result<(), ()> { ) -> Result<(), ()> {
let weight = self.geometry_with_rtree.geometry().dot_weight(dot); let weight = self.geometry_with_rtree.geometry().dot_weight(dot);
@ -196,7 +196,7 @@ impl<
pub fn remove_seg( pub fn remove_seg(
&mut self, &mut self,
recorder: &mut GeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI>, recorder: &mut GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>,
seg: SI, seg: SI,
) { ) {
let geometry = self.geometry_with_rtree.geometry(); let geometry = self.geometry_with_rtree.geometry();
@ -208,7 +208,7 @@ impl<
pub fn remove_bend( pub fn remove_bend(
&mut self, &mut self,
recorder: &mut GeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI>, recorder: &mut GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>,
bend: BI, bend: BI,
) { ) {
let geometry = self.geometry_with_rtree.geometry(); let geometry = self.geometry_with_rtree.geometry();
@ -225,7 +225,7 @@ impl<
pub fn remove_compound( pub fn remove_compound(
&mut self, &mut self,
recorder: &mut GeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI>, recorder: &mut GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>,
compound: GenericIndex<CW>, compound: GenericIndex<CW>,
) { ) {
let geometry = self.geometry_with_rtree.geometry(); let geometry = self.geometry_with_rtree.geometry();
@ -237,7 +237,7 @@ impl<
pub fn move_dot( pub fn move_dot(
&mut self, &mut self,
recorder: &mut GeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI>, recorder: &mut GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>,
dot: DI, dot: DI,
to: Point, to: Point,
) { ) {
@ -254,11 +254,11 @@ impl<
fn modify_bend<F>( fn modify_bend<F>(
&mut self, &mut self,
recorder: &mut GeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI>, recorder: &mut GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>,
bend: BI, bend: BI,
f: F, f: F,
) where ) where
F: FnOnce(&mut GeometryWithRtree<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI>, BI), F: FnOnce(&mut GeometryWithRtree<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI>, BI),
{ {
let geometry = self.geometry_with_rtree.geometry(); let geometry = self.geometry_with_rtree.geometry();
let old_joints = geometry.bend_joints(bend); let old_joints = geometry.bend_joints(bend);
@ -284,7 +284,7 @@ impl<
pub fn shift_bend( pub fn shift_bend(
&mut self, &mut self,
recorder: &mut GeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI>, recorder: &mut GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>,
bend: BI, bend: BI,
offset: f64, offset: f64,
) { ) {
@ -295,7 +295,7 @@ impl<
pub fn flip_bend( pub fn flip_bend(
&mut self, &mut self,
recorder: &mut GeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI>, recorder: &mut GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>,
bend: BI, bend: BI,
) { ) {
self.modify_bend(recorder, bend, |geometry_with_rtree, bend| { self.modify_bend(recorder, bend, |geometry_with_rtree, bend| {
@ -305,7 +305,7 @@ impl<
pub fn reattach_bend( pub fn reattach_bend(
&mut self, &mut self,
recorder: &mut GeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI>, recorder: &mut GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>,
bend: BI, bend: BI,
maybe_new_inner: Option<BI>, maybe_new_inner: Option<BI>,
) { ) {
@ -321,7 +321,7 @@ impl<
pub fn compounds<'a, W: 'a>( pub fn compounds<'a, W: 'a>(
&'a self, &'a self,
node: GenericIndex<W>, node: GenericIndex<W>,
) -> impl Iterator<Item = (Cek, GenericIndex<CW>)> + 'a { ) -> impl Iterator<Item = (Cel, GenericIndex<CW>)> + 'a {
self.geometry_with_rtree.compounds(node) self.geometry_with_rtree.compounds(node)
} }
} }
@ -352,15 +352,15 @@ impl<
SW: AccessSegWeight + Into<PW> + GetLayer, SW: AccessSegWeight + Into<PW> + GetLayer,
BW: AccessBendWeight + Into<PW> + GetLayer, BW: AccessBendWeight + Into<PW> + GetLayer,
CW: Clone, CW: Clone,
Cek: Copy, Cel: Copy,
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Eq + Ord + Copy, PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Eq + Ord + Copy,
DI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy, DI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy,
SI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy, SI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy,
BI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy, BI: GetPetgraphIndex + Into<PI> + Eq + Ord + Copy,
> ApplyGeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI> > ApplyGeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>
for RecordingGeometryWithRtree<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> for RecordingGeometryWithRtree<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI>
{ {
fn apply(&mut self, edit: &GeometryEdit<DW, SW, BW, CW, Cek, PI, DI, SI, BI>) { fn apply(&mut self, edit: &GeometryEdit<DW, SW, BW, CW, Cel, PI, DI, SI, BI>) {
for (compound, (maybe_old_data, ..)) in &edit.compounds { for (compound, (maybe_old_data, ..)) in &edit.compounds {
if maybe_old_data.is_some() { if maybe_old_data.is_some() {
self.geometry_with_rtree.remove_compound(*compound); self.geometry_with_rtree.remove_compound(*compound);
@ -410,10 +410,10 @@ impl<
self.geometry_with_rtree self.geometry_with_rtree
.add_compound_at_index(*compound, weight.clone()); .add_compound_at_index(*compound, weight.clone());
for (entry_kind, member) in members { for (entry_label, member) in members {
self.geometry_with_rtree.add_to_compound( self.geometry_with_rtree.add_to_compound(
GenericIndex::<PW>::new(member.petgraph_index()), GenericIndex::<PW>::new(member.petgraph_index()),
*entry_kind, *entry_label,
*compound, *compound,
); );
} }

View File

@ -39,14 +39,14 @@ impl RTreeObject for Bbox {
pub type BboxedIndex<I> = GeomWithData<Bbox, I>; pub type BboxedIndex<I> = GeomWithData<Bbox, I>;
#[derive(Debug, Getters)] #[derive(Debug, Getters)]
pub struct GeometryWithRtree<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> { pub struct GeometryWithRtree<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI> {
geometry: Geometry<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI>, geometry: Geometry<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI>,
rtree: RTree<BboxedIndex<GenericNode<PI, GenericIndex<CW>>>>, rtree: RTree<BboxedIndex<GenericNode<PI, GenericIndex<CW>>>>,
layer_count: usize, layer_count: usize,
} }
impl<PW: Clone, DW, SW, BW, CW: Clone, Cek: Clone, PI: Clone, DI, SI, BI> Clone impl<PW: Clone, DW, SW, BW, CW: Clone, Cel: Clone, PI: Clone, DI, SI, BI> Clone
for GeometryWithRtree<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> for GeometryWithRtree<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI>
{ {
fn clone(&self) -> Self { fn clone(&self) -> Self {
Self { Self {
@ -57,10 +57,10 @@ impl<PW: Clone, DW, SW, BW, CW: Clone, Cek: Clone, PI: Clone, DI, SI, BI> Clone
} }
} }
impl<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> impl<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI>
GeometryWithRtree<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> GeometryWithRtree<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI>
{ {
pub fn graph(&self) -> &StableDiGraph<GenericNode<PW, CW>, GeometryLabel<Cek>, usize> { pub fn graph(&self) -> &StableDiGraph<GenericNode<PW, CW>, GeometryLabel<Cel>, usize> {
self.geometry.graph() self.geometry.graph()
} }
} }
@ -73,12 +73,12 @@ impl<
SW: AccessSegWeight + Into<PW> + GetLayer, SW: AccessSegWeight + Into<PW> + GetLayer,
BW: AccessBendWeight + Into<PW> + GetLayer, BW: AccessBendWeight + Into<PW> + GetLayer,
CW: Clone, CW: Clone,
Cek: Copy, Cel: Copy,
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + PartialEq + Copy, PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + PartialEq + Copy,
DI: GetPetgraphIndex + Into<PI> + Copy, DI: GetPetgraphIndex + Into<PI> + Copy,
SI: GetPetgraphIndex + Into<PI> + Copy, SI: GetPetgraphIndex + Into<PI> + Copy,
BI: GetPetgraphIndex + Into<PI> + Copy, BI: GetPetgraphIndex + Into<PI> + Copy,
> GeometryWithRtree<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> > GeometryWithRtree<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI>
{ {
pub fn new(layer_count: usize) -> Self { pub fn new(layer_count: usize) -> Self {
Self { Self {
@ -181,12 +181,12 @@ impl<
pub fn add_to_compound<W>( pub fn add_to_compound<W>(
&mut self, &mut self,
primitive: GenericIndex<W>, primitive: GenericIndex<W>,
entry_kind: Cek, entry_label: Cel,
compound: GenericIndex<CW>, compound: GenericIndex<CW>,
) { ) {
self.rtree.remove(&self.make_compound_bbox(compound)); self.rtree.remove(&self.make_compound_bbox(compound));
self.geometry self.geometry
.add_to_compound(primitive, entry_kind, compound); .add_to_compound(primitive, entry_label, compound);
self.rtree.insert(self.make_compound_bbox(compound)); self.rtree.insert(self.make_compound_bbox(compound));
} }
@ -293,12 +293,12 @@ impl<
SW: AccessSegWeight + Into<PW> + GetLayer, SW: AccessSegWeight + Into<PW> + GetLayer,
BW: AccessBendWeight + Into<PW> + GetLayer, BW: AccessBendWeight + Into<PW> + GetLayer,
CW: Clone, CW: Clone,
Cek: Copy, Cel: Copy,
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + PartialEq + Copy, PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + PartialEq + Copy,
DI: GetPetgraphIndex + Into<PI> + Copy, DI: GetPetgraphIndex + Into<PI> + Copy,
SI: GetPetgraphIndex + Into<PI> + Copy, SI: GetPetgraphIndex + Into<PI> + Copy,
BI: GetPetgraphIndex + Into<PI> + Copy, BI: GetPetgraphIndex + Into<PI> + Copy,
> GeometryWithRtree<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> > GeometryWithRtree<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI>
{ {
fn init_dot_bbox(&mut self, dot: DI) { fn init_dot_bbox(&mut self, dot: DI) {
self.rtree.insert(self.make_dot_bbox(dot)); self.rtree.insert(self.make_dot_bbox(dot));
@ -363,7 +363,7 @@ impl<
) -> BboxedIndex<GenericNode<PI, GenericIndex<CW>>> { ) -> BboxedIndex<GenericNode<PI, GenericIndex<CW>>> {
let mut aabb = AABB::<[f64; 3]>::new_empty(); let mut aabb = AABB::<[f64; 3]>::new_empty();
// NOTE(fogti): perhaps allow `entry_kind` to specify if it // NOTE(fogti): perhaps allow `entry_label` to specify if it
// should be considered part of the bounding box or not // should be considered part of the bounding box or not
for (_, member) in self.geometry.compound_members(compound) { for (_, member) in self.geometry.compound_members(compound) {
aabb.merge(&self.make_bbox(member).geom().aabb); aabb.merge(&self.make_bbox(member).geom().aabb);
@ -422,15 +422,15 @@ impl<
SW: AccessSegWeight + Into<PW> + GetLayer, SW: AccessSegWeight + Into<PW> + GetLayer,
BW: AccessBendWeight + Into<PW> + GetLayer, BW: AccessBendWeight + Into<PW> + GetLayer,
CW: Clone, CW: Clone,
Cek: Copy, Cel: Copy,
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + PartialEq + Copy, PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + PartialEq + Copy,
DI: GetPetgraphIndex + Into<PI> + Copy, DI: GetPetgraphIndex + Into<PI> + Copy,
SI: GetPetgraphIndex + Into<PI> + Copy, SI: GetPetgraphIndex + Into<PI> + Copy,
BI: GetPetgraphIndex + Into<PI> + Copy, BI: GetPetgraphIndex + Into<PI> + Copy,
> ManageCompounds<CW> for GeometryWithRtree<PW, DW, SW, BW, CW, Cek, PI, DI, SI, BI> > ManageCompounds<CW> for GeometryWithRtree<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI>
{ {
type GeneralIndex = PI; type GeneralIndex = PI;
type EntryKind = Cek; type EntryLabel = Cel;
fn add_compound(&mut self, weight: CW) -> GenericIndex<CW> { fn add_compound(&mut self, weight: CW) -> GenericIndex<CW> {
let compound = self.geometry.add_compound(weight); let compound = self.geometry.add_compound(weight);
@ -443,11 +443,11 @@ impl<
self.geometry.remove_compound(compound); self.geometry.remove_compound(compound);
} }
fn add_to_compound<I>(&mut self, primitive: I, kind: Cek, compound: GenericIndex<CW>) fn add_to_compound<I>(&mut self, primitive: I, label: Cel, compound: GenericIndex<CW>)
where where
I: Copy + GetPetgraphIndex, I: Copy + GetPetgraphIndex,
{ {
self.geometry.add_to_compound(primitive, kind, compound); self.geometry.add_to_compound(primitive, label, compound);
} }
fn compound_weight(&self, compound: GenericIndex<CW>) -> &CW { fn compound_weight(&self, compound: GenericIndex<CW>) -> &CW {
@ -457,11 +457,11 @@ impl<
fn compound_members( fn compound_members(
&self, &self,
compound: GenericIndex<CW>, compound: GenericIndex<CW>,
) -> impl Iterator<Item = (Cek, Self::GeneralIndex)> { ) -> impl Iterator<Item = (Cel, Self::GeneralIndex)> {
self.geometry.compound_members(compound) self.geometry.compound_members(compound)
} }
fn compounds<I>(&self, node: I) -> impl Iterator<Item = (Cek, GenericIndex<CW>)> fn compounds<I>(&self, node: I) -> impl Iterator<Item = (Cel, GenericIndex<CW>)>
where where
I: Copy + GetPetgraphIndex, I: Copy + GetPetgraphIndex,
{ {

View File

@ -53,23 +53,23 @@ pub enum CompoundWeight {
} }
#[derive(Clone, Copy, Debug, PartialEq, Eq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CompoundEntryKind { pub enum CompoundEntryLabel {
Normal, Normal,
NotInConvexHull, NotInConvexHull,
} }
/// The alias to differ node types /// The alias to differ node types
pub type NodeIndex = GenericNode<PrimitiveIndex, GenericIndex<CompoundWeight>>; pub type NodeIndex = GenericNode<PrimitiveIndex, GenericIndex<CompoundWeight>>;
pub type LayoutEdit = DrawingEdit<CompoundWeight, CompoundEntryKind>; pub type LayoutEdit = DrawingEdit<CompoundWeight, CompoundEntryLabel>;
#[derive(Clone, Debug, Getters)] #[derive(Clone, Debug, Getters)]
/// Structure for managing the Layout design /// Structure for managing the Layout design
pub struct Layout<R> { pub struct Layout<R> {
pub(super) drawing: Drawing<CompoundWeight, CompoundEntryKind, R>, pub(super) drawing: Drawing<CompoundWeight, CompoundEntryLabel, R>,
} }
impl<R> Layout<R> { impl<R> Layout<R> {
pub fn new(drawing: Drawing<CompoundWeight, CompoundEntryKind, R>) -> Self { pub fn new(drawing: Drawing<CompoundWeight, CompoundEntryLabel, R>) -> Self {
Self { drawing } Self { drawing }
} }
} }
@ -126,7 +126,7 @@ impl<R: AccessRules> Layout<R> {
self.drawing.add_to_compound( self.drawing.add_to_compound(
recorder, recorder,
dot, dot,
CompoundEntryKind::Normal, CompoundEntryLabel::Normal,
compound, compound,
); );
dots.push(dot); dots.push(dot);
@ -286,7 +286,7 @@ impl<R: AccessRules> Layout<R> {
pub fn poly_members( pub fn poly_members(
&self, &self,
poly: GenericIndex<PolyWeight>, poly: GenericIndex<PolyWeight>,
) -> impl Iterator<Item = (CompoundEntryKind, PrimitiveIndex)> + '_ { ) -> impl Iterator<Item = (CompoundEntryLabel, PrimitiveIndex)> + '_ {
self.drawing self.drawing
.geometry() .geometry()
.compound_members(GenericIndex::new(poly.petgraph_index())) .compound_members(GenericIndex::new(poly.petgraph_index()))
@ -442,7 +442,7 @@ impl<R: AccessRules>
SegWeight, SegWeight,
BendWeight, BendWeight,
CompoundWeight, CompoundWeight,
CompoundEntryKind, CompoundEntryLabel,
PrimitiveIndex, PrimitiveIndex,
DotIndex, DotIndex,
SegIndex, SegIndex,

View File

@ -22,7 +22,7 @@ use crate::{
}, },
geometry::{compound::ManageCompounds, GetLayer, GetSetPos}, geometry::{compound::ManageCompounds, GetLayer, GetSetPos},
graph::{GenericIndex, GetPetgraphIndex, MakeRef}, graph::{GenericIndex, GetPetgraphIndex, MakeRef},
layout::{CompoundEntryKind, CompoundWeight, Layout, LayoutEdit}, layout::{CompoundEntryLabel, CompoundWeight, Layout, LayoutEdit},
math::Circle, math::Circle,
}; };
@ -34,7 +34,7 @@ pub trait MakePolygon {
#[derive(Debug)] #[derive(Debug)]
pub struct PolyRef<'a, R> { pub struct PolyRef<'a, R> {
pub index: GenericIndex<PolyWeight>, pub index: GenericIndex<PolyWeight>,
drawing: &'a Drawing<CompoundWeight, CompoundEntryKind, R>, drawing: &'a Drawing<CompoundWeight, CompoundEntryLabel, R>,
} }
impl<'a, R: 'a> MakeRef<'a, Layout<R>> for GenericIndex<PolyWeight> { impl<'a, R: 'a> MakeRef<'a, Layout<R>> for GenericIndex<PolyWeight> {
@ -81,7 +81,7 @@ pub(super) fn add_poly_with_nodes_intern<R: AccessRules>(
layout.drawing.add_to_compound( layout.drawing.add_to_compound(
recorder, recorder,
GenericIndex::<()>::new(idx.petgraph_index()), GenericIndex::<()>::new(idx.petgraph_index()),
CompoundEntryKind::Normal, CompoundEntryLabel::Normal,
poly_compound, poly_compound,
); );
@ -123,17 +123,17 @@ pub(super) fn add_poly_with_nodes_intern<R: AccessRules>(
layout.drawing.add_to_compound( layout.drawing.add_to_compound(
recorder, recorder,
GenericIndex::<()>::new(idx.petgraph_index()), GenericIndex::<()>::new(idx.petgraph_index()),
CompoundEntryKind::NotInConvexHull, CompoundEntryLabel::NotInConvexHull,
poly_compound, poly_compound,
); );
} }
} }
// maybe this should be a different edge kind // maybe this should be a different edge label
layout.drawing.add_to_compound( layout.drawing.add_to_compound(
recorder, recorder,
apex, apex,
CompoundEntryKind::NotInConvexHull, CompoundEntryLabel::NotInConvexHull,
poly_compound, poly_compound,
); );
@ -141,7 +141,10 @@ pub(super) fn add_poly_with_nodes_intern<R: AccessRules>(
apex apex
} }
fn is_apex<R>(drawing: &Drawing<CompoundWeight, CompoundEntryKind, R>, dot: FixedDotIndex) -> bool { fn is_apex<R>(
drawing: &Drawing<CompoundWeight, CompoundEntryLabel, R>,
dot: FixedDotIndex,
) -> bool {
!drawing !drawing
.primitive(dot) .primitive(dot)
.segs() .segs()
@ -153,7 +156,7 @@ fn is_apex<R>(drawing: &Drawing<CompoundWeight, CompoundEntryKind, R>, dot: Fixe
impl<'a, R> PolyRef<'a, R> { impl<'a, R> PolyRef<'a, R> {
pub fn new( pub fn new(
index: GenericIndex<PolyWeight>, index: GenericIndex<PolyWeight>,
drawing: &'a Drawing<CompoundWeight, CompoundEntryKind, R>, drawing: &'a Drawing<CompoundWeight, CompoundEntryLabel, R>,
) -> Self { ) -> Self {
Self { index, drawing } Self { index, drawing }
} }
@ -162,8 +165,8 @@ impl<'a, R> PolyRef<'a, R> {
self.drawing self.drawing
.geometry() .geometry()
.compound_members(self.index.into()) .compound_members(self.index.into())
.find_map(|(kind, primitive_node)| { .find_map(|(label, primitive_node)| {
if kind == CompoundEntryKind::NotInConvexHull { if label == CompoundEntryLabel::NotInConvexHull {
if let PrimitiveIndex::FixedDot(dot) = primitive_node { if let PrimitiveIndex::FixedDot(dot) = primitive_node {
if is_apex(self.drawing, dot) { if is_apex(self.drawing, dot) {
return Some(dot); return Some(dot);
@ -200,7 +203,7 @@ impl<R> MakePolygon for PolyRef<'_, R> {
self.drawing self.drawing
.geometry() .geometry()
.compound_members(self.index.into()) .compound_members(self.index.into())
.filter_map(|(_kind, primitive_node)| { .filter_map(|(_label, primitive_node)| {
let PrimitiveIndex::FixedDot(dot) = primitive_node else { let PrimitiveIndex::FixedDot(dot) = primitive_node else {
return None; return None;
}; };

View File

@ -15,20 +15,20 @@ use crate::{
}, },
geometry::primitive::{DotShape, PrimitiveShape}, geometry::primitive::{DotShape, PrimitiveShape},
graph::{GenericIndex, GetPetgraphIndex}, graph::{GenericIndex, GetPetgraphIndex},
layout::{CompoundEntryKind, CompoundWeight}, layout::{CompoundEntryLabel, CompoundWeight},
math::Circle, math::Circle,
}; };
#[derive(Debug)] #[derive(Debug)]
pub struct Via<'a, R> { pub struct Via<'a, R> {
pub index: GenericIndex<ViaWeight>, pub index: GenericIndex<ViaWeight>,
drawing: &'a Drawing<CompoundWeight, CompoundEntryKind, R>, drawing: &'a Drawing<CompoundWeight, CompoundEntryLabel, R>,
} }
impl<'a, R> Via<'a, R> { impl<'a, R> Via<'a, R> {
pub fn new( pub fn new(
index: GenericIndex<ViaWeight>, index: GenericIndex<ViaWeight>,
drawing: &'a Drawing<CompoundWeight, CompoundEntryKind, R>, drawing: &'a Drawing<CompoundWeight, CompoundEntryLabel, R>,
) -> Self { ) -> Self {
Self { index, drawing } Self { index, drawing }
} }