Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up Shell validation code #2065

Merged
merged 15 commits into from
Oct 20, 2023
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