-
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2063 from hannobraun/queries
Update names in `queries` module that refer to half-edges
- Loading branch information
Showing
5 changed files
with
91 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
72 changes: 72 additions & 0 deletions
72
crates/fj-core/src/queries/bounding_vertices_of_half_edge.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
use crate::{ | ||
geometry::CurveBoundary, | ||
objects::{Cycle, Face, HalfEdge, Region, Shell, Vertex}, | ||
storage::Handle, | ||
}; | ||
|
||
/// Determine the bounding vertices of a half-edge | ||
pub trait BoundingVerticesOfHalfEdge { | ||
/// Determine the bounding vertices of a half-edge | ||
/// | ||
/// Returns `None`, if the provided half-edge is not part of the object this | ||
/// method is called on. | ||
fn bounding_vertices_of_half_edge( | ||
&self, | ||
half_edge: &Handle<HalfEdge>, | ||
) -> Option<CurveBoundary<Vertex>>; | ||
} | ||
|
||
impl BoundingVerticesOfHalfEdge for Cycle { | ||
fn bounding_vertices_of_half_edge( | ||
&self, | ||
half_edge: &Handle<HalfEdge>, | ||
) -> Option<CurveBoundary<Vertex>> { | ||
let start = half_edge.start_vertex().clone(); | ||
let end = self.half_edges().after(half_edge)?.start_vertex().clone(); | ||
|
||
Some(CurveBoundary::from([start, end])) | ||
} | ||
} | ||
|
||
impl BoundingVerticesOfHalfEdge for Region { | ||
fn bounding_vertices_of_half_edge( | ||
&self, | ||
half_edge: &Handle<HalfEdge>, | ||
) -> Option<CurveBoundary<Vertex>> { | ||
for cycle in self.all_cycles() { | ||
if let Some(vertices) = | ||
cycle.bounding_vertices_of_half_edge(half_edge) | ||
{ | ||
return Some(vertices); | ||
} | ||
} | ||
|
||
None | ||
} | ||
} | ||
|
||
impl BoundingVerticesOfHalfEdge for Face { | ||
fn bounding_vertices_of_half_edge( | ||
&self, | ||
half_edge: &Handle<HalfEdge>, | ||
) -> Option<CurveBoundary<Vertex>> { | ||
self.region().bounding_vertices_of_half_edge(half_edge) | ||
} | ||
} | ||
|
||
impl BoundingVerticesOfHalfEdge for Shell { | ||
fn bounding_vertices_of_half_edge( | ||
&self, | ||
half_edge: &Handle<HalfEdge>, | ||
) -> Option<CurveBoundary<Vertex>> { | ||
for face in self.faces() { | ||
if let Some(vertices) = | ||
face.bounding_vertices_of_half_edge(half_edge) | ||
{ | ||
return Some(vertices); | ||
} | ||
} | ||
|
||
None | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters