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::{
objects::Cycle,
partial::{HasPartial, PartialFace},
};
use super::CycleBuilder;
pub trait FaceBuilder {
fn with_exterior_polygon_from_points(
self,
points: impl IntoIterator<Item = impl Into<Point<2>>>,
) -> Self;
fn with_interior_polygon_from_points(
self,
points: impl IntoIterator<Item = impl Into<Point<2>>>,
) -> Self;
}
impl FaceBuilder for PartialFace {
fn with_exterior_polygon_from_points(
self,
points: impl IntoIterator<Item = impl Into<Point<2>>>,
) -> Self {
let surface = self.surface().expect("Need surface to create polygon");
self.with_exterior(
Cycle::partial()
.with_poly_chain_from_points(surface, points)
.close_with_line_segment(),
)
}
fn with_interior_polygon_from_points(
self,
points: impl IntoIterator<Item = impl Into<Point<2>>>,
) -> Self {
let surface = self.surface().expect("Need surface to build polygon.");
self.with_interiors([Cycle::partial()
.with_poly_chain_from_points(surface, points)
.close_with_line_segment()])
}
}