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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
use crate::vector3::Vector3D;
use crate::point_neighbor_searcher3::*;
use std::sync::{RwLock, Arc};
pub struct PointSimpleListSearcher3 {
_points: Vec<Vector3D>,
}
impl PointSimpleListSearcher3 {
pub fn new() -> PointSimpleListSearcher3 {
return PointSimpleListSearcher3 {
_points: vec![]
};
}
pub fn builder() -> Builder {
return Builder::new();
}
pub fn clone(&self) -> PointSimpleListSearcher3Ptr {
let mut searcher = PointSimpleListSearcher3::new();
searcher.set(self);
return PointSimpleListSearcher3Ptr::new(RwLock::new(searcher));
}
pub fn set(&mut self, other: &PointSimpleListSearcher3) {
self._points = other._points.clone();
}
}
impl PointNeighborSearcher3 for PointSimpleListSearcher3 {
fn type_name() -> String {
return "PointSimpleListSearcher3".parse().unwrap();
}
fn build(&mut self, points: &Vec<Vector3D>) {
self._points = points.clone();
}
fn for_each_nearby_point<Callback>(&self, origin: &Vector3D, radius: f64, callback: &mut Callback)
where Callback: ForEachNearbyPointFunc {
let radius_squared = radius * radius;
for i in 0..self._points.len() {
let r = self._points[i] - *origin;
let distance_squared = r.dot(&r);
if distance_squared <= radius_squared {
callback(i, &self._points[i]);
}
}
}
fn has_nearby_point(&self, origin: &Vector3D, radius: f64) -> bool {
let radius_squared = radius * radius;
for i in 0..self._points.len() {
let r = self._points[i] - *origin;
let distance_squared = r.dot(&r);
if distance_squared <= radius_squared {
return true;
}
}
return false;
}
}
pub type PointSimpleListSearcher3Ptr = Arc<RwLock<PointSimpleListSearcher3>>;
pub struct Builder {}
impl Builder {
pub fn build(&self) -> PointSimpleListSearcher3 {
return PointSimpleListSearcher3::new();
}
pub fn make_shared(&self) -> PointSimpleListSearcher3Ptr {
return PointSimpleListSearcher3Ptr::new(RwLock::new(self.build()));
}
pub fn new() -> Builder {
return Builder {};
}
}