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 std::collections::BTreeSet;
use fj_math::Scalar;
use crate::{
objects::{Objects, Shell, Solid},
storage::Handle,
};
pub struct SolidBuilder<'a> {
pub objects: &'a Objects,
pub shells: BTreeSet<Handle<Shell>>,
}
impl<'a> SolidBuilder<'a> {
pub fn with_shells(
mut self,
shells: impl IntoIterator<Item = Handle<Shell>>,
) -> Self {
self.shells.extend(shells);
self
}
pub fn with_cube_from_edge_length(
mut self,
edge_length: impl Into<Scalar>,
) -> Self {
let shell = Shell::builder(self.objects)
.with_cube_from_edge_length(edge_length)
.build();
self.shells.insert(shell);
self
}
pub fn build(self) -> Handle<Solid> {
self.objects.solids.insert(Solid::new(self.shells)).unwrap()
}
}