From 83d9fce38c1830bfceeaf8a0f2921ec400f3849e Mon Sep 17 00:00:00 2001 From: Ellen Emilia Anna Zscheile Date: Wed, 30 Apr 2025 14:18:22 +0200 Subject: [PATCH] fix(geometry/compound): rename CompoundEntryKind -> CompoundEntryLabel --- src/board/mod.rs | 4 +- src/drawing/band.rs | 18 ++-- src/drawing/collect.rs | 4 +- src/drawing/drawing.rs | 102 +++++++++++----------- src/drawing/gear.rs | 26 +++--- src/drawing/graph.rs | 12 +-- src/drawing/guide.rs | 4 +- src/drawing/head.rs | 18 ++-- src/drawing/loose.rs | 22 ++--- src/drawing/primitive.rs | 126 +++++++++++++-------------- src/geometry/compound.rs | 8 +- src/geometry/edit.rs | 20 ++--- src/geometry/geometry.rs | 54 ++++++------ src/geometry/recording_with_rtree.rs | 68 +++++++-------- src/geometry/with_rtree.rs | 42 ++++----- src/layout/layout.rs | 14 +-- src/layout/poly.rs | 25 +++--- src/layout/via.rs | 6 +- 18 files changed, 290 insertions(+), 283 deletions(-) diff --git a/src/board/mod.rs b/src/board/mod.rs index c6129b3..ccbfb8f 100644 --- a/src/board/mod.rs +++ b/src/board/mod.rs @@ -23,7 +23,7 @@ use crate::{ }, geometry::{edit::ApplyGeometryEdit, GenericNode, GetLayer}, 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. @@ -225,7 +225,7 @@ impl SegWeight, BendWeight, CompoundWeight, - CompoundEntryKind, + CompoundEntryLabel, PrimitiveIndex, DotIndex, SegIndex, diff --git a/src/drawing/band.rs b/src/drawing/band.rs index 024c4a2..eaad831 100644 --- a/src/drawing/band.rs +++ b/src/drawing/band.rs @@ -37,28 +37,28 @@ impl From for LooseIndex { } } -impl<'a, CW: 'a, Cek: 'a, R: 'a> MakeRef<'a, Drawing> for BandTermsegIndex { - type Output = BandRef<'a, CW, Cek, R>; - fn ref_(&self, drawing: &'a Drawing) -> BandRef<'a, CW, Cek, R> { +impl<'a, CW: 'a, Cel: 'a, R: 'a> MakeRef<'a, Drawing> for BandTermsegIndex { + type Output = BandRef<'a, CW, Cel, R>; + fn ref_(&self, drawing: &'a Drawing) -> BandRef<'a, CW, Cel, R> { BandRef::new(*self, drawing) } } -pub struct BandRef<'a, CW, Cek, R> { +pub struct BandRef<'a, CW, Cel, R> { first_seg: BandTermsegIndex, - drawing: &'a Drawing, + drawing: &'a Drawing, } -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( first_seg: BandTermsegIndex, - drawing: &'a Drawing, - ) -> BandRef<'a, CW, Cek, R> { + drawing: &'a Drawing, + ) -> BandRef<'a, CW, Cel, R> { Self { first_seg, drawing } } } -impl MeasureLength for BandRef<'_, CW, Cek, R> { +impl MeasureLength for BandRef<'_, CW, Cel, R> { fn length(&self) -> f64 { match self.first_seg { BandTermsegIndex::Straight(seg) => { diff --git a/src/drawing/collect.rs b/src/drawing/collect.rs index 042d66a..b13d8e9 100644 --- a/src/drawing/collect.rs +++ b/src/drawing/collect.rs @@ -25,7 +25,7 @@ pub trait Collect { fn wraparounded_bows(&self, around: GearIndex) -> Vec; } -impl Collect for Drawing { +impl Collect for Drawing { fn loose_band_uid(&self, start_loose: LooseIndex) -> BandUid { BandUid::from(( self.loose_band_first_seg(start_loose), @@ -92,7 +92,7 @@ trait CollectPrivate { fn loose_band_last_seg(&self, start_loose: LooseIndex) -> BandTermsegIndex; } -impl CollectPrivate for Drawing { +impl CollectPrivate for Drawing { fn loose_band_first_seg(&self, start_loose: LooseIndex) -> BandTermsegIndex { if let LooseIndex::LoneSeg(seg) = start_loose { return BandTermsegIndex::Straight(seg); diff --git a/src/drawing/drawing.rs b/src/drawing/drawing.rs index 88a90a9..f1821b9 100644 --- a/src/drawing/drawing.rs +++ b/src/drawing/drawing.rs @@ -93,12 +93,12 @@ pub struct Collision(pub PrimitiveShape, pub PrimitiveIndex); #[error("{1:?} is already connected to net {0}")] pub struct AlreadyConnected(pub usize, pub PrimitiveIndex); -pub type DrawingEdit = GeometryEdit< +pub type DrawingEdit = GeometryEdit< DotWeight, SegWeight, BendWeight, CW, - Cek, + Cel, PrimitiveIndex, DotIndex, SegIndex, @@ -106,14 +106,14 @@ pub type DrawingEdit = GeometryEdit< >; #[derive(Clone, Debug, Getters)] -pub struct Drawing { +pub struct Drawing { recording_geometry_with_rtree: RecordingGeometryWithRtree< PrimitiveWeight, DotWeight, SegWeight, BendWeight, CW, - Cek, + Cel, PrimitiveIndex, DotIndex, SegIndex, @@ -122,7 +122,7 @@ pub struct Drawing { rules: R, } -impl Drawing { +impl Drawing { pub fn geometry( &self, ) -> &Geometry< @@ -131,7 +131,7 @@ impl Drawing { SegWeight, BendWeight, CW, - Cek, + Cel, PrimitiveIndex, DotIndex, SegIndex, @@ -148,11 +148,11 @@ impl Drawing { &mut self.rules } - pub fn primitive(&self, index: GenericIndex) -> GenericPrimitive<'_, W, CW, Cek, R> { + pub fn primitive(&self, index: GenericIndex) -> GenericPrimitive<'_, W, CW, Cel, R> { 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) } @@ -165,7 +165,7 @@ impl Drawing { } } -impl Drawing { +impl Drawing { pub fn compound_weight(&self, compound: GenericIndex) -> &CW { self.recording_geometry_with_rtree.compound_weight(compound) } @@ -173,13 +173,13 @@ impl Drawing { pub fn compounds<'a, W: 'a>( &'a self, node: GenericIndex, - ) -> impl Iterator)> + 'a { + ) -> impl Iterator)> + 'a { self.recording_geometry_with_rtree.compounds(node) } } #[debug_invariant(self.test_if_looses_dont_infringe_each_other())] -impl Drawing { +impl Drawing { pub fn new(rules: R, layer_count: usize) -> Self { Self { recording_geometry_with_rtree: RecordingGeometryWithRtree::new(layer_count), @@ -189,7 +189,7 @@ impl Drawing { pub fn remove_band( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, band: BandTermsegIndex, ) -> Result<(), DrawingException> { match band { @@ -266,7 +266,7 @@ impl Drawing { #[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] pub fn add_fixed_dot( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, weight: FixedDotWeight, ) -> Result { self.add_dot_with_infringables(recorder, weight, Some(&[])) @@ -274,7 +274,7 @@ impl Drawing { #[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()))] - pub fn remove_fixed_dot(&mut self, recorder: &mut DrawingEdit, dot: FixedDotIndex) { + pub fn remove_fixed_dot(&mut self, recorder: &mut DrawingEdit, dot: FixedDotIndex) { self.recording_geometry_with_rtree .remove_dot(recorder, dot.into()); } @@ -283,7 +283,7 @@ impl Drawing { #[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( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, weight: FixedDotWeight, ) -> FixedDotIndex { self.add_dot_infringably(recorder, weight) @@ -293,7 +293,7 @@ impl Drawing { #[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 + GetLayer>( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, weight: W, infringables: Option<&[PrimitiveIndex]>, ) -> Result, Infringement> @@ -311,7 +311,7 @@ impl Drawing { #[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] pub fn add_fixed_seg( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, from: FixedDotIndex, to: FixedDotIndex, weight: FixedSegWeight, @@ -323,7 +323,7 @@ impl Drawing { #[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( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, from: FixedDotIndex, to: FixedDotIndex, weight: FixedSegWeight, @@ -337,7 +337,7 @@ impl Drawing { #[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( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, from: FixedDotIndex, to: FixedDotIndex, weight: LoneLooseSegWeight, @@ -353,7 +353,7 @@ impl Drawing { #[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( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, from: DotIndex, to: LooseDotIndex, weight: SeqLooseSegWeight, @@ -368,7 +368,7 @@ impl Drawing { #[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 + GetLayer>( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, from: DotIndex, to: DotIndex, weight: W, @@ -390,7 +390,7 @@ impl Drawing { #[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( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, from: LooseDotIndex, to: LooseDotIndex, around: GearIndex, @@ -455,7 +455,7 @@ impl Drawing { #[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 + GetLayer>( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, from: DotIndex, to: DotIndex, core: FixedDotIndex, @@ -479,7 +479,7 @@ impl Drawing { #[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( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, from: LooseDotIndex, to: LooseDotIndex, inner: BendIndex, @@ -525,7 +525,7 @@ impl Drawing { #[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()))] - pub fn flip_bend(&mut self, recorder: &mut DrawingEdit, bend: FixedBendIndex) { + pub fn flip_bend(&mut self, recorder: &mut DrawingEdit, bend: FixedBendIndex) { self.recording_geometry_with_rtree .flip_bend(recorder, bend.into()); } @@ -536,7 +536,7 @@ impl Drawing { || self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count() + 1))] fn reattach_bend( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, bend: LooseBendIndex, maybe_new_inner: Option, ) { @@ -553,7 +553,7 @@ impl Drawing { #[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( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, from: DotIndex, around: GearIndex, dot_weight: LooseDotWeight, @@ -597,7 +597,7 @@ impl Drawing { fn update_this_and_outward_bows_intern( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, around: LooseBendIndex, ) -> Result<(), DrawingException> { let mut maybe_rail = Some(around); @@ -676,7 +676,7 @@ impl Drawing { #[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( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, around: LooseBendIndex, ) -> Result<(), DrawingException> { let mut temp_recorder = DrawingEdit::new(); @@ -696,7 +696,7 @@ impl Drawing { #[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( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, from: DotIndex, around: GearIndex, dot_weight: LooseDotWeight, @@ -722,7 +722,7 @@ impl Drawing { #[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( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, from: DotIndex, around: GearIndex, dot_weight: LooseDotWeight, @@ -781,7 +781,7 @@ impl Drawing { #[debug_ensures(self.recording_geometry_with_rtree.graph().node_count() == old(self.recording_geometry_with_rtree.graph().node_count() - 4))] pub fn remove_cane( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, cane: &Cane, face: LooseDotIndex, ) { @@ -818,7 +818,7 @@ impl Drawing { #[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] pub fn move_dot( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, dot: DotIndex, to: Point, ) -> Result<(), Infringement> { @@ -832,7 +832,7 @@ impl Drawing { #[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] fn move_dot_with_infringables( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, dot: DotIndex, to: Point, infringables: Option<&[PrimitiveIndex]>, @@ -868,7 +868,7 @@ impl Drawing { #[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count()))] fn shift_bend_with_infringables( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, bend: BendIndex, offset: f64, infringables: Option<&[PrimitiveIndex]>, @@ -910,12 +910,12 @@ impl Drawing { } } -impl Drawing { +impl Drawing { #[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()))] fn add_dot_infringably + GetLayer>( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, weight: W, ) -> GenericIndex where @@ -928,7 +928,7 @@ impl Drawing { #[debug_ensures(self.recording_geometry_with_rtree.graph().edge_count() == old(self.recording_geometry_with_rtree.graph().edge_count() + 2))] fn add_seg_infringably + GetLayer>( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, from: DotIndex, to: DotIndex, weight: W, @@ -942,7 +942,7 @@ impl Drawing { pub fn add_compound( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, weight: CW, ) -> GenericIndex { self.recording_geometry_with_rtree @@ -951,7 +951,7 @@ impl Drawing { pub fn remove_compound( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, compound: GenericIndex, ) { self.recording_geometry_with_rtree @@ -960,13 +960,17 @@ impl Drawing { pub fn add_to_compound( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, primitive: GenericIndex, - entry_kind: Cek, + entry_label: Cel, compound: GenericIndex, ) { - self.recording_geometry_with_rtree - .add_to_compound(recorder, primitive, entry_kind, compound); + self.recording_geometry_with_rtree.add_to_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()))] @@ -974,7 +978,7 @@ impl Drawing { #[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( &mut self, - recorder: &mut DrawingEdit, + recorder: &mut DrawingEdit, node: PrimitiveIndex, maybe_except: Option<&[PrimitiveIndex]>, ) -> Result<(), Infringement> { @@ -1172,20 +1176,20 @@ impl Drawing { } } -impl +impl ApplyGeometryEdit< DotWeight, SegWeight, BendWeight, CW, - Cek, + Cel, PrimitiveIndex, DotIndex, SegIndex, BendIndex, - > for Drawing + > for Drawing { - fn apply(&mut self, edit: &DrawingEdit) { + fn apply(&mut self, edit: &DrawingEdit) { self.recording_geometry_with_rtree.apply(edit); } } diff --git a/src/drawing/gear.rs b/src/drawing/gear.rs index c3bcffe..f3a10cc 100644 --- a/src/drawing/gear.rs +++ b/src/drawing/gear.rs @@ -30,10 +30,10 @@ pub enum GearIndex { LooseBend(LooseBendIndex), } -impl<'a, CW: 'a, Cek: 'a, R: 'a> MakeRef<'a, Drawing> for GearIndex { - type Output = GearRef<'a, CW, Cek, R>; - fn ref_(&self, drawing: &'a Drawing) -> GearRef<'a, CW, Cek, R> { - GearRef::<'a, CW, Cek, R>::new(*self, drawing) +impl<'a, CW: 'a, Cel: 'a, R: 'a> MakeRef<'a, Drawing> for GearIndex { + type Output = GearRef<'a, CW, Cel, R>; + fn ref_(&self, drawing: &'a Drawing) -> GearRef<'a, CW, Cel, R> { + GearRef::<'a, CW, Cel, R>::new(*self, drawing) } } @@ -57,14 +57,14 @@ impl From for GearIndex { } #[enum_dispatch(GetNextGear, GetDrawing, GetPetgraphIndex)] -pub enum GearRef<'a, CW, Cek, R> { - FixedDot(FixedDot<'a, CW, Cek, R>), - FixedBend(FixedBend<'a, CW, Cek, R>), - LooseBend(LooseBend<'a, CW, Cek, R>), +pub enum GearRef<'a, CW, Cel, R> { + FixedDot(FixedDot<'a, CW, Cel, R>), + FixedBend(FixedBend<'a, CW, Cel, R>), + LooseBend(LooseBend<'a, CW, Cel, R>), } -impl<'a, CW, Cek, R> GearRef<'a, CW, Cek, R> { - pub fn new(index: GearIndex, drawing: &'a Drawing) -> Self { +impl<'a, CW, Cel, R> GearRef<'a, CW, Cel, R> { + pub fn new(index: GearIndex, drawing: &'a Drawing) -> Self { match index { GearIndex::FixedDot(dot) => drawing.primitive(dot).into(), GearIndex::FixedBend(bend) => drawing.primitive(bend).into(), @@ -73,19 +73,19 @@ impl<'a, CW, Cek, R> GearRef<'a, CW, Cek, R> { } } -impl GetNextGear for FixedDot<'_, CW, Cek, R> { +impl GetNextGear for FixedDot<'_, CW, Cel, R> { fn next_gear(&self) -> Option { self.first_gear() } } -impl GetNextGear for LooseBend<'_, CW, Cek, R> { +impl GetNextGear for LooseBend<'_, CW, Cel, R> { fn next_gear(&self) -> Option { self.outer() } } -impl GetNextGear for FixedBend<'_, CW, Cek, R> { +impl GetNextGear for FixedBend<'_, CW, Cel, R> { fn next_gear(&self) -> Option { self.first_gear() } diff --git a/src/drawing/graph.rs b/src/drawing/graph.rs index b4c2795..035fa34 100644 --- a/src/drawing/graph.rs +++ b/src/drawing/graph.rs @@ -47,10 +47,10 @@ pub trait GetMaybeNet { #[enum_dispatch] pub trait MakePrimitive { - fn primitive<'a, CW: Clone, Cek: Copy, R: AccessRules>( + fn primitive<'a, CW: Clone, Cel: Copy, R: AccessRules>( &self, - drawing: &'a Drawing, - ) -> Primitive<'a, CW, Cek, R>; + drawing: &'a Drawing, + ) -> Primitive<'a, CW, Cel, R>; } macro_rules! impl_weight_forward { @@ -76,10 +76,10 @@ macro_rules! impl_weight_forward { pub type $index_struct = GenericIndex<$weight_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, - drawing: &'a crate::drawing::Drawing, - ) -> Primitive<'a, CW, Cek, R> { + drawing: &'a crate::drawing::Drawing, + ) -> Primitive<'a, CW, Cel, R> { Primitive::$weight_variant(GenericPrimitive::new(*self, drawing)) } } diff --git a/src/drawing/guide.rs b/src/drawing/guide.rs index 7c571a3..330c720 100644 --- a/src/drawing/guide.rs +++ b/src/drawing/guide.rs @@ -73,7 +73,7 @@ pub trait Guide { fn head(&self, face: DotIndex) -> Head; } -impl Guide for Drawing { +impl Guide for Drawing { fn head_into_dot_segment( &self, head: &Head, @@ -223,7 +223,7 @@ trait GuidePrivate { fn conditions(&self, node: PrimitiveIndex) -> Option>; } -impl GuidePrivate for Drawing { +impl GuidePrivate for Drawing { fn clearance(&self, lhs: Option<&Conditions<'_>>, rhs: Option<&Conditions<'_>>) -> f64 { match (lhs, rhs) { (None, _) | (_, None) => 0.0, diff --git a/src/drawing/head.rs b/src/drawing/head.rs index 8974fb0..7aece60 100644 --- a/src/drawing/head.rs +++ b/src/drawing/head.rs @@ -29,9 +29,9 @@ pub enum Head { Cane(CaneHead), } -impl<'a, CW: 'a, Cek: 'a, R: 'a> MakeRef<'a, Drawing> for Head { - type Output = HeadRef<'a, CW, Cek, R>; - fn ref_(&self, drawing: &'a Drawing) -> HeadRef<'a, CW, Cek, R> { +impl<'a, CW: 'a, Cel: 'a, R: 'a> MakeRef<'a, Drawing> for Head { + type Output = HeadRef<'a, CW, Cel, R>; + fn ref_(&self, drawing: &'a Drawing) -> HeadRef<'a, CW, Cel, R> { 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, - drawing: &'a Drawing, + drawing: &'a Drawing, } -impl<'a, CW, Cek, R> HeadRef<'a, CW, Cek, R> { - pub fn new(head: Head, drawing: &'a Drawing) -> Self { +impl<'a, CW, Cel, R> HeadRef<'a, CW, Cel, R> { + pub fn new(head: Head, drawing: &'a Drawing) -> Self { Self { drawing, head } } } -impl GetFace for HeadRef<'_, CW, Cek, R> { +impl GetFace for HeadRef<'_, CW, Cel, R> { fn face(&self) -> DotIndex { self.head.face() } } -impl MeasureLength for HeadRef<'_, CW, Cek, R> { +impl MeasureLength for HeadRef<'_, CW, Cel, R> { fn length(&self) -> f64 { match self.head { Head::Bare(..) => 0.0, diff --git a/src/drawing/loose.rs b/src/drawing/loose.rs index cc94e58..3fcabee 100644 --- a/src/drawing/loose.rs +++ b/src/drawing/loose.rs @@ -70,15 +70,15 @@ impl TryFrom for LooseIndex { } #[enum_dispatch(GetPrevNextLoose, GetDrawing, GetPetgraphIndex)] -pub enum Loose<'a, CW, Cek, R> { - Dot(LooseDot<'a, CW, Cek, R>), - LoneSeg(LoneLooseSeg<'a, CW, Cek, R>), - SeqSeg(SeqLooseSeg<'a, CW, Cek, R>), - Bend(LooseBend<'a, CW, Cek, R>), +pub enum Loose<'a, CW, Cel, R> { + Dot(LooseDot<'a, CW, Cel, R>), + LoneSeg(LoneLooseSeg<'a, CW, Cel, R>), + SeqSeg(SeqLooseSeg<'a, CW, Cel, R>), + Bend(LooseBend<'a, CW, Cel, R>), } -impl<'a, CW, Cek, R> Loose<'a, CW, Cek, R> { - pub fn new(index: LooseIndex, drawing: &'a Drawing) -> Self { +impl<'a, CW, Cel, R> Loose<'a, CW, Cel, R> { + pub fn new(index: LooseIndex, drawing: &'a Drawing) -> Self { match index { LooseIndex::Dot(dot) => drawing.primitive(dot).into(), LooseIndex::LoneSeg(seg) => drawing.primitive(seg).into(), @@ -88,7 +88,7 @@ impl<'a, CW, Cek, R> Loose<'a, CW, Cek, R> { } } -impl GetPrevNextLoose for LooseDot<'_, CW, Cek, R> { +impl GetPrevNextLoose for LooseDot<'_, CW, Cel, R> { fn next_loose(&self, maybe_prev: Option) -> Option { let bend = self.bend(); @@ -104,13 +104,13 @@ impl GetPrevNextLoose for LooseDot<'_, CW, Cek, R> { } } -impl GetPrevNextLoose for LoneLooseSeg<'_, CW, Cek, R> { +impl GetPrevNextLoose for LoneLooseSeg<'_, CW, Cel, R> { fn next_loose(&self, _maybe_prev: Option) -> Option { None } } -impl GetPrevNextLoose for SeqLooseSeg<'_, CW, Cek, R> { +impl GetPrevNextLoose for SeqLooseSeg<'_, CW, Cel, R> { fn next_loose(&self, maybe_prev: Option) -> Option { let joints = self.joints(); let Some(prev) = maybe_prev else { @@ -128,7 +128,7 @@ impl GetPrevNextLoose for SeqLooseSeg<'_, CW, Cek, R> { } } -impl GetPrevNextLoose for LooseBend<'_, CW, Cek, R> { +impl GetPrevNextLoose for LooseBend<'_, CW, Cel, R> { fn next_loose(&self, maybe_prev: Option) -> Option { let joints = self.joints(); diff --git a/src/drawing/primitive.rs b/src/drawing/primitive.rs index 7dd847d..2d26d97 100644 --- a/src/drawing/primitive.rs +++ b/src/drawing/primitive.rs @@ -20,9 +20,9 @@ use crate::{ pub trait GetDrawing { type CompoundWeight; - type CompoundEntryKind; + type CompoundEntryLabel; type Rules; - fn drawing(&self) -> &Drawing; + fn drawing(&self) -> &Drawing; } #[enum_dispatch] @@ -108,7 +108,7 @@ impl GetCore for S { macro_rules! impl_primitive { ($primitive_struct:ident, $weight_struct:ident) => { - impl GetWeight<$weight_struct> for $primitive_struct<'_, CW, Cek, R> { + impl GetWeight<$weight_struct> for $primitive_struct<'_, CW, Cel, R> { fn weight(&self) -> $weight_struct { if let PrimitiveWeight::$primitive_struct(weight) = self.tagged_weight() { weight @@ -118,13 +118,13 @@ macro_rules! impl_primitive { } } - impl GetLayer for $primitive_struct<'_, CW, Cek, R> { + impl GetLayer for $primitive_struct<'_, CW, Cel, R> { fn layer(&self) -> usize { self.weight().layer() } } - impl GetMaybeNet for $primitive_struct<'_, CW, Cek, R> { + impl GetMaybeNet for $primitive_struct<'_, CW, Cel, R> { fn maybe_net(&self) -> Option { self.weight().maybe_net() } @@ -152,17 +152,17 @@ macro_rules! impl_loose_primitive { MakePrimitiveShape, GetLimbs )] -pub enum Primitive<'a, CW, Cek, R> { - FixedDot(FixedDot<'a, CW, Cek, R>), - LooseDot(LooseDot<'a, CW, Cek, R>), - FixedSeg(FixedSeg<'a, CW, Cek, R>), - LoneLooseSeg(LoneLooseSeg<'a, CW, Cek, R>), - SeqLooseSeg(SeqLooseSeg<'a, CW, Cek, R>), - FixedBend(FixedBend<'a, CW, Cek, R>), - LooseBend(LooseBend<'a, CW, Cek, R>), +pub enum Primitive<'a, CW, Cel, R> { + FixedDot(FixedDot<'a, CW, Cel, R>), + LooseDot(LooseDot<'a, CW, Cel, R>), + FixedSeg(FixedSeg<'a, CW, Cel, R>), + LoneLooseSeg(LoneLooseSeg<'a, CW, Cel, R>), + SeqLooseSeg(SeqLooseSeg<'a, CW, Cel, R>), + FixedBend(FixedBend<'a, CW, Cel, 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> { match self { 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)] -pub struct GenericPrimitive<'a, W, CW, Cek, R> { +pub struct GenericPrimitive<'a, W, CW, Cel, R> { pub index: GenericIndex, - drawing: &'a Drawing, + drawing: &'a Drawing, } -impl<'a, W, CW, Cek, R> GenericPrimitive<'a, W, CW, Cek, R> { - pub fn new(index: GenericIndex, drawing: &'a Drawing) -> Self { +impl<'a, W, CW, Cel, R> GenericPrimitive<'a, W, CW, Cel, R> { + pub fn new(index: GenericIndex, drawing: &'a Drawing) -> Self { Self { index, drawing } } @@ -202,39 +202,39 @@ impl<'a, W, CW, Cek, R> GenericPrimitive<'a, W, CW, Cek, R> { } } -impl GetInterior for GenericPrimitive<'_, W, CW, Cek, R> { +impl GetInterior for GenericPrimitive<'_, W, CW, Cel, R> { fn interior(&self) -> Vec { vec![self.tagged_weight().retag(self.index.petgraph_index())] } } -impl GetDrawing for GenericPrimitive<'_, W, CW, Cek, R> { +impl GetDrawing for GenericPrimitive<'_, W, CW, Cel, R> { type CompoundWeight = CW; - type CompoundEntryKind = Cek; + type CompoundEntryLabel = Cel; type Rules = R; - fn drawing(&self) -> &Drawing { + fn drawing(&self) -> &Drawing { self.drawing } } -impl GetPetgraphIndex for GenericPrimitive<'_, W, CW, Cek, R> { +impl GetPetgraphIndex for GenericPrimitive<'_, W, CW, Cel, R> { fn petgraph_index(&self) -> NodeIndex { 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 - GenericPrimitive<'a, W, CW, Cek, R>: GetWeight, + GenericPrimitive<'a, W, CW, Cel, R>: GetWeight, { fn width(&self) -> f64 { 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 - GenericPrimitive<'a, W, CW, Cek, R>: GetMaybeNet, + GenericPrimitive<'a, W, CW, Cel, R>: GetMaybeNet, { fn conditions(self) -> Option> { 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 MakePrimitiveShape for FixedDot<'_, CW, Cek, R> { +impl MakePrimitiveShape for FixedDot<'_, CW, Cel, R> { fn shape(&self) -> PrimitiveShape { self.drawing.geometry().dot_shape(self.index.into()) } } -impl GetLimbs for FixedDot<'_, CW, Cek, R> { +impl GetLimbs for FixedDot<'_, CW, Cel, R> { fn segs(&self) -> Vec { self.drawing .geometry() @@ -270,12 +270,12 @@ impl GetLimbs for FixedDot<'_, CW, Cek, R> { } } -impl GetFirstGear for FixedDot<'_, CW, Cek, R> {} +impl 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 LooseDot<'_, CW, Cek, R> { +impl LooseDot<'_, CW, Cel, R> { pub fn seg(&self) -> Option { self.drawing .geometry() @@ -294,13 +294,13 @@ impl LooseDot<'_, CW, Cek, R> { } } -impl MakePrimitiveShape for LooseDot<'_, CW, Cek, R> { +impl MakePrimitiveShape for LooseDot<'_, CW, Cel, R> { fn shape(&self) -> PrimitiveShape { self.drawing.geometry().dot_shape(self.index.into()) } } -impl GetLimbs for LooseDot<'_, CW, Cek, R> { +impl GetLimbs for LooseDot<'_, CW, Cel, R> { fn segs(&self) -> Vec { if let Some(seg) = self.seg() { vec![seg.into()] @@ -314,18 +314,18 @@ impl 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 MakePrimitiveShape for FixedSeg<'_, CW, Cek, R> { +impl MakePrimitiveShape for FixedSeg<'_, CW, Cel, R> { fn shape(&self) -> PrimitiveShape { self.drawing.geometry().seg_shape(self.index.into()) } } -impl GetLimbs for FixedSeg<'_, CW, Cek, R> {} +impl GetLimbs for FixedSeg<'_, CW, Cel, R> {} -impl GetJoints for FixedSeg<'_, CW, Cek, R> { +impl GetJoints for FixedSeg<'_, CW, Cel, R> { fn joints(&self) -> (FixedDotIndex, FixedDotIndex) { let (from, to) = self.drawing.geometry().seg_joints(self.index.into()); ( @@ -335,18 +335,18 @@ impl GetJoints 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 MakePrimitiveShape for LoneLooseSeg<'_, CW, Cek, R> { +impl MakePrimitiveShape for LoneLooseSeg<'_, CW, Cel, R> { fn shape(&self) -> PrimitiveShape { self.drawing.geometry().seg_shape(self.index.into()) } } -impl GetLimbs for LoneLooseSeg<'_, CW, Cek, R> {} +impl GetLimbs for LoneLooseSeg<'_, CW, Cel, R> {} -impl GetJoints for LoneLooseSeg<'_, CW, Cek, R> { +impl GetJoints for LoneLooseSeg<'_, CW, Cel, R> { fn joints(&self) -> (FixedDotIndex, FixedDotIndex) { let (from, to) = self.drawing.geometry().seg_joints(self.index.into()); ( @@ -356,18 +356,18 @@ impl GetJoints 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 MakePrimitiveShape for SeqLooseSeg<'_, CW, Cek, R> { +impl MakePrimitiveShape for SeqLooseSeg<'_, CW, Cel, R> { fn shape(&self) -> PrimitiveShape { self.drawing.geometry().seg_shape(self.index.into()) } } -impl GetLimbs for SeqLooseSeg<'_, CW, Cek, R> {} +impl GetLimbs for SeqLooseSeg<'_, CW, Cel, R> {} -impl GetJoints for SeqLooseSeg<'_, CW, Cek, R> { +impl GetJoints for SeqLooseSeg<'_, CW, Cel, R> { fn joints(&self) -> (DotIndex, LooseDotIndex) { let joints = self.drawing.geometry().seg_joints(self.index.into()); if let DotWeight::Fixed(..) = self.drawing.geometry().dot_weight(joints.0) { @@ -389,24 +389,24 @@ impl GetJoints 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 GetBendIndex for FixedBend<'_, CW, Cek, R> { +impl GetBendIndex for FixedBend<'_, CW, Cel, R> { fn bend_index(&self) -> BendIndex { self.index.into() } } -impl MakePrimitiveShape for FixedBend<'_, CW, Cek, R> { +impl MakePrimitiveShape for FixedBend<'_, CW, Cel, R> { fn shape(&self) -> PrimitiveShape { self.drawing.geometry().bend_shape(self.index.into()) } } -impl GetLimbs for FixedBend<'_, CW, Cek, R> {} +impl GetLimbs for FixedBend<'_, CW, Cel, R> {} -impl GetJoints for FixedBend<'_, CW, Cek, R> { +impl GetJoints for FixedBend<'_, CW, Cel, R> { fn joints(&self) -> (FixedDotIndex, FixedDotIndex) { let (from, to) = self.drawing.geometry().bend_joints(self.index.into()); ( @@ -416,39 +416,39 @@ impl GetJoints for FixedBend<'_, CW, C } } -impl GetFirstGear for FixedBend<'_, CW, Cek, R> {} -//impl<'a, R: QueryRules> GetInnerOuter for FixedBend<'a, CW, Cek, R> {} +impl GetFirstGear for FixedBend<'_, CW, Cel, 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 GetBendIndex for LooseBend<'_, CW, Cek, R> { +impl GetBendIndex for LooseBend<'_, CW, Cel, R> { fn bend_index(&self) -> BendIndex { self.index.into() } } -impl<'a, CW: Clone, Cek: Copy, R: AccessRules> From> for BendIndex { - fn from(bend: LooseBend<'a, CW, Cek, R>) -> BendIndex { +impl<'a, CW: Clone, Cel: Copy, R: AccessRules> From> for BendIndex { + fn from(bend: LooseBend<'a, CW, Cel, R>) -> BendIndex { bend.index.into() } } -impl MakePrimitiveShape for LooseBend<'_, CW, Cek, R> { +impl MakePrimitiveShape for LooseBend<'_, CW, Cel, R> { fn shape(&self) -> PrimitiveShape { self.drawing.geometry().bend_shape(self.index.into()) } } -impl GetLimbs for LooseBend<'_, CW, Cek, R> {} +impl GetLimbs for LooseBend<'_, CW, Cel, R> {} -impl GetOffset for LooseBend<'_, CW, Cek, R> { +impl GetOffset for LooseBend<'_, CW, Cel, R> { fn offset(&self) -> f64 { self.weight().offset() } } -impl GetJoints for LooseBend<'_, CW, Cek, R> { +impl GetJoints for LooseBend<'_, CW, Cel, R> { fn joints(&self) -> (LooseDotIndex, LooseDotIndex) { let (from, to) = self.drawing.geometry().bend_joints(self.index.into()); ( @@ -458,7 +458,7 @@ impl GetJoints for LooseBend<'_, CW, C } } -impl LooseBend<'_, CW, Cek, R> { +impl LooseBend<'_, CW, Cel, R> { pub fn inner(&self) -> Option { self.drawing() .geometry() diff --git a/src/geometry/compound.rs b/src/geometry/compound.rs index 0c5d9a7..d8cbf1b 100644 --- a/src/geometry/compound.rs +++ b/src/geometry/compound.rs @@ -6,11 +6,11 @@ use crate::graph::{GenericIndex, GetPetgraphIndex}; pub trait ManageCompounds { type GeneralIndex: Copy; - type EntryKind: Copy; + type EntryLabel: Copy; fn add_compound(&mut self, weight: CW) -> GenericIndex; fn remove_compound(&mut self, compound: GenericIndex); - fn add_to_compound(&mut self, node: I, kind: Self::EntryKind, compound: GenericIndex) + fn add_to_compound(&mut self, node: I, label: Self::EntryLabel, compound: GenericIndex) where I: Copy + GetPetgraphIndex; @@ -19,9 +19,9 @@ pub trait ManageCompounds { fn compound_members( &self, compound: GenericIndex, - ) -> impl Iterator + '_; + ) -> impl Iterator + '_; - fn compounds(&self, node: I) -> impl Iterator)> + fn compounds(&self, node: I) -> impl Iterator)> where I: Copy + GetPetgraphIndex; } diff --git a/src/geometry/edit.rs b/src/geometry/edit.rs index e275e62..8342b14 100644 --- a/src/geometry/edit.rs +++ b/src/geometry/edit.rs @@ -13,23 +13,23 @@ pub trait ApplyGeometryEdit< SW: AccessSegWeight + GetLayer, BW: AccessBendWeight + GetLayer, CW: Clone, - Cek: Copy, + Cel: Copy, PI: GetPetgraphIndex + TryInto + TryInto + TryInto + Eq + Ord + Copy, DI: GetPetgraphIndex + Into + Eq + Ord + Copy, SI: GetPetgraphIndex + Into + Eq + Ord + Copy, BI: GetPetgraphIndex + Into + Eq + Ord + Copy, > { - fn apply(&mut self, edit: &GeometryEdit); + fn apply(&mut self, edit: &GeometryEdit); } #[derive(Debug, Clone)] -pub struct GeometryEdit { +pub struct GeometryEdit { pub(super) dots: BTreeMap, Option)>, pub(super) segs: BTreeMap, Option<((DI, DI), SW)>)>, pub(super) bends: BTreeMap, Option<((DI, DI, DI), BW)>)>, pub(super) compounds: - BTreeMap, (Option<(Vec<(Cek, PI)>, CW)>, Option<(Vec<(Cek, PI)>, CW)>)>, + BTreeMap, (Option<(Vec<(Cel, PI)>, CW)>, Option<(Vec<(Cel, PI)>, CW)>)>, } fn swap_tuple_inplace(x: &mut (D, D)) { @@ -41,12 +41,12 @@ impl< SW: AccessSegWeight + GetLayer, BW: AccessBendWeight + GetLayer, CW: Clone, - Cek: Copy, + Cel: Copy, PI: GetPetgraphIndex + TryInto + TryInto + TryInto + Eq + Ord + Copy, DI: GetPetgraphIndex + Into + Eq + Ord + Copy, SI: GetPetgraphIndex + Into + Eq + Ord + Copy, BI: GetPetgraphIndex + Into + Eq + Ord + Copy, - > GeometryEdit + > GeometryEdit { pub fn new() -> Self { Self { @@ -93,15 +93,15 @@ impl< SW: AccessSegWeight + GetLayer, BW: AccessBendWeight + GetLayer, CW: Clone, - Cek: Copy, + Cel: Copy, PI: GetPetgraphIndex + TryInto + TryInto + TryInto + Eq + Ord + Copy, DI: GetPetgraphIndex + Into + Eq + Ord + Copy, SI: GetPetgraphIndex + Into + Eq + Ord + Copy, BI: GetPetgraphIndex + Into + Eq + Ord + Copy, - > ApplyGeometryEdit - for GeometryEdit + > ApplyGeometryEdit + for GeometryEdit { - fn apply(&mut self, edit: &GeometryEdit) { + fn apply(&mut self, edit: &GeometryEdit) { apply_btmap(&mut self.dots, &edit.dots); apply_btmap(&mut self.segs, &edit.segs); apply_btmap(&mut self.bends, &edit.bends); diff --git a/src/geometry/geometry.rs b/src/geometry/geometry.rs index c55270e..ccbed2d 100644 --- a/src/geometry/geometry.rs +++ b/src/geometry/geometry.rs @@ -60,11 +60,11 @@ pub trait SetOffset: GetOffset { } #[derive(Copy, Clone, Debug, PartialEq, Eq)] -pub enum GeometryLabel { +pub enum GeometryLabel { Joined, Outer, Core, - Compound(Cek), + Compound(Cel), } #[derive(Clone, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)] @@ -83,8 +83,8 @@ pub trait AccessBendWeight: SetOffset + GetWidth + Copy {} impl AccessBendWeight for T {} #[derive(Debug)] -pub struct Geometry { - graph: StableDiGraph, GeometryLabel, usize>, +pub struct Geometry { + graph: StableDiGraph, GeometryLabel, usize>, primitive_weight_marker: PhantomData, dot_weight_marker: PhantomData, seg_weight_marker: PhantomData, @@ -96,8 +96,8 @@ pub struct Geometry { bend_index_marker: PhantomData, } -impl Clone - for Geometry +impl Clone + for Geometry { fn clone(&self) -> Self { Self { @@ -107,15 +107,15 @@ impl Clone } } -impl Default - for Geometry +impl Default + for Geometry { fn default() -> Self { Self::new() } } -impl Geometry { +impl Geometry { pub fn new() -> Self { Self { graph: StableDiGraph::default(), @@ -135,7 +135,7 @@ impl Geometry &StableDiGraph, GeometryLabel, usize> { + pub fn graph(&self) -> &StableDiGraph, GeometryLabel, usize> { &self.graph } @@ -157,12 +157,12 @@ impl< SW: AccessSegWeight + Into, BW: AccessBendWeight + Into, CW, - Cek, + Cel, PI: GetPetgraphIndex + TryInto + TryInto + TryInto + Copy, DI: GetPetgraphIndex + Into + Copy, SI: GetPetgraphIndex + Into + Copy, BI: GetPetgraphIndex + Into + Copy, - > Geometry + > Geometry { pub fn add_dot>(&mut self, weight: W) -> GenericIndex { GenericIndex::::new(self.graph.add_node(GenericNode::Primitive(weight.into()))) @@ -484,8 +484,8 @@ impl< } } -impl, DW, SW, BW, CW, Cek, PI, DI, SI, BI> - Geometry +impl, DW, SW, BW, CW, Cel, PI, DI, SI, BI> + Geometry { fn primitive_index(&self, index: NodeIndex) -> PI { self.primitive_weight(index).retag(index) @@ -498,12 +498,12 @@ impl< SW, BW, CW, - Cek, + Cel, PI: TryInto + TryInto + TryInto, DI, SI, BI: GetPetgraphIndex, - > Geometry + > Geometry { pub fn first_rail(&self, node: NodeIndex) -> Option { self.graph @@ -551,11 +551,11 @@ impl< } } -impl, DW, SW, BW, CW: Clone, Cek: Copy, PI: Copy, DI, SI, BI> - ManageCompounds for Geometry +impl, DW, SW, BW, CW: Clone, Cel: Copy, PI: Copy, DI, SI, BI> + ManageCompounds for Geometry { type GeneralIndex = PI; - type EntryKind = Cek; + type EntryLabel = Cel; fn add_compound(&mut self, weight: CW) -> GenericIndex { GenericIndex::::new(self.graph.add_node(GenericNode::Compound(weight))) @@ -565,14 +565,14 @@ impl, DW, SW, BW, CW: Clone, Cek: Copy, PI: Copy, D self.graph.remove_node(compound.petgraph_index()); } - fn add_to_compound(&mut self, primitive: I, entry_kind: Cek, compound: GenericIndex) + fn add_to_compound(&mut self, primitive: I, entry_label: Cel, compound: GenericIndex) where I: Copy + GetPetgraphIndex, { self.graph.update_edge( primitive.petgraph_index(), compound.petgraph_index(), - GeometryLabel::Compound(entry_kind), + GeometryLabel::Compound(entry_label), ); } @@ -589,27 +589,27 @@ impl, DW, SW, BW, CW: Clone, Cek: Copy, PI: Copy, D fn compound_members( &self, compound: GenericIndex, - ) -> impl Iterator + '_ { + ) -> impl Iterator + '_ { self.graph .edges_directed(compound.petgraph_index(), Incoming) .filter_map(|edge| { - if let GeometryLabel::Compound(entry_kind) = *edge.weight() { - Some((entry_kind, self.primitive_index(edge.source()))) + if let GeometryLabel::Compound(entry_label) = *edge.weight() { + Some((entry_label, self.primitive_index(edge.source()))) } else { None } }) } - fn compounds(&self, node: I) -> impl Iterator)> + fn compounds(&self, node: I) -> impl Iterator)> where I: Copy + GetPetgraphIndex, { self.graph .edges_directed(node.petgraph_index(), Outgoing) .filter_map(|edge| { - if let GeometryLabel::Compound(entry_kind) = *edge.weight() { - Some((entry_kind, GenericIndex::new(edge.target()))) + if let GeometryLabel::Compound(entry_label) = *edge.weight() { + Some((entry_label, GenericIndex::new(edge.target()))) } else { None } diff --git a/src/geometry/recording_with_rtree.rs b/src/geometry/recording_with_rtree.rs index d8ecdd6..e4718a5 100644 --- a/src/geometry/recording_with_rtree.rs +++ b/src/geometry/recording_with_rtree.rs @@ -19,12 +19,12 @@ use super::{ }; #[derive(Debug)] -pub struct RecordingGeometryWithRtree { - geometry_with_rtree: GeometryWithRtree, +pub struct RecordingGeometryWithRtree { + geometry_with_rtree: GeometryWithRtree, } -impl Clone - for RecordingGeometryWithRtree +impl Clone + for RecordingGeometryWithRtree { fn clone(&self) -> Self { Self { @@ -33,10 +33,10 @@ impl Clone } } -impl - RecordingGeometryWithRtree +impl + RecordingGeometryWithRtree { - pub fn geometry(&self) -> &Geometry { + pub fn geometry(&self) -> &Geometry { self.geometry_with_rtree.geometry() } @@ -48,7 +48,7 @@ impl *self.geometry_with_rtree.layer_count() } - pub fn graph(&self) -> &StableDiGraph, GeometryLabel, usize> { + pub fn graph(&self) -> &StableDiGraph, GeometryLabel, usize> { self.geometry_with_rtree.graph() } } @@ -59,12 +59,12 @@ impl< SW: AccessSegWeight + Into + GetLayer, BW: AccessBendWeight + Into + GetLayer, CW: Clone, - Cek: Copy, + Cel: Copy, PI: GetPetgraphIndex + TryInto + TryInto + TryInto + Eq + Ord + Copy, DI: GetPetgraphIndex + Into + Eq + Ord + Copy, SI: GetPetgraphIndex + Into + Eq + Ord + Copy, BI: GetPetgraphIndex + Into + Eq + Ord + Copy, - > RecordingGeometryWithRtree + > RecordingGeometryWithRtree { pub fn new(layer_count: usize) -> Self { Self { @@ -74,7 +74,7 @@ impl< pub fn add_dot + GetLayer>( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, weight: W, ) -> GenericIndex where @@ -95,7 +95,7 @@ impl< pub fn add_seg + GetLayer>( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, from: DI, to: DI, weight: W, @@ -121,7 +121,7 @@ impl< pub fn add_bend + GetLayer>( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, from: DI, to: DI, core: DI, @@ -148,7 +148,7 @@ impl< pub fn add_compound( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, weight: CW, ) -> GenericIndex { let compound = self.geometry_with_rtree.add_compound(weight.clone()); @@ -160,9 +160,9 @@ impl< pub fn add_to_compound( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, primitive: GenericIndex, - entry_kind: Cek, + entry_label: Cel, compound: GenericIndex, ) { let geometry = self.geometry_with_rtree.geometry(); @@ -170,7 +170,7 @@ impl< let old_weight = geometry.compound_weight(compound).clone(); 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 new_members = geometry.compound_members(compound).collect(); @@ -185,7 +185,7 @@ impl< pub fn remove_dot( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, dot: DI, ) -> Result<(), ()> { let weight = self.geometry_with_rtree.geometry().dot_weight(dot); @@ -196,7 +196,7 @@ impl< pub fn remove_seg( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, seg: SI, ) { let geometry = self.geometry_with_rtree.geometry(); @@ -208,7 +208,7 @@ impl< pub fn remove_bend( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, bend: BI, ) { let geometry = self.geometry_with_rtree.geometry(); @@ -225,7 +225,7 @@ impl< pub fn remove_compound( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, compound: GenericIndex, ) { let geometry = self.geometry_with_rtree.geometry(); @@ -237,7 +237,7 @@ impl< pub fn move_dot( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, dot: DI, to: Point, ) { @@ -254,11 +254,11 @@ impl< fn modify_bend( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, bend: BI, f: F, ) where - F: FnOnce(&mut GeometryWithRtree, BI), + F: FnOnce(&mut GeometryWithRtree, BI), { let geometry = self.geometry_with_rtree.geometry(); let old_joints = geometry.bend_joints(bend); @@ -284,7 +284,7 @@ impl< pub fn shift_bend( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, bend: BI, offset: f64, ) { @@ -295,7 +295,7 @@ impl< pub fn flip_bend( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, bend: BI, ) { self.modify_bend(recorder, bend, |geometry_with_rtree, bend| { @@ -305,7 +305,7 @@ impl< pub fn reattach_bend( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, bend: BI, maybe_new_inner: Option, ) { @@ -321,7 +321,7 @@ impl< pub fn compounds<'a, W: 'a>( &'a self, node: GenericIndex, - ) -> impl Iterator)> + 'a { + ) -> impl Iterator)> + 'a { self.geometry_with_rtree.compounds(node) } } @@ -352,15 +352,15 @@ impl< SW: AccessSegWeight + Into + GetLayer, BW: AccessBendWeight + Into + GetLayer, CW: Clone, - Cek: Copy, + Cel: Copy, PI: GetPetgraphIndex + TryInto + TryInto + TryInto + Eq + Ord + Copy, DI: GetPetgraphIndex + Into + Eq + Ord + Copy, SI: GetPetgraphIndex + Into + Eq + Ord + Copy, BI: GetPetgraphIndex + Into + Eq + Ord + Copy, - > ApplyGeometryEdit - for RecordingGeometryWithRtree + > ApplyGeometryEdit + for RecordingGeometryWithRtree { - fn apply(&mut self, edit: &GeometryEdit) { + fn apply(&mut self, edit: &GeometryEdit) { for (compound, (maybe_old_data, ..)) in &edit.compounds { if maybe_old_data.is_some() { self.geometry_with_rtree.remove_compound(*compound); @@ -410,10 +410,10 @@ impl< self.geometry_with_rtree .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( GenericIndex::::new(member.petgraph_index()), - *entry_kind, + *entry_label, *compound, ); } diff --git a/src/geometry/with_rtree.rs b/src/geometry/with_rtree.rs index 4eed640..8240669 100644 --- a/src/geometry/with_rtree.rs +++ b/src/geometry/with_rtree.rs @@ -39,14 +39,14 @@ impl RTreeObject for Bbox { pub type BboxedIndex = GeomWithData; #[derive(Debug, Getters)] -pub struct GeometryWithRtree { - geometry: Geometry, +pub struct GeometryWithRtree { + geometry: Geometry, rtree: RTree>>>, layer_count: usize, } -impl Clone - for GeometryWithRtree +impl Clone + for GeometryWithRtree { fn clone(&self) -> Self { Self { @@ -57,10 +57,10 @@ impl Clone } } -impl - GeometryWithRtree +impl + GeometryWithRtree { - pub fn graph(&self) -> &StableDiGraph, GeometryLabel, usize> { + pub fn graph(&self) -> &StableDiGraph, GeometryLabel, usize> { self.geometry.graph() } } @@ -73,12 +73,12 @@ impl< SW: AccessSegWeight + Into + GetLayer, BW: AccessBendWeight + Into + GetLayer, CW: Clone, - Cek: Copy, + Cel: Copy, PI: GetPetgraphIndex + TryInto + TryInto + TryInto + PartialEq + Copy, DI: GetPetgraphIndex + Into + Copy, SI: GetPetgraphIndex + Into + Copy, BI: GetPetgraphIndex + Into + Copy, - > GeometryWithRtree + > GeometryWithRtree { pub fn new(layer_count: usize) -> Self { Self { @@ -181,12 +181,12 @@ impl< pub fn add_to_compound( &mut self, primitive: GenericIndex, - entry_kind: Cek, + entry_label: Cel, compound: GenericIndex, ) { self.rtree.remove(&self.make_compound_bbox(compound)); self.geometry - .add_to_compound(primitive, entry_kind, compound); + .add_to_compound(primitive, entry_label, compound); self.rtree.insert(self.make_compound_bbox(compound)); } @@ -293,12 +293,12 @@ impl< SW: AccessSegWeight + Into + GetLayer, BW: AccessBendWeight + Into + GetLayer, CW: Clone, - Cek: Copy, + Cel: Copy, PI: GetPetgraphIndex + TryInto + TryInto + TryInto + PartialEq + Copy, DI: GetPetgraphIndex + Into + Copy, SI: GetPetgraphIndex + Into + Copy, BI: GetPetgraphIndex + Into + Copy, - > GeometryWithRtree + > GeometryWithRtree { fn init_dot_bbox(&mut self, dot: DI) { self.rtree.insert(self.make_dot_bbox(dot)); @@ -363,7 +363,7 @@ impl< ) -> BboxedIndex>> { 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 for (_, member) in self.geometry.compound_members(compound) { aabb.merge(&self.make_bbox(member).geom().aabb); @@ -422,15 +422,15 @@ impl< SW: AccessSegWeight + Into + GetLayer, BW: AccessBendWeight + Into + GetLayer, CW: Clone, - Cek: Copy, + Cel: Copy, PI: GetPetgraphIndex + TryInto + TryInto + TryInto + PartialEq + Copy, DI: GetPetgraphIndex + Into + Copy, SI: GetPetgraphIndex + Into + Copy, BI: GetPetgraphIndex + Into + Copy, - > ManageCompounds for GeometryWithRtree + > ManageCompounds for GeometryWithRtree { type GeneralIndex = PI; - type EntryKind = Cek; + type EntryLabel = Cel; fn add_compound(&mut self, weight: CW) -> GenericIndex { let compound = self.geometry.add_compound(weight); @@ -443,11 +443,11 @@ impl< self.geometry.remove_compound(compound); } - fn add_to_compound(&mut self, primitive: I, kind: Cek, compound: GenericIndex) + fn add_to_compound(&mut self, primitive: I, label: Cel, compound: GenericIndex) where 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 { @@ -457,11 +457,11 @@ impl< fn compound_members( &self, compound: GenericIndex, - ) -> impl Iterator { + ) -> impl Iterator { self.geometry.compound_members(compound) } - fn compounds(&self, node: I) -> impl Iterator)> + fn compounds(&self, node: I) -> impl Iterator)> where I: Copy + GetPetgraphIndex, { diff --git a/src/layout/layout.rs b/src/layout/layout.rs index f47cbcf..fb1a0da 100644 --- a/src/layout/layout.rs +++ b/src/layout/layout.rs @@ -53,23 +53,23 @@ pub enum CompoundWeight { } #[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum CompoundEntryKind { +pub enum CompoundEntryLabel { Normal, NotInConvexHull, } /// The alias to differ node types pub type NodeIndex = GenericNode>; -pub type LayoutEdit = DrawingEdit; +pub type LayoutEdit = DrawingEdit; #[derive(Clone, Debug, Getters)] /// Structure for managing the Layout design pub struct Layout { - pub(super) drawing: Drawing, + pub(super) drawing: Drawing, } impl Layout { - pub fn new(drawing: Drawing) -> Self { + pub fn new(drawing: Drawing) -> Self { Self { drawing } } } @@ -126,7 +126,7 @@ impl Layout { self.drawing.add_to_compound( recorder, dot, - CompoundEntryKind::Normal, + CompoundEntryLabel::Normal, compound, ); dots.push(dot); @@ -286,7 +286,7 @@ impl Layout { pub fn poly_members( &self, poly: GenericIndex, - ) -> impl Iterator + '_ { + ) -> impl Iterator + '_ { self.drawing .geometry() .compound_members(GenericIndex::new(poly.petgraph_index())) @@ -442,7 +442,7 @@ impl SegWeight, BendWeight, CompoundWeight, - CompoundEntryKind, + CompoundEntryLabel, PrimitiveIndex, DotIndex, SegIndex, diff --git a/src/layout/poly.rs b/src/layout/poly.rs index 62c269e..01c62f0 100644 --- a/src/layout/poly.rs +++ b/src/layout/poly.rs @@ -22,7 +22,7 @@ use crate::{ }, geometry::{compound::ManageCompounds, GetLayer, GetSetPos}, graph::{GenericIndex, GetPetgraphIndex, MakeRef}, - layout::{CompoundEntryKind, CompoundWeight, Layout, LayoutEdit}, + layout::{CompoundEntryLabel, CompoundWeight, Layout, LayoutEdit}, math::Circle, }; @@ -34,7 +34,7 @@ pub trait MakePolygon { #[derive(Debug)] pub struct PolyRef<'a, R> { pub index: GenericIndex, - drawing: &'a Drawing, + drawing: &'a Drawing, } impl<'a, R: 'a> MakeRef<'a, Layout> for GenericIndex { @@ -81,7 +81,7 @@ pub(super) fn add_poly_with_nodes_intern( layout.drawing.add_to_compound( recorder, GenericIndex::<()>::new(idx.petgraph_index()), - CompoundEntryKind::Normal, + CompoundEntryLabel::Normal, poly_compound, ); @@ -123,17 +123,17 @@ pub(super) fn add_poly_with_nodes_intern( layout.drawing.add_to_compound( recorder, GenericIndex::<()>::new(idx.petgraph_index()), - CompoundEntryKind::NotInConvexHull, + CompoundEntryLabel::NotInConvexHull, poly_compound, ); } } - // maybe this should be a different edge kind + // maybe this should be a different edge label layout.drawing.add_to_compound( recorder, apex, - CompoundEntryKind::NotInConvexHull, + CompoundEntryLabel::NotInConvexHull, poly_compound, ); @@ -141,7 +141,10 @@ pub(super) fn add_poly_with_nodes_intern( apex } -fn is_apex(drawing: &Drawing, dot: FixedDotIndex) -> bool { +fn is_apex( + drawing: &Drawing, + dot: FixedDotIndex, +) -> bool { !drawing .primitive(dot) .segs() @@ -153,7 +156,7 @@ fn is_apex(drawing: &Drawing, dot: Fixe impl<'a, R> PolyRef<'a, R> { pub fn new( index: GenericIndex, - drawing: &'a Drawing, + drawing: &'a Drawing, ) -> Self { Self { index, drawing } } @@ -162,8 +165,8 @@ impl<'a, R> PolyRef<'a, R> { self.drawing .geometry() .compound_members(self.index.into()) - .find_map(|(kind, primitive_node)| { - if kind == CompoundEntryKind::NotInConvexHull { + .find_map(|(label, primitive_node)| { + if label == CompoundEntryLabel::NotInConvexHull { if let PrimitiveIndex::FixedDot(dot) = primitive_node { if is_apex(self.drawing, dot) { return Some(dot); @@ -200,7 +203,7 @@ impl MakePolygon for PolyRef<'_, R> { self.drawing .geometry() .compound_members(self.index.into()) - .filter_map(|(_kind, primitive_node)| { + .filter_map(|(_label, primitive_node)| { let PrimitiveIndex::FixedDot(dot) = primitive_node else { return None; }; diff --git a/src/layout/via.rs b/src/layout/via.rs index c7a1872..c590aab 100644 --- a/src/layout/via.rs +++ b/src/layout/via.rs @@ -15,20 +15,20 @@ use crate::{ }, geometry::primitive::{DotShape, PrimitiveShape}, graph::{GenericIndex, GetPetgraphIndex}, - layout::{CompoundEntryKind, CompoundWeight}, + layout::{CompoundEntryLabel, CompoundWeight}, math::Circle, }; #[derive(Debug)] pub struct Via<'a, R> { pub index: GenericIndex, - drawing: &'a Drawing, + drawing: &'a Drawing, } impl<'a, R> Via<'a, R> { pub fn new( index: GenericIndex, - drawing: &'a Drawing, + drawing: &'a Drawing, ) -> Self { Self { index, drawing } }