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
use fj_math::Point;

use crate::{
    objects::{Face, Sketch, Surface},
    stores::Stores,
};

/// API for building a [`Sketch`]
///
/// Also see [`Sketch::builder`].
pub struct SketchBuilder<'a> {
    /// The stores that the created objects are put in
    pub stores: &'a Stores,

    /// The surface that the [`Sketch`] is defined in
    pub surface: Surface,
}

impl<'a> SketchBuilder<'a> {
    /// Construct a polygon from a list of points
    pub fn build_polygon_from_points(
        self,
        points: impl IntoIterator<Item = impl Into<Point<2>>>,
    ) -> Sketch {
        let face = Face::builder(self.stores, self.surface)
            .with_exterior_polygon_from_points(points)
            .build();
        Sketch::new().with_faces([face])
    }
}