From 6fa6ec752745dc44239ec46640993eee12e41139 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Thu, 15 Feb 2024 02:34:25 +0000 Subject: [PATCH] layout: use epsilons instead of infringable lists to evade abutters --- src/layout/layout.rs | 21 ++++++++------------- src/main.rs | 4 ++-- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/layout/layout.rs b/src/layout/layout.rs index 431dcb8..af08600 100644 --- a/src/layout/layout.rs +++ b/src/layout/layout.rs @@ -281,7 +281,7 @@ impl Layout { } if let Some(outer) = self.primitive(segbend.bend).outer() { - self.update_this_and_outward_bows(outer); + self.update_this_and_outward_bows(outer)?; } // Segs must not cross. @@ -309,6 +309,7 @@ impl Layout { &mut self, around: LooseBendIndex, ) -> Result<(), LayoutException> { + // FIXME: Fail gracefully on infringement. let mut maybe_rail = Some(around); while let Some(rail) = maybe_rail { @@ -516,14 +517,7 @@ impl Layout { to: LooseDotIndex, weight: SeqLooseSegWeight, ) -> Result { - let seg = self.add_seg_infringably( - from, - to.into(), - weight, - &self - .collect() - .bend_abutters(self.primitive(to).bend().into()), - )?; + let seg = self.add_seg_infringably(from, to.into(), weight, &[])?; if let DotIndex::Fixed(dot) = from { self.connectivity.update_edge( @@ -821,10 +815,11 @@ impl Layout { .filter(|wrapper| { let infringee_conditions = wrapper.data.primitive(self).conditions(); - inflated_shape = node - .primitive(self) - .shape() - .inflate(self.rules.clearance(&conditions, &infringee_conditions)); + let epsilon = 1.0; + inflated_shape = node.primitive(self).shape().inflate( + (self.rules.clearance(&conditions, &infringee_conditions) - epsilon) + .clamp(0.0, f64::INFINITY), + ); inflated_shape.intersects(wrapper.geom()) }) diff --git a/src/main.rs b/src/main.rs index 2f59ac3..591e599 100644 --- a/src/main.rs +++ b/src/main.rs @@ -526,8 +526,8 @@ fn main() -> Result<(), anyhow::Error> { dot_start, dot_end, 3.0, - //&mut EmptyRouterObserver, - &mut DebugRouterObserver::new(&mut event_pump, &window, &mut renderer, &font_context), + &mut EmptyRouterObserver, + //&mut DebugRouterObserver::new(&mut event_pump, &window, &mut renderer, &font_context), )?; render_times(