mirror of https://codeberg.org/topola/topola.git
layout: Add invariant testing R-tree envelope invariance
This commit is contained in:
parent
efea917cb1
commit
f36f80537f
|
|
@ -24,6 +24,7 @@ pub struct Layout {
|
|||
}
|
||||
|
||||
#[debug_invariant(self.graph.node_count() == self.rtree.size())]
|
||||
#[debug_invariant(self.test_envelopes())]
|
||||
impl Layout {
|
||||
pub fn new() -> Self {
|
||||
Layout {
|
||||
|
|
@ -224,6 +225,7 @@ impl Layout {
|
|||
}
|
||||
}
|
||||
|
||||
#[debug_invariant(self.test_envelopes())]
|
||||
impl Layout {
|
||||
#[debug_ensures(self.graph.node_count() == old(self.graph.node_count()))]
|
||||
#[debug_ensures(self.graph.edge_count() == old(self.graph.edge_count()))]
|
||||
|
|
@ -310,3 +312,14 @@ impl Layout {
|
|||
.is_some());
|
||||
}
|
||||
}
|
||||
|
||||
impl Layout {
|
||||
fn test_envelopes(&self) -> bool {
|
||||
!self.rtree.iter().any(|wrapper| {
|
||||
!self
|
||||
.rtree
|
||||
.locate_in_envelope(&wrapper.geom().envelope())
|
||||
.any(|w| w == wrapper)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue