fj_core/operations/build/
solid.rs

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