Skip to main content

mesh_graph/ops/
mod.rs

1mod add;
2mod cleanup;
3mod collapse;
4mod edit;
5mod merge_one_ring;
6mod query;
7mod remove;
8mod subdivide;
9mod transform;
10
11pub use add::*;
12use hashbrown::HashMap;
13pub use merge_one_ring::*;
14
15use crate::{HalfedgeId, MeshGraph, utils::unwrap_or_return};
16
17impl MeshGraph {
18    pub fn halfedges_map(&mut self, predicate: impl Fn(f32) -> bool) -> HashMap<HalfedgeId, f32> {
19        let mut halfedges_map = HashMap::new();
20
21        for (he_id, he) in &self.halfedges {
22            let twin_id = unwrap_or_return!(he.twin, "Twin missing", halfedges_map);
23
24            let id = he_id.min(twin_id);
25
26            if halfedges_map.contains_key(&id) {
27                continue;
28            }
29            let len_sqr = he.length_squared(self);
30
31            if predicate(len_sqr) {
32                halfedges_map.insert(id, len_sqr);
33            }
34        }
35
36        halfedges_map
37    }
38}