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
use crate::{
    objects::{Cycle, HalfEdge, Objects},
    partial::{FullToPartialCache, PartialObject},
    services::Service,
    storage::Handle,
};

/// A partial [`Cycle`]
#[derive(Clone, Debug)]
pub struct PartialCycle {
    /// The half-edges that make up the cycle
    pub half_edges: Vec<Handle<HalfEdge>>,
}

impl PartialObject for PartialCycle {
    type Full = Cycle;

    fn new(_: &mut Service<Objects>) -> Self {
        Self {
            half_edges: Vec::new(),
        }
    }

    fn from_full(cycle: &Self::Full, _: &mut FullToPartialCache) -> Self {
        Self {
            half_edges: cycle.half_edges().cloned().collect(),
        }
    }

    fn build(self, _: &mut Service<Objects>) -> Self::Full {
        Cycle::new(self.half_edges)
    }
}