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).
This commit is contained in:
Mikolaj Wielgus 2023-09-19 20:44:05 +02:00
parent 12e37e0e91
commit abf92c7f43
2 changed files with 6 additions and 3 deletions

View File

@ -316,10 +316,13 @@ impl Layout {
impl Layout { impl Layout {
fn test_envelopes(&self) -> bool { fn test_envelopes(&self) -> bool {
!self.rtree.iter().any(|wrapper| { !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 !self
.rtree .rtree
.locate_in_envelope(&wrapper.geom().envelope()) .locate_in_envelope(&shape.envelope())
.any(|w| w == wrapper) .any(|w| *w == wrapper)
}) })
} }
} }

View File

@ -69,7 +69,7 @@ impl BendShape {
} }
} }
#[derive(Debug, EnumAsInner, PartialEq)] #[derive(Debug, Clone, Copy, EnumAsInner, PartialEq)]
pub enum Shape { pub enum Shape {
// Intentionally in different order to reorder `self.intersects(...)` properly. // Intentionally in different order to reorder `self.intersects(...)` properly.
Dot(DotShape), Dot(DotShape),