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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use fj_interop::mesh::Color;
use crate::{
objects::{Cycle, Face, Objects},
partial::{FullToPartialCache, Partial, PartialObject},
services::Service,
};
#[derive(Clone, Debug)]
pub struct PartialFace {
pub exterior: Partial<Cycle>,
pub interiors: Vec<Partial<Cycle>>,
pub color: Option<Color>,
}
impl PartialFace {
pub fn new(
exterior: Option<Partial<Cycle>>,
interiors: Vec<Partial<Cycle>>,
color: Option<Color>,
) -> Self {
let exterior = exterior.unwrap_or_default();
Self {
exterior,
interiors,
color,
}
}
}
impl PartialObject for PartialFace {
type Full = Face;
fn from_full(face: &Self::Full, cache: &mut FullToPartialCache) -> Self {
Self::new(
Some(Partial::from_full(face.exterior().clone(), cache)),
face.interiors()
.map(|cycle| Partial::from_full(cycle.clone(), cache))
.collect(),
Some(face.color()),
)
}
fn build(self, objects: &mut Service<Objects>) -> Self::Full {
let exterior = self.exterior.build(objects);
let interiors =
self.interiors.into_iter().map(|cycle| cycle.build(objects));
let color = self.color.unwrap_or_default();
Face::new(exterior, interiors, color)
}
}
impl Default for PartialFace {
fn default() -> Self {
Self::new(None, Vec::new(), None)
}
}