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
use std::collections::BTreeSet;

use super::Face;

/// A 2-dimensional shape
///
/// # Implementation Note
///
/// The faces that make up the sketch must be in the same surface. This is not
/// currently validated.
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct Sketch {
    faces: BTreeSet<Face>,
}

impl Sketch {
    /// Construct a sketch from faces
    pub fn from_faces(faces: impl IntoIterator<Item = Face>) -> Self {
        let faces = faces.into_iter().collect();
        Self { faces }
    }

    /// Access the sketch's faces
    pub fn faces(&self) -> impl Iterator<Item = &Face> {
        self.faces.iter()
    }

    /// Convert the sketch into a list of faces
    pub fn into_faces(self) -> BTreeSet<Face> {
        self.faces
    }
}