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

Return more information from CurveBoundary::normalize #1990

Merged
merged 3 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions crates/fj-core/src/geometry/boundary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@ impl<T: CurveBoundaryElement> CurveBoundary<T> {
/// Normalize the boundary
///
/// Returns a new instance of this struct, which has the bounding elements
/// in a defined order. This can be used to compare a boundary while
/// disregarding its direction.
/// in a defined order, alongside a boolean that indicates whether the new
/// instance is different from the original one.
///
/// This can be used to compare a boundary while disregarding its direction.
#[must_use]
pub fn normalize(mut self) -> Self {
self.inner.sort();
self
pub fn normalize(self) -> (Self, bool) {
let [a, b] = &self.inner;
if a > b {
(self.reverse(), true)
} else {
(self, false)
}
}
}

Expand Down
7 changes: 5 additions & 2 deletions crates/fj-core/src/validate/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ impl ShellValidationError {
.bounding_vertices_of_edge(edge)
.expect("Expected edge to be part of shell")
.normalize()
.0
};

bounding_vertices_of(edge_a)
Expand Down Expand Up @@ -314,7 +315,8 @@ impl ShellValidationError {
.expect(
"Cycle should provide bounds of its own half-edge",
)
.normalize();
.normalize()
.0;

let edge = (curve, bounding_vertices);

Expand Down Expand Up @@ -394,7 +396,8 @@ impl ShellValidationError {
.expect(
"Just got edge from this cycle; must be part of it",
)
.normalize();
.normalize()
.0;

edges_by_coincidence
.entry((curve, boundary))
Expand Down