fj_kernel/operations/build/
solid.rs

1use fj_math::Point;
2
3use crate::{
4    objects::{Shell, Solid},
5    operations::{
6        build::shell::BuildShell, Insert, IsInsertedYes, TetrahedronShell,
7        UpdateSolid,
8    },
9    services::Services,
10};
11
12/// Build a [`Solid`]
13pub trait BuildSolid {
14    /// Build an empty solid
15    fn empty() -> Solid {
16        Solid::new([])
17    }
18
19    /// Build a tetrahedron from the provided points
20    ///
21    /// See [`BuildShell::tetrahedron`] for more information.
22    fn tetrahedron(
23        points: [impl Into<Point<3>>; 4],
24        services: &mut Services,
25    ) -> Tetrahedron {
26        let shell = Shell::tetrahedron(points, services).insert(services);
27        let solid = Solid::empty().add_shell(shell.shell.clone());
28
29        Tetrahedron { solid, shell }
30    }
31}
32
33impl BuildSolid for Solid {}
34
35/// A tetrahedron
36///
37/// Returned by [`BuildSolid::tetrahedron`].
38pub struct Tetrahedron {
39    /// The solid that forms the tetrahedron
40    pub solid: Solid,
41
42    /// The shell of the tetrahedron
43    pub shell: TetrahedronShell<IsInsertedYes>,
44}