fj_kernel/algorithms/sweep/
vertex.rs1use fj_math::Vector;
2
3use crate::{
4 objects::{GlobalEdge, Vertex},
5 operations::Insert,
6 services::Services,
7 storage::Handle,
8};
9
10use super::{Sweep, SweepCache};
11
12impl Sweep for Handle<Vertex> {
13 type Swept = (Handle<GlobalEdge>, [Self; 2]);
14
15 fn sweep_with_cache(
16 self,
17 _: impl Into<Vector<3>>,
18 cache: &mut SweepCache,
19 services: &mut Services,
20 ) -> Self::Swept {
21 let a = self.clone();
22 let b = cache
23 .global_vertex
24 .entry(self.id())
25 .or_insert_with(|| Vertex::new().insert(services))
26 .clone();
27
28 let vertices = [a, b];
29 let global_edge = cache
30 .global_edge
31 .entry(self.id())
32 .or_insert_with(|| GlobalEdge::new().insert(services))
33 .clone();
34
35 (global_edge, vertices)
39 }
40}