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
use crate::{
geometry::surface::SurfaceGeometry,
objects::{Objects, Surface},
partial::{FullToPartialCache, PartialObject},
services::Service,
};
#[derive(Clone, Debug)]
pub struct PartialSurface {
pub geometry: Option<SurfaceGeometry>,
}
impl PartialSurface {
pub fn new(geometry: Option<SurfaceGeometry>) -> Self {
Self { geometry }
}
}
impl PartialObject for PartialSurface {
type Full = Surface;
fn from_full(surface: &Self::Full, _: &mut FullToPartialCache) -> Self {
Self::new(Some(surface.geometry()))
}
fn build(self, _: &mut Service<Objects>) -> Self::Full {
let geometry = self
.geometry
.expect("Can't build `Surface` without geometry");
Surface::new(geometry)
}
}
impl Default for PartialSurface {
fn default() -> Self {
Self::new(None)
}
}