Skip to content

Commit

Permalink
Merge pull request #2065 from hannobraun/validation
Browse files Browse the repository at this point in the history
Clean up `Shell` validation code
  • Loading branch information
hannobraun authored Oct 20, 2023
2 parents 2c1f39b + 02a8ece commit e9e4b7e
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 215 deletions.
20 changes: 10 additions & 10 deletions crates/fj-core/src/objects/kinds/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,6 @@ impl HalfEdge {
self.boundary
}

/// Compute the surface position where the edge starts
pub fn start_position(&self) -> Point<2> {
// Computing the surface position from the curve position is fine.
// `Edge` "owns" its start position. There is no competing code that
// could compute the surface position from slightly different data.

let [start, _] = self.boundary.inner;
self.path.point_from_path_coords(start)
}

/// Access the curve of the edge
pub fn curve(&self) -> &Handle<Curve> {
&self.curve
Expand All @@ -86,4 +76,14 @@ impl HalfEdge {
pub fn start_vertex(&self) -> &Handle<Vertex> {
&self.start_vertex
}

/// Compute the surface position where the edge starts
pub fn start_position(&self) -> Point<2> {
// Computing the surface position from the curve position is fine.
// `Edge` "owns" its start position. There is no competing code that
// could compute the surface position from slightly different data.

let [start, _] = self.boundary.inner;
self.path.point_from_path_coords(start)
}
}
27 changes: 26 additions & 1 deletion crates/fj-core/src/objects/kinds/shell.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{
objects::{handles::Handles, Face},
objects::{handles::Handles, Face, HalfEdge},
queries::BoundingVerticesOfHalfEdge,
storage::Handle,
};

Expand All @@ -21,4 +22,28 @@ impl Shell {
pub fn faces(&self) -> &Handles<Face> {
&self.faces
}

/// Indicate whether the provided half-edges are siblings
pub fn are_siblings(
&self,
a: &Handle<HalfEdge>,
b: &Handle<HalfEdge>,
) -> bool {
let same_curve = a.curve().id() == b.curve().id();
let same_boundary = a.boundary() == b.boundary().reverse();
let same_vertices = {
let Some(a_vertices) = self.bounding_vertices_of_half_edge(a)
else {
return false;
};
let Some(b_vertices) = self.bounding_vertices_of_half_edge(b)
else {
return false;
};

a_vertices == b_vertices.reverse()
};

same_curve && same_boundary && same_vertices
}
}
Loading

0 comments on commit e9e4b7e

Please sign in to comment.