Add CycleOfHalfEdge

This commit is contained in:
Hanno Braun 2024-07-09 20:49:59 +02:00
parent 61ef8f024c
commit 610c99cf9d
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,32 @@
use crate::{
storage::Handle,
topology::{Cycle, HalfEdge, Shell},
};
/// Query to find the cycle that a half-edge is part of
pub trait CycleOfHalfEdge {
/// Find the cycle that a half-edge is part of
fn find_cycle_of_half_edge(
&self,
half_edge: &Handle<HalfEdge>,
) -> Option<Handle<Cycle>>;
}
impl CycleOfHalfEdge for Shell {
fn find_cycle_of_half_edge(
&self,
half_edge: &Handle<HalfEdge>,
) -> Option<Handle<Cycle>> {
for face in self.faces() {
for cycle in face.region().all_cycles() {
for h in cycle.half_edges() {
if h == half_edge {
return Some(cycle.clone());
}
}
}
}
None
}
}

View File

@ -11,10 +11,12 @@
mod all_half_edges_with_surface;
mod bounding_vertices_of_half_edge;
mod cycle_of_half_edge;
mod sibling_of_half_edge;
pub use self::{
all_half_edges_with_surface::AllHalfEdgesWithSurface,
bounding_vertices_of_half_edge::BoundingVerticesOfHalfEdge,
cycle_of_half_edge::CycleOfHalfEdge,
sibling_of_half_edge::{Sibling, SiblingOfHalfEdge},
};