MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/splashsurf / par_from_points

Method par_from_points

splashsurf_lib/src/aabb.rs:28–52  ·  view source on GitHub ↗

Constructs the smallest AABB fitting around all the given points, parallel version

(points: &[SVector<R, D>])

Source from the content-addressed store, hash-verified

26{
27 /// Constructs the smallest AABB fitting around all the given points, parallel version
28 pub fn par_from_points(points: &[SVector<R, D>]) -> Self {
29 if points.is_empty() {
30 Self::zeros()
31 } else if points.len() == 1 {
32 Self::from_point(points[0])
33 } else {
34 let initial_aabb = Self::from_point(points[0]);
35 points[1..]
36 .par_iter()
37 .fold(
38 || initial_aabb.clone(),
39 |mut aabb, next_point| {
40 aabb.join_with_point(next_point);
41 aabb
42 },
43 )
44 .reduce(
45 || initial_aabb.clone(),
46 |mut final_aabb, aabb| {
47 final_aabb.join(&aabb);
48 final_aabb
49 },
50 )
51 }
52 }
53}
54
55impl<R, const D: usize> AxisAlignedBoundingBox<R, D>

Callers

nothing calls this directly

Calls 5

is_emptyMethod · 0.80
cloneMethod · 0.80
join_with_pointMethod · 0.80
joinMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected