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; improve error messages #1711

Merged
merged 11 commits into from
Mar 21, 2023
Prev Previous commit
Next Next commit
Make variable name more explicit
hannobraun committed Mar 21, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 53db5a7b3b895822d19b2959f8399a34603a8d45
23 changes: 12 additions & 11 deletions crates/fj-kernel/src/validate/shell.rs
Original file line number Diff line number Diff line change
@@ -100,21 +100,22 @@ impl ShellValidationError {
config: &ValidationConfig,
errors: &mut Vec<ValidationError>,
) {
let faces: Vec<(Handle<HalfEdge>, SurfaceGeometry)> = shell
.faces()
.into_iter()
.flat_map(|face| {
face.all_cycles()
.flat_map(|cycle| cycle.half_edges().cloned())
.zip(repeat(face.surface().geometry()))
})
.collect();
let edges_and_surfaces: Vec<(Handle<HalfEdge>, SurfaceGeometry)> =
shell
.faces()
.into_iter()
.flat_map(|face| {
face.all_cycles()
.flat_map(|cycle| cycle.half_edges().cloned())
.zip(repeat(face.surface().geometry()))
})
.collect();

// This is O(N^2) which isn't great, but we can't use a HashMap since we
// need to deal with float inaccuracies. Maybe we could use some smarter
// data-structure like an octree.
for edge in &faces {
for other_edge in &faces {
for edge in &edges_and_surfaces {
for other_edge in &edges_and_surfaces {
let id = edge.0.global_form().id();
let other_id = other_edge.0.global_form().id();
let identical = id == other_id;