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
48
49
50
51
52
53
54
55
//! Adaptive tree cell scheme.

use crate::geom::{Cube, SmoothTriangle};

/// Tree cell enumeration.
pub enum Tree<'a, T> {
    /// Root cell.
    Root {
        /// Boundary.
        boundary: Cube,
        /// Children.
        children: [Box<Tree<'a, T>>; 8],
    },
    /// Branching cell.
    Branch {
        /// Boundary.
        boundary: Cube,
        /// Children.
        children: [Box<Tree<'a, T>>; 8],
    },
    /// Terminal populated cell.
    Leaf {
        /// Boundary.
        boundary: Cube,
        /// Intersecting triangles.
        tris: Vec<(T, &'a SmoothTriangle)>,
    },
    /// Terminal empty cell.
    Empty {
        /// Boundary.
        boundary: Cube,
    },
}

impl<'a, T> Tree<'a, T> {
    /// Reference the cell's boundary.
    #[allow(clippy::missing_const_for_fn)]
    #[inline]
    #[must_use]
    pub fn boundary(&self) -> &Cube {
        match *self {
            Self::Root { ref boundary, .. }
            | Self::Branch { ref boundary, .. }
            | Self::Leaf { ref boundary, .. }
            | Self::Empty { ref boundary, .. } => boundary,
        }
    }
}

pub mod info;
pub mod observe;
pub mod scan;
pub mod search;

pub use self::{info::*, observe::*, scan::*, search::*};