Skip to content

Commit 58ced3d

Browse files
committed
geometry: rename Aabb and Mbr
to BoundingBox and OrientedBoundingBox also make the BoundingBox fields public for simplicity.
1 parent fb2cf47 commit 58ced3d

File tree

7 files changed

+105
-95
lines changed

7 files changed

+105
-95
lines changed

src/algorithms/hilbert_curve.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
//!
1111
//! The complexity of encoding a point is O(order)
1212
13-
use crate::geometry::{Mbr, Point2D};
13+
use crate::geometry::OrientedBoundingBox;
14+
use crate::Point2D;
1415
use rayon::prelude::*;
1516
use std::fmt;
1617

@@ -97,14 +98,12 @@ fn segment_to_segment(min: f64, max: f64, order: usize) -> impl Fn(f64) -> u64 {
9798
}
9899

99100
fn hilbert_index_computer(points: &[Point2D], order: usize) -> impl Fn(&Point2D) -> u64 {
100-
let mbr = Mbr::from_points(points);
101+
let mbr = OrientedBoundingBox::from_points(points);
101102
let aabb = mbr.aabb();
102-
let p_min = aabb.p_min();
103-
let p_max = aabb.p_max();
104-
let x_mapping = segment_to_segment(p_min.x, p_max.x, order);
105-
let y_mapping = segment_to_segment(p_min.y, p_max.y, order);
103+
let x_mapping = segment_to_segment(aabb.p_min.x, aabb.p_max.x, order);
104+
let y_mapping = segment_to_segment(aabb.p_min.y, aabb.p_max.y, order);
106105
move |p| {
107-
let p = mbr.mbr_to_aabb(p);
106+
let p = mbr.obb_to_aabb(p);
108107
encode(x_mapping(p.x), y_mapping(p.y), order)
109108
}
110109
}

src/algorithms/k_means.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
//! "Balanced k-means for Parallel Geometric Partitioning" by Moritz von Looz,
33
//! Charilaos Tzovas and Henning Meyerhenke (2018, University of Cologne)
44
5-
use crate::geometry::Mbr;
6-
use crate::geometry::{self, PointND};
5+
use crate::geometry;
6+
use crate::geometry::OrientedBoundingBox;
7+
use crate::PointND;
78
use nalgebra::allocator::Allocator;
89
use nalgebra::ArrayStorage;
910
use nalgebra::Const;
@@ -315,7 +316,7 @@ fn assign_and_balance<const D: usize>(
315316
} = clusters;
316317
// compute the distances from each cluster center to the minimal
317318
// bounding rectangle of the set of points
318-
let mbr = Mbr::from_points(points);
319+
let mbr = OrientedBoundingBox::from_points(points);
319320
let distances_to_mbr = centers
320321
.par_iter()
321322
.zip(influences.par_iter())

src/algorithms/recursive_bisection.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::Error;
2-
use crate::geometry::Mbr;
2+
use crate::geometry::OrientedBoundingBox;
33
use crate::geometry::PointND;
44
use async_lock::Mutex;
55
use async_lock::MutexGuard;
@@ -892,8 +892,8 @@ where
892892
W::Item: RcbWeight,
893893
W::Iter: rayon::iter::IndexedParallelIterator,
894894
{
895-
let mbr = Mbr::from_points(points);
896-
let points = points.par_iter().map(|p| mbr.mbr_to_aabb(p));
895+
let mbr = OrientedBoundingBox::from_points(points);
896+
let points = points.par_iter().map(|p| mbr.obb_to_aabb(p));
897897
// When the rotation is done, we just apply RCB
898898
simple_rcb(partition, points, weights, n_iter, tolerance)
899899
}

src/algorithms/z_curve.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
//! Finally, the points are reordered according to the order of their hash.
1818
1919
use super::multi_jagged::split_at_mut_many;
20-
use crate::geometry::{Mbr, PointND};
20+
use crate::geometry::OrientedBoundingBox;
21+
use crate::PointND;
2122

2223
use nalgebra::allocator::Allocator;
2324
use nalgebra::ArrayStorage;
@@ -54,8 +55,8 @@ fn z_curve_partition<const D: usize>(
5455
max_order,
5556
);
5657

57-
// Mbr used to construct Point hashes
58-
let mbr = Mbr::from_points(points);
58+
// Bounding box used to construct Point hashes
59+
let mbr = OrientedBoundingBox::from_points(points);
5960

6061
let mut permutation: Vec<_> = (0..points.len()).into_par_iter().collect();
6162

@@ -90,7 +91,7 @@ fn z_curve_partition<const D: usize>(
9091
fn z_curve_partition_recurse<const D: usize>(
9192
points: &[PointND<D>],
9293
order: u32,
93-
mbr: &Mbr<D>,
94+
mbr: &OrientedBoundingBox<D>,
9495
permu: &mut [usize],
9596
) {
9697
// we stop recursion if there is only 1 point left to avoid useless calls
@@ -164,7 +165,7 @@ pub(crate) fn z_curve_reorder_permu<const D: usize>(
164165
DefaultAllocator: Allocator<f64, Const<D>, Const<D>, Buffer = ArrayStorage<f64, D, D>>
165166
+ Allocator<f64, DimDiff<Const<D>, Const<1>>>,
166167
{
167-
let mbr = Mbr::from_points(points);
168+
let mbr = OrientedBoundingBox::from_points(points);
168169
let hashes = permu
169170
.par_iter()
170171
.map(|idx| compute_hash(&points[*idx], order, &mbr))
@@ -173,7 +174,11 @@ pub(crate) fn z_curve_reorder_permu<const D: usize>(
173174
permu.par_sort_by_key(|idx| hashes[*idx]);
174175
}
175176

176-
fn compute_hash<const D: usize>(point: &PointND<D>, order: u32, mbr: &Mbr<D>) -> HashType {
177+
fn compute_hash<const D: usize>(
178+
point: &PointND<D>,
179+
order: u32,
180+
mbr: &OrientedBoundingBox<D>,
181+
) -> HashType {
177182
let current_hash = mbr
178183
.region(point)
179184
.expect("Cannot compute the z-hash of a point outside of the current Mbr.");

0 commit comments

Comments
 (0)