-
-
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 #1974 from hannobraun/query
Add "all edges with surface" query, use it to clean up validation check
- Loading branch information
Showing
4 changed files
with
62 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use crate::{ | ||
objects::{Face, HalfEdge, Shell, Surface}, | ||
storage::Handle, | ||
}; | ||
|
||
/// Access all edges referenced by the object and the surface they're on | ||
pub trait AllEdgesWithSurface { | ||
/// Access all edges referenced by the object and the surface they're on | ||
fn all_edges_with_surface( | ||
&self, | ||
result: &mut Vec<(Handle<HalfEdge>, Handle<Surface>)>, | ||
); | ||
} | ||
|
||
impl AllEdgesWithSurface for Face { | ||
fn all_edges_with_surface( | ||
&self, | ||
result: &mut Vec<(Handle<HalfEdge>, Handle<Surface>)>, | ||
) { | ||
for cycle in self.region().all_cycles() { | ||
result.extend( | ||
cycle | ||
.half_edges() | ||
.cloned() | ||
.map(|half_edge| (half_edge, self.surface().clone())), | ||
); | ||
} | ||
} | ||
} | ||
|
||
impl AllEdgesWithSurface for Shell { | ||
fn all_edges_with_surface( | ||
&self, | ||
result: &mut Vec<(Handle<HalfEdge>, Handle<Surface>)>, | ||
) { | ||
for face in self.faces() { | ||
face.all_edges_with_surface(result); | ||
} | ||
} | ||
} |
11 changes: 0 additions & 11 deletions
11
crates/fj-core/src/queries.rs → .../src/queries/bounding_vertices_of_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
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,18 @@ | ||
//! Queries about objects | ||
//! | ||
//! Objects have methods that provide access to anything that the object itself | ||
//! has direct access to. However, not all potentially interesting information | ||
//! can be accessed that way. An example are the bounding vertices of an edge: | ||
//! `HalfEdge` only stores its starting vertex, so you need a `Cycle` to get | ||
//! both vertices. | ||
//! | ||
//! This module provides traits express such non-trivial queries, and implements | ||
//! them for various objects that have the information to answer the query. | ||
|
||
mod all_edges_with_surface; | ||
mod bounding_vertices_of_edge; | ||
|
||
pub use self::{ | ||
all_edges_with_surface::AllEdgesWithSurface, | ||
bounding_vertices_of_edge::BoundingVerticesOfEdge, | ||
}; |
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