fj_kernel/objects/full/
shell.rs

1use crate::{
2    objects::{Face, FaceSet},
3    storage::Handle,
4};
5
6/// A 3-dimensional closed shell
7///
8/// # Implementation Note
9///
10/// The faces that make up a shell should be closed ("watertight"). This is not
11/// currently validated.
12#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
13pub struct Shell {
14    faces: FaceSet,
15}
16
17impl Shell {
18    /// Construct an empty instance of `Shell`
19    pub fn new(faces: impl IntoIterator<Item = Handle<Face>>) -> Self {
20        Self {
21            faces: faces.into_iter().collect(),
22        }
23    }
24
25    /// Access the faces of the shell
26    pub fn faces(&self) -> &FaceSet {
27        &self.faces
28    }
29
30    /// Find the given face in the shell
31    pub fn find_face(&self, face: &Handle<Face>) -> Option<Handle<Face>> {
32        self.faces().find(face)
33    }
34}