mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-04 01:48:28 +00:00
Add CycleOfHalfEdge
This commit is contained in:
parent
61ef8f024c
commit
610c99cf9d
32
crates/fj-core/src/queries/cycle_of_half_edge.rs
Normal file
32
crates/fj-core/src/queries/cycle_of_half_edge.rs
Normal 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
|
||||
}
|
||||
}
|
@ -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},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user