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
use fj_math::Point;
use crate::{
objects::HalfEdge,
partial::{Partial, PartialCycle, PartialFace},
};
use super::CycleBuilder;
pub trait FaceBuilder {
fn update_exterior_as_polygon(
&mut self,
points: impl IntoIterator<Item = impl Into<Point<2>>>,
) -> Vec<Partial<HalfEdge>>;
fn add_interior_polygon(
&mut self,
points: impl IntoIterator<Item = impl Into<Point<2>>>,
);
}
impl FaceBuilder for PartialFace {
fn update_exterior_as_polygon(
&mut self,
points: impl IntoIterator<Item = impl Into<Point<2>>>,
) -> Vec<Partial<HalfEdge>> {
self.exterior.write().update_as_polygon_from_points(points)
}
fn add_interior_polygon(
&mut self,
points: impl IntoIterator<Item = impl Into<Point<2>>>,
) {
let mut cycle = PartialCycle {
surface: self.exterior.read().surface.clone(),
..Default::default()
};
cycle.update_as_polygon_from_points(points);
self.interiors.push(Partial::from_partial(cycle));
}
}