From 79f859f8cb816420733a5489aeb25fb6d0fd069f Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Mon, 18 May 2026 21:09:47 +0200 Subject: [PATCH] Add (not yet used) private interface to modify joints without segment, via updates --- topola/src/layout.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/topola/src/layout.rs b/topola/src/layout.rs index 3afaec2..95b221c 100644 --- a/topola/src/layout.rs +++ b/topola/src/layout.rs @@ -147,15 +147,8 @@ impl Layout { where F: FnOnce(&mut JointSpec), { - let old_joint = self.joints.get(&id.index()).unwrap(); - self.joints_rtree - .remove(&GeomWithData::new(old_joint.bbox(), id)); - - self.joints.modify(id.index(), |joint| f(&mut joint.spec)); - + self.modify_joint_raw(id, |joint| f(&mut joint.spec)); let new_joint = self.joints.get(&id.index()).unwrap().clone(); - self.joints_rtree - .insert(GeomWithData::new(new_joint.bbox(), id), ()); for &segment in &new_joint.segments { self.update_segment(segment); @@ -166,6 +159,21 @@ impl Layout { } } + fn modify_joint_raw(&mut self, id: JointId, f: F) + where + F: FnOnce(&mut Joint), + { + let old_joint = self.joints.get(&id.index()).unwrap(); + self.joints_rtree + .remove(&GeomWithData::new(old_joint.bbox(), id)); + + self.joints.modify(id.index(), |joint| f(joint)); + + let new_joint = self.joints.get(&id.index()).unwrap().clone(); + self.joints_rtree + .insert(GeomWithData::new(new_joint.bbox(), id), ()); + } + pub fn add_segment(&mut self, spec: SegmentSpec) -> SegmentId { self.add_segment_raw(Segment { spec,