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
use fj_math::Point;
use crate::{
insert::Insert,
objects::{Face, FaceSet, Objects, Sketch, Surface},
partial::HasPartial,
services::Service,
storage::Handle,
};
use super::FaceBuilder;
pub struct SketchBuilder {
pub faces: FaceSet,
}
impl SketchBuilder {
pub fn with_faces(
mut self,
faces: impl IntoIterator<Item = Handle<Face>>,
) -> Self {
self.faces.extend(faces);
self
}
pub fn with_polygon_from_points(
mut self,
surface: Handle<Surface>,
points: impl IntoIterator<Item = impl Into<Point<2>>>,
objects: &mut Service<Objects>,
) -> Self {
self.faces.extend([Face::partial()
.with_exterior_polygon_from_points(surface, points)
.build(objects)
.insert(objects)]);
self
}
pub fn build(self, objects: &mut Service<Objects>) -> Handle<Sketch> {
Sketch::new(self.faces).insert(objects)
}
}