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

Update validation check to also use curves #1983

Merged
merged 2 commits into from
Aug 7, 2023
Merged
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
41 changes: 40 additions & 1 deletion crates/fj-core/src/validate/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,46 @@ impl ShellValidationError {
// Check if a is reverse of b
if a.boundary().reverse() != b.boundary() {
errors.push(Self::MixedOrientations.into());
dbg!(a, b);
return;
}
}
}

// Here's the same check again a second time, except using `Curve`
// instead of `GlobalEdge`. This redundancy can be fixed once the
// transition from `Curve` to `GlobalEdge` is finished, and `GlobalEdge`
// can be removed.

let mut edges_by_coincidence = BTreeMap::new();

for face in shell.faces() {
for cycle in face.region().all_cycles() {
for edge in cycle.half_edges() {
let curve = HandleWrapper::from(edge.curve().clone());
let boundary = cycle
.bounding_vertices_of_edge(edge)
.expect(
"Just got edge from this cycle; must be part of it",
)
.normalize();

edges_by_coincidence
.entry((curve, boundary))
.or_insert(Vec::new())
.push(edge.clone());
}
}
}

for (_, edges) in edges_by_coincidence {
let mut edges = edges.into_iter();

// We should have exactly two coincident edges here. This is
// verified in a different validation check, so let's just silently
// do nothing here, if that isn't the case.
if let (Some(a), Some(b)) = (edges.next(), edges.next()) {
if a.boundary().reverse() != b.boundary() {
errors.push(Self::MixedOrientations.into());
return;
}
}
Expand Down