-
-
Notifications
You must be signed in to change notification settings - Fork 114
/
solid.rs
44 lines (37 loc) · 1.02 KB
/
solid.rs
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
use fj_math::Point;
use crate::{
objects::{Shell, Solid},
operations::{
build::shell::BuildShell, Insert, IsInsertedYes, TetrahedronShell,
UpdateSolid,
},
services::Services,
};
/// Build a [`Solid`]
pub trait BuildSolid {
/// Build an empty solid
fn empty() -> Solid {
Solid::new([])
}
/// Build a tetrahedron from the provided points
///
/// See [`BuildShell::tetrahedron`] for more information.
fn tetrahedron(
points: [impl Into<Point<3>>; 4],
services: &mut Services,
) -> Tetrahedron {
let shell = Shell::tetrahedron(points, services).insert(services);
let solid = Solid::empty().add_shell(shell.shell.clone());
Tetrahedron { solid, shell }
}
}
impl BuildSolid for Solid {}
/// A tetrahedron
///
/// Returned by [`BuildSolid::tetrahedron`].
pub struct Tetrahedron {
/// The solid that forms the tetrahedron
pub solid: Solid,
/// The shell of the tetrahedron
pub shell: TetrahedronShell<IsInsertedYes>,
}