From abf92c7f43d115fb2750cbbca512be781d4b5767 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Tue, 19 Sep 2023 20:44:05 +0200 Subject: [PATCH] contracts: Fix R-tree envelope invariance test Violations were not detected if shape changed but not the envelope (which is the case when bends are flipped). --- src/layout.rs | 7 +++++-- src/shape.rs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/layout.rs b/src/layout.rs index e12c67c..97a10ba 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -316,10 +316,13 @@ impl Layout { impl Layout { fn test_envelopes(&self) -> bool { !self.rtree.iter().any(|wrapper| { + let index = wrapper.data; + let shape = untag!(index, Primitive::new(index, &self.graph).shape()); + let wrapper = RTreeWrapper::new(shape, index); !self .rtree - .locate_in_envelope(&wrapper.geom().envelope()) - .any(|w| w == wrapper) + .locate_in_envelope(&shape.envelope()) + .any(|w| *w == wrapper) }) } } diff --git a/src/shape.rs b/src/shape.rs index 8a97d9e..2982cdf 100644 --- a/src/shape.rs +++ b/src/shape.rs @@ -69,7 +69,7 @@ impl BendShape { } } -#[derive(Debug, EnumAsInner, PartialEq)] +#[derive(Debug, Clone, Copy, EnumAsInner, PartialEq)] pub enum Shape { // Intentionally in different order to reorder `self.intersects(...)` properly. Dot(DotShape),