From b38454725f22a46a11183633b05ad559e94b1804 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 7 Aug 2023 12:37:03 +0200 Subject: [PATCH 1/2] Remove debug output --- crates/fj-core/src/validate/shell.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index e4882503f..28ddd5f98 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -373,7 +373,6 @@ impl ShellValidationError { // Check if a is reverse of b if a.boundary().reverse() != b.boundary() { errors.push(Self::MixedOrientations.into()); - dbg!(a, b); return; } } From 5435f6921b39f9dfa7c4be0a95651ed5f0791a9e Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 7 Aug 2023 12:49:14 +0200 Subject: [PATCH 2/2] Update validation check to also use `Curve` --- crates/fj-core/src/validate/shell.rs | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index 28ddd5f98..eb1f1f328 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -377,6 +377,46 @@ impl ShellValidationError { } } } + + // 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; + } + } + } } }