diff --git a/src/geometry/edit.rs b/src/geometry/edit.rs index 8ec85f8..775f590 100644 --- a/src/geometry/edit.rs +++ b/src/geometry/edit.rs @@ -7,6 +7,21 @@ use crate::{ use super::{AccessBendWeight, AccessDotWeight, AccessSegWeight, GetWidth}; +pub trait ApplyGeometryEdit< + PW: GetWidth + GetLayer + TryInto + TryInto + TryInto + Retag + Copy, + DW: AccessDotWeight + GetLayer, + SW: AccessSegWeight + GetLayer, + BW: AccessBendWeight + GetLayer, + CW: Copy, + PI: GetPetgraphIndex + TryInto + TryInto + TryInto + Eq + Hash + Copy, + DI: GetPetgraphIndex + Into + Eq + Hash + Copy, + SI: GetPetgraphIndex + Into + Eq + Hash + Copy, + BI: GetPetgraphIndex + Into + Eq + Hash + Copy, +> +{ + fn apply(&mut self, edit: GeometryEdit); +} + #[derive(Debug)] pub struct GeometryEdit< PW: GetWidth + GetLayer + TryInto + TryInto + TryInto + Retag + Copy, diff --git a/src/geometry/recording_with_rtree.rs b/src/geometry/recording_with_rtree.rs index f930d93..50ed65c 100644 --- a/src/geometry/recording_with_rtree.rs +++ b/src/geometry/recording_with_rtree.rs @@ -11,7 +11,7 @@ use crate::{ use super::{ compound::ManageCompounds, - edit::GeometryEdit, + edit::{ApplyGeometryEdit, GeometryEdit}, with_rtree::{BboxedIndex, GeometryWithRtree}, AccessBendWeight, AccessDotWeight, AccessSegWeight, GenericNode, Geometry, GeometryLabel, GetWidth, @@ -333,7 +333,48 @@ impl< } } - pub fn apply_edit(&mut self, edit: GeometryEdit) { + pub fn compound_weight(&self, compound: GenericIndex) -> CW { + self.geometry_with_rtree.compound_weight(compound) + } + + pub fn compounds<'a, W: 'a>( + &'a self, + node: GenericIndex, + ) -> impl Iterator> + 'a { + self.geometry_with_rtree.compounds(node) + } + + pub fn geometry(&self) -> &Geometry { + self.geometry_with_rtree.geometry() + } + + pub fn rtree(&self) -> &RTree>>> { + self.geometry_with_rtree.rtree() + } + + pub fn layer_count(&self) -> usize { + *self.geometry_with_rtree.layer_count() + } + + pub fn graph(&self) -> &StableDiGraph, GeometryLabel, usize> { + self.geometry_with_rtree.graph() + } +} + +impl< + PW: GetWidth + GetLayer + TryInto + TryInto + TryInto + Retag + Copy, + DW: AccessDotWeight + GetLayer, + SW: AccessSegWeight + GetLayer, + BW: AccessBendWeight + GetLayer, + CW: Copy, + PI: GetPetgraphIndex + TryInto + TryInto + TryInto + Eq + Hash + Copy, + DI: GetPetgraphIndex + Into + Eq + Hash + Copy, + SI: GetPetgraphIndex + Into + Eq + Hash + Copy, + BI: GetPetgraphIndex + Into + Eq + Hash + Copy, + > ApplyGeometryEdit + for RecordingGeometryWithRtree +{ + fn apply(&mut self, edit: GeometryEdit) { for (compound, ..) in &edit.compounds { self.geometry_with_rtree.remove_compound(*compound); } @@ -384,31 +425,4 @@ impl< } } } - - pub fn compound_weight(&self, compound: GenericIndex) -> CW { - self.geometry_with_rtree.compound_weight(compound) - } - - pub fn compounds<'a, W: 'a>( - &'a self, - node: GenericIndex, - ) -> impl Iterator> + 'a { - self.geometry_with_rtree.compounds(node) - } - - pub fn geometry(&self) -> &Geometry { - self.geometry_with_rtree.geometry() - } - - pub fn rtree(&self) -> &RTree>>> { - self.geometry_with_rtree.rtree() - } - - pub fn layer_count(&self) -> usize { - *self.geometry_with_rtree.layer_count() - } - - pub fn graph(&self) -> &StableDiGraph, GeometryLabel, usize> { - self.geometry_with_rtree.graph() - } }