1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use crate::math::{Isometry, Point};
use crate::partitioning::{VisitStatus, Visitor};
use crate::query::PointQuery;
use na::RealField;
pub struct PointInterferencesCollector<'a, N: 'a + RealField, T: 'a> {
pub point: &'a Point<N>,
pub collector: &'a mut Vec<T>,
}
impl<'a, N: RealField, T> PointInterferencesCollector<'a, N, T> {
#[inline]
pub fn new(
point: &'a Point<N>,
buffer: &'a mut Vec<T>,
) -> PointInterferencesCollector<'a, N, T> {
PointInterferencesCollector {
point: point,
collector: buffer,
}
}
}
impl<'a, N, T, BV> Visitor<T, BV> for PointInterferencesCollector<'a, N, T>
where
N: RealField,
T: Clone,
BV: PointQuery<N>,
{
#[inline]
fn visit(&mut self, bv: &BV, t: Option<&T>) -> VisitStatus {
if bv.contains_point(&Isometry::identity(), self.point) {
if let Some(t) = t {
self.collector.push(t.clone());
}
VisitStatus::Continue
} else {
VisitStatus::Stop
}
}
}