fj_kernel/algorithms/reverse/
cycle.rs1use itertools::Itertools;
2
3use crate::{
4 objects::{Cycle, HalfEdge},
5 operations::Insert,
6 services::Services,
7 storage::Handle,
8};
9
10use super::Reverse;
11
12impl Reverse for Handle<Cycle> {
13 fn reverse(self, services: &mut Services) -> Self {
14 let mut edges = self
15 .half_edges()
16 .cloned()
17 .circular_tuple_windows()
18 .map(|(current, next)| {
19 let boundary = {
20 let [a, b] = current.boundary();
21 [b, a]
22 };
23
24 HalfEdge::new(
25 current.curve(),
26 boundary,
27 next.start_vertex().clone(),
28 current.global_form().clone(),
29 )
30 .insert(services)
31 })
32 .collect::<Vec<_>>();
33
34 edges.reverse();
35
36 Cycle::new(edges).insert(services)
37 }
38}