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
use crate::vector3::Vector3D;
use crate::field3::Field3;
use crate::vector_field3::VectorField3;
use std::sync::{RwLock, Arc};
pub struct ConstantVectorField3 {
_value: Vector3D,
}
impl ConstantVectorField3 {
pub fn new(value: Option<Vector3D>) -> ConstantVectorField3 {
return ConstantVectorField3 {
_value: value.unwrap_or(Vector3D::new_default())
};
}
pub fn builder() -> Builder {
return Builder::new();
}
}
impl Field3 for ConstantVectorField3 {}
impl VectorField3 for ConstantVectorField3 {
fn sample(&self, _: &Vector3D) -> Vector3D {
return self._value;
}
}
pub type ConstantVectorField3Ptr = Arc<RwLock<ConstantVectorField3>>;
pub struct Builder {
_value: Vector3D,
}
impl Builder {
pub fn with_value(&mut self, value: Vector3D) -> &mut Self {
self._value = value;
return self;
}
pub fn build(&mut self) -> ConstantVectorField3 {
return ConstantVectorField3::new(Some(self._value));
}
pub fn make_shared(&mut self) -> ConstantVectorField3Ptr {
return ConstantVectorField3Ptr::new(RwLock::new(self.build()));
}
pub fn new() -> Builder {
return Builder {
_value: Vector3D::new_default()
};
}
}