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
use crate::{
objects::{Cycle, HalfEdge, Objects, Surface},
partial::{FullToPartialCache, Partial, PartialObject},
services::Service,
};
#[derive(Clone, Debug, Default)]
pub struct PartialCycle {
pub half_edges: Vec<Partial<HalfEdge>>,
}
impl PartialCycle {
pub fn surface(&self) -> Option<Partial<Surface>> {
self.half_edges
.first()
.map(|half_edge| half_edge.read().curve().read().surface.clone())
}
}
impl PartialObject for PartialCycle {
type Full = Cycle;
fn from_full(cycle: &Self::Full, cache: &mut FullToPartialCache) -> Self {
Self {
half_edges: cycle
.half_edges()
.cloned()
.map(|half_edge| Partial::from_full(half_edge, cache))
.collect(),
}
}
fn build(self, objects: &mut Service<Objects>) -> Self::Full {
let half_edges = self
.half_edges
.into_iter()
.map(|half_edge| half_edge.build(objects));
Cycle::new(half_edges)
}
}