diff --git a/src/board/mod.rs b/src/board/mod.rs index e087ca6..a7bde6b 100644 --- a/src/board/mod.rs +++ b/src/board/mod.rs @@ -17,7 +17,7 @@ use crate::{ band::BandUid, bend::{BendIndex, BendWeight}, dot::{DotIndex, DotWeight, FixedDotIndex, FixedDotWeight, GeneralDotWeight}, - graph::{GetMaybeNet, PrimitiveIndex, PrimitiveWeight}, + graph::{GetMaybeNet, PrimitiveIndex}, seg::{FixedSegIndex, FixedSegWeight, SegIndex, SegWeight}, Collect, }, @@ -288,7 +288,6 @@ impl Board { impl ApplyGeometryEdit< - PrimitiveWeight, DotWeight, SegWeight, BendWeight, diff --git a/src/drawing/drawing.rs b/src/drawing/drawing.rs index 0b2896d..e814b20 100644 --- a/src/drawing/drawing.rs +++ b/src/drawing/drawing.rs @@ -91,7 +91,6 @@ pub struct Collision(pub PrimitiveShape, pub PrimitiveIndex); pub struct AlreadyConnected(pub usize, pub PrimitiveIndex); pub type DrawingEdit = GeometryEdit< - PrimitiveWeight, DotWeight, SegWeight, BendWeight, @@ -1120,7 +1119,6 @@ impl Drawing { impl ApplyGeometryEdit< - PrimitiveWeight, DotWeight, SegWeight, BendWeight, diff --git a/src/geometry/edit.rs b/src/geometry/edit.rs index 1b98c87..427d08c 100644 --- a/src/geometry/edit.rs +++ b/src/geometry/edit.rs @@ -2,17 +2,16 @@ // // SPDX-License-Identifier: MIT -use std::{collections::BTreeMap, marker::PhantomData}; +use std::collections::BTreeMap; use crate::graph::{GenericIndex, GetPetgraphIndex}; -use super::{AccessBendWeight, AccessDotWeight, AccessSegWeight, GetLayer, GetWidth, Retag}; +use super::{AccessBendWeight, AccessDotWeight, AccessSegWeight, GetLayer}; pub trait ApplyGeometryEdit< - PW: GetWidth + GetLayer + TryInto + TryInto + TryInto + Retag + Copy, - DW: AccessDotWeight + Into + GetLayer, - SW: AccessSegWeight + Into + GetLayer, - BW: AccessBendWeight + Into + GetLayer, + DW: AccessDotWeight + GetLayer, + SW: AccessSegWeight + GetLayer, + BW: AccessBendWeight + GetLayer, CW: Copy, PI: GetPetgraphIndex + TryInto + TryInto + TryInto + Eq + Ord + Copy, DI: GetPetgraphIndex + Into + Eq + Ord + Copy, @@ -20,17 +19,16 @@ pub trait ApplyGeometryEdit< 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, CW)>, Option<(Vec, CW)>)>, - primitive_weight_marker: PhantomData, } fn swap_tuple_inplace(x: &mut (D, D)) { @@ -38,16 +36,15 @@ fn swap_tuple_inplace(x: &mut (D, D)) { } impl< - PW: GetWidth + GetLayer + TryInto + TryInto + TryInto + Retag + Copy, - DW: AccessDotWeight + Into + GetLayer, - SW: AccessSegWeight + Into + GetLayer, - BW: AccessBendWeight + Into + GetLayer, + DW: AccessDotWeight + GetLayer, + SW: AccessSegWeight + GetLayer, + BW: AccessBendWeight + GetLayer, CW: 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 { @@ -55,7 +52,6 @@ impl< segs: BTreeMap::new(), bends: BTreeMap::new(), compounds: BTreeMap::new(), - primitive_weight_marker: PhantomData, } } @@ -91,19 +87,18 @@ fn apply_btmap( } impl< - PW: GetWidth + GetLayer + TryInto + TryInto + TryInto + Retag + Copy, - DW: AccessDotWeight + Into + GetLayer, - SW: AccessSegWeight + Into + GetLayer, - BW: AccessBendWeight + Into + GetLayer, + DW: AccessDotWeight + GetLayer, + SW: AccessSegWeight + GetLayer, + BW: AccessBendWeight + GetLayer, CW: 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/recording_with_rtree.rs b/src/geometry/recording_with_rtree.rs index 4e74220..99700fd 100644 --- a/src/geometry/recording_with_rtree.rs +++ b/src/geometry/recording_with_rtree.rs @@ -55,7 +55,7 @@ impl< pub fn add_dot + GetLayer>( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, weight: W, ) -> GenericIndex where @@ -76,7 +76,7 @@ impl< pub fn add_seg + GetLayer>( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, from: DI, to: DI, weight: W, @@ -102,7 +102,7 @@ impl< pub fn add_bend + GetLayer>( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, from: DI, to: DI, core: DI, @@ -129,7 +129,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); @@ -141,7 +141,7 @@ impl< pub fn add_to_compound( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, primitive: GenericIndex, compound: GenericIndex, ) { @@ -165,7 +165,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); @@ -176,7 +176,7 @@ impl< pub fn remove_seg( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, seg: SI, ) { let geometry = self.geometry_with_rtree.geometry(); @@ -188,7 +188,7 @@ impl< pub fn remove_bend( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, bend: BI, ) { let geometry = self.geometry_with_rtree.geometry(); @@ -205,7 +205,7 @@ impl< pub fn remove_compound( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, compound: GenericIndex, ) { let geometry = self.geometry_with_rtree.geometry(); @@ -217,7 +217,7 @@ impl< pub fn move_dot( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, dot: DI, to: Point, ) { @@ -234,7 +234,7 @@ impl< fn modify_bend( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, bend: BI, f: F, ) where @@ -264,7 +264,7 @@ impl< pub fn shift_bend( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, bend: BI, offset: f64, ) { @@ -275,7 +275,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| { @@ -285,7 +285,7 @@ impl< pub fn reattach_bend( &mut self, - recorder: &mut GeometryEdit, + recorder: &mut GeometryEdit, bend: BI, maybe_new_inner: Option, ) { @@ -352,10 +352,10 @@ impl< DI: GetPetgraphIndex + Into + Eq + Ord + Copy, SI: GetPetgraphIndex + Into + Eq + Ord + Copy, BI: GetPetgraphIndex + Into + Eq + Ord + Copy, - > ApplyGeometryEdit + > 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); diff --git a/src/layout/layout.rs b/src/layout/layout.rs index 346a427..4620bb1 100644 --- a/src/layout/layout.rs +++ b/src/layout/layout.rs @@ -17,7 +17,7 @@ use crate::{ LooseDotWeight, }, gear::GearIndex, - graph::{GetMaybeNet, IsInLayer, MakePrimitive, PrimitiveIndex, PrimitiveWeight}, + graph::{GetMaybeNet, IsInLayer, MakePrimitive, PrimitiveIndex}, loose::LooseIndex, primitive::{GetWeight, MakePrimitiveShape, Primitive}, rules::AccessRules, @@ -476,7 +476,6 @@ impl Layout { impl ApplyGeometryEdit< - PrimitiveWeight, DotWeight, SegWeight, BendWeight,