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
use fj_interop::mesh::Color;
use crate::{
objects::{Cycle, Face, Objects},
partial::{FullToPartialCache, Partial, PartialObject},
services::Service,
};
#[derive(Clone, Debug, Default)]
pub struct PartialFace {
pub exterior: Partial<Cycle>,
pub interiors: Vec<Partial<Cycle>>,
pub color: Option<Color>,
}
impl PartialObject for PartialFace {
type Full = Face;
fn from_full(face: &Self::Full, cache: &mut FullToPartialCache) -> Self {
Self {
exterior: Partial::from_full(face.exterior().clone(), cache),
interiors: face
.interiors()
.map(|cycle| Partial::from_full(cycle.clone(), cache))
.collect(),
color: 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)
}
}