From fa66b35cd5cf6e86eb728349aa852de29317c729 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:54:04 +0200 Subject: [PATCH 01/13] Update argument name --- crates/fj-core/src/validate/shell.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index c324f24d4..00c27b77c 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -66,7 +66,7 @@ pub enum ShellValidationError { /// Returns an [`Iterator`] of the distance at each sample. fn distances( config: &ValidationConfig, - (edge1, surface1): (Handle, Handle), + (edge_a, surface1): (Handle, Handle), (edge2, surface2): (Handle, Handle), ) -> impl Iterator { fn sample( @@ -80,7 +80,7 @@ fn distances( } // Check whether start positions do not match. If they don't treat second edge as flipped - let flip = sample(0.0, (&edge1, surface1.geometry())) + let flip = sample(0.0, (&edge_a, surface1.geometry())) .distance_to(&sample(0.0, (&edge2, surface2.geometry()))) > config.identical_max_distance; @@ -93,7 +93,7 @@ fn distances( let mut distances = Vec::new(); for i in 0..sample_count { let percent = i as f64 * step; - let sample1 = sample(percent, (&edge1, surface1.geometry())); + let sample1 = sample(percent, (&edge_a, surface1.geometry())); let sample2 = sample( if flip { 1.0 - percent } else { percent }, (&edge2, surface2.geometry()), From e45e518f902ad69dc561881fe22ea866c3bfb6fb Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:54:24 +0200 Subject: [PATCH 02/13] Update argument name --- crates/fj-core/src/validate/shell.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index 00c27b77c..cd55e41ae 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -66,7 +66,7 @@ pub enum ShellValidationError { /// Returns an [`Iterator`] of the distance at each sample. fn distances( config: &ValidationConfig, - (edge_a, surface1): (Handle, Handle), + (edge_a, surface_a): (Handle, Handle), (edge2, surface2): (Handle, Handle), ) -> impl Iterator { fn sample( @@ -80,7 +80,7 @@ fn distances( } // Check whether start positions do not match. If they don't treat second edge as flipped - let flip = sample(0.0, (&edge_a, surface1.geometry())) + let flip = sample(0.0, (&edge_a, surface_a.geometry())) .distance_to(&sample(0.0, (&edge2, surface2.geometry()))) > config.identical_max_distance; @@ -93,7 +93,7 @@ fn distances( let mut distances = Vec::new(); for i in 0..sample_count { let percent = i as f64 * step; - let sample1 = sample(percent, (&edge_a, surface1.geometry())); + let sample1 = sample(percent, (&edge_a, surface_a.geometry())); let sample2 = sample( if flip { 1.0 - percent } else { percent }, (&edge2, surface2.geometry()), From ba3c118a3db980851523a58802b993bb735a9a78 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:54:40 +0200 Subject: [PATCH 03/13] Update argument name --- crates/fj-core/src/validate/shell.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index cd55e41ae..11307da9d 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -67,7 +67,7 @@ pub enum ShellValidationError { fn distances( config: &ValidationConfig, (edge_a, surface_a): (Handle, Handle), - (edge2, surface2): (Handle, Handle), + (edge_b, surface2): (Handle, Handle), ) -> impl Iterator { fn sample( percent: f64, @@ -81,7 +81,7 @@ fn distances( // Check whether start positions do not match. If they don't treat second edge as flipped let flip = sample(0.0, (&edge_a, surface_a.geometry())) - .distance_to(&sample(0.0, (&edge2, surface2.geometry()))) + .distance_to(&sample(0.0, (&edge_b, surface2.geometry()))) > config.identical_max_distance; // Three samples (start, middle, end), are enough to detect weather lines @@ -96,7 +96,7 @@ fn distances( let sample1 = sample(percent, (&edge_a, surface_a.geometry())); let sample2 = sample( if flip { 1.0 - percent } else { percent }, - (&edge2, surface2.geometry()), + (&edge_b, surface2.geometry()), ); distances.push(sample1.distance_to(&sample2)) } From 3f8f8abf566e931f3760f1381457c995dc4c8fcc Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:54:54 +0200 Subject: [PATCH 04/13] Update argument name --- crates/fj-core/src/validate/shell.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index 11307da9d..1a1c01697 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -67,7 +67,7 @@ pub enum ShellValidationError { fn distances( config: &ValidationConfig, (edge_a, surface_a): (Handle, Handle), - (edge_b, surface2): (Handle, Handle), + (edge_b, surface_b): (Handle, Handle), ) -> impl Iterator { fn sample( percent: f64, @@ -81,7 +81,7 @@ fn distances( // Check whether start positions do not match. If they don't treat second edge as flipped let flip = sample(0.0, (&edge_a, surface_a.geometry())) - .distance_to(&sample(0.0, (&edge_b, surface2.geometry()))) + .distance_to(&sample(0.0, (&edge_b, surface_b.geometry()))) > config.identical_max_distance; // Three samples (start, middle, end), are enough to detect weather lines @@ -96,7 +96,7 @@ fn distances( let sample1 = sample(percent, (&edge_a, surface_a.geometry())); let sample2 = sample( if flip { 1.0 - percent } else { percent }, - (&edge_b, surface2.geometry()), + (&edge_b, surface_b.geometry()), ); distances.push(sample1.distance_to(&sample2)) } From e3a407b3ce0701fd1301c80da5785ba0090c9cc9 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:57:52 +0200 Subject: [PATCH 05/13] Update struct field name --- crates/fj-core/src/validate/shell.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index 1a1c01697..67e120af0 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -41,14 +41,14 @@ pub enum ShellValidationError { /// [`Shell`] contains half-edges that are identical, but do not coincide #[error( "Shell contains HalfEdges that are identical but do not coincide\n\ - Edge 1: {edge_1:#?}\n\ + Edge 1: {edge_a:#?}\n\ Surface for edge 1: {surface_1:#?}\n\ Edge 2: {edge_2:#?}\n\ Surface for edge 2: {surface_2:#?}" )] IdenticalEdgesNotCoincident { /// The first edge - edge_1: Handle, + edge_a: Handle, /// The surface that the first edge is on surface_1: Handle, @@ -140,7 +140,7 @@ impl ShellValidationError { { errors.push( Self::IdenticalEdgesNotCoincident { - edge_1: edge.0.clone(), + edge_a: edge.0.clone(), surface_1: edge.1.clone(), edge_2: other_edge.0.clone(), surface_2: other_edge.1.clone(), From 86e6155a0f721ca95dd891be43bf4a4034a8f5b8 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:58:16 +0200 Subject: [PATCH 06/13] Update struct field name --- crates/fj-core/src/validate/shell.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index 67e120af0..2b8102c6a 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -42,7 +42,7 @@ pub enum ShellValidationError { #[error( "Shell contains HalfEdges that are identical but do not coincide\n\ Edge 1: {edge_a:#?}\n\ - Surface for edge 1: {surface_1:#?}\n\ + Surface for edge 1: {surface_a:#?}\n\ Edge 2: {edge_2:#?}\n\ Surface for edge 2: {surface_2:#?}" )] @@ -51,7 +51,7 @@ pub enum ShellValidationError { edge_a: Handle, /// The surface that the first edge is on - surface_1: Handle, + surface_a: Handle, /// The second edge edge_2: Handle, @@ -141,7 +141,7 @@ impl ShellValidationError { errors.push( Self::IdenticalEdgesNotCoincident { edge_a: edge.0.clone(), - surface_1: edge.1.clone(), + surface_a: edge.1.clone(), edge_2: other_edge.0.clone(), surface_2: other_edge.1.clone(), } From fcc2023327bbf42a72de445441e7a19972a29b2a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:58:36 +0200 Subject: [PATCH 07/13] Update struct field name --- crates/fj-core/src/validate/shell.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index 2b8102c6a..fd4212f59 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -43,7 +43,7 @@ pub enum ShellValidationError { "Shell contains HalfEdges that are identical but do not coincide\n\ Edge 1: {edge_a:#?}\n\ Surface for edge 1: {surface_a:#?}\n\ - Edge 2: {edge_2:#?}\n\ + Edge 2: {edge_b:#?}\n\ Surface for edge 2: {surface_2:#?}" )] IdenticalEdgesNotCoincident { @@ -54,7 +54,7 @@ pub enum ShellValidationError { surface_a: Handle, /// The second edge - edge_2: Handle, + edge_b: Handle, /// The surface that the second edge is on surface_2: Handle, @@ -142,7 +142,7 @@ impl ShellValidationError { Self::IdenticalEdgesNotCoincident { edge_a: edge.0.clone(), surface_a: edge.1.clone(), - edge_2: other_edge.0.clone(), + edge_b: other_edge.0.clone(), surface_2: other_edge.1.clone(), } .into(), From f88bad18baf1c3767fb346bf29afa15ff540cb19 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:58:53 +0200 Subject: [PATCH 08/13] Update struct field name --- crates/fj-core/src/validate/shell.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index fd4212f59..db0aac145 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -44,7 +44,7 @@ pub enum ShellValidationError { Edge 1: {edge_a:#?}\n\ Surface for edge 1: {surface_a:#?}\n\ Edge 2: {edge_b:#?}\n\ - Surface for edge 2: {surface_2:#?}" + Surface for edge 2: {surface_b:#?}" )] IdenticalEdgesNotCoincident { /// The first edge @@ -57,7 +57,7 @@ pub enum ShellValidationError { edge_b: Handle, /// The surface that the second edge is on - surface_2: Handle, + surface_b: Handle, }, } @@ -143,7 +143,7 @@ impl ShellValidationError { edge_a: edge.0.clone(), surface_a: edge.1.clone(), edge_b: other_edge.0.clone(), - surface_2: other_edge.1.clone(), + surface_b: other_edge.1.clone(), } .into(), ) From ab99c9abebdc3be9a236afc61fb7d06a4a7518be Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 12:01:01 +0200 Subject: [PATCH 09/13] Un-tangle variables --- crates/fj-core/src/validate/shell.rs | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index db0aac145..cfae1bd2f 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -123,9 +123,9 @@ impl ShellValidationError { // 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 &edges_and_surfaces { + for (edge_a, surface_a) in &edges_and_surfaces { for other_edge in &edges_and_surfaces { - let id = edge.0.global_form().id(); + let id = edge_a.global_form().id(); let other_id = other_edge.0.global_form().id(); let identical = id == other_id; @@ -135,13 +135,17 @@ impl ShellValidationError { // All points on identical curves should be within // identical_max_distance, so we shouldn't have any // greater than the max - if distances(config, edge.clone(), other_edge.clone()) - .any(|d| d > config.identical_max_distance) + if distances( + config, + (edge_a.clone(), surface_a.clone()), + other_edge.clone(), + ) + .any(|d| d > config.identical_max_distance) { errors.push( Self::IdenticalEdgesNotCoincident { - edge_a: edge.0.clone(), - surface_a: edge.1.clone(), + edge_a: edge_a.clone(), + surface_a: surface_a.clone(), edge_b: other_edge.0.clone(), surface_b: other_edge.1.clone(), } @@ -152,12 +156,16 @@ impl ShellValidationError { false => { // If all points on distinct curves are within // distinct_min_distance, that's a problem. - if distances(config, edge.clone(), other_edge.clone()) - .all(|d| d < config.distinct_min_distance) + if distances( + config, + (edge_a.clone(), surface_a.clone()), + other_edge.clone(), + ) + .all(|d| d < config.distinct_min_distance) { errors.push( Self::CoincidentEdgesNotIdentical( - edge.0.clone(), + edge_a.clone(), other_edge.0.clone(), ) .into(), From a2515f795014e88dda9e9d8cc19155108fd571d5 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 12:02:24 +0200 Subject: [PATCH 10/13] Un-tangle arguments --- crates/fj-core/src/validate/shell.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index cfae1bd2f..a32bf0b71 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -66,7 +66,8 @@ pub enum ShellValidationError { /// Returns an [`Iterator`] of the distance at each sample. fn distances( config: &ValidationConfig, - (edge_a, surface_a): (Handle, Handle), + edge_a: Handle, + surface_a: Handle, (edge_b, surface_b): (Handle, Handle), ) -> impl Iterator { fn sample( @@ -137,7 +138,8 @@ impl ShellValidationError { // greater than the max if distances( config, - (edge_a.clone(), surface_a.clone()), + edge_a.clone(), + surface_a.clone(), other_edge.clone(), ) .any(|d| d > config.identical_max_distance) @@ -158,7 +160,8 @@ impl ShellValidationError { // distinct_min_distance, that's a problem. if distances( config, - (edge_a.clone(), surface_a.clone()), + edge_a.clone(), + surface_a.clone(), other_edge.clone(), ) .all(|d| d < config.distinct_min_distance) From 90c10f812eaa8e780d959e48e141adaeddcea3e3 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 12:05:23 +0200 Subject: [PATCH 11/13] Un-tangle variables --- crates/fj-core/src/validate/shell.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index a32bf0b71..5aa5ad175 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -125,9 +125,9 @@ impl ShellValidationError { // need to deal with float inaccuracies. Maybe we could use some smarter // data-structure like an octree. for (edge_a, surface_a) in &edges_and_surfaces { - for other_edge in &edges_and_surfaces { + for (edge_b, surface_b) in &edges_and_surfaces { let id = edge_a.global_form().id(); - let other_id = other_edge.0.global_form().id(); + let other_id = edge_b.global_form().id(); let identical = id == other_id; @@ -140,7 +140,7 @@ impl ShellValidationError { config, edge_a.clone(), surface_a.clone(), - other_edge.clone(), + (edge_b.clone(), surface_b.clone()), ) .any(|d| d > config.identical_max_distance) { @@ -148,8 +148,8 @@ impl ShellValidationError { Self::IdenticalEdgesNotCoincident { edge_a: edge_a.clone(), surface_a: surface_a.clone(), - edge_b: other_edge.0.clone(), - surface_b: other_edge.1.clone(), + edge_b: edge_b.clone(), + surface_b: surface_b.clone(), } .into(), ) @@ -162,14 +162,14 @@ impl ShellValidationError { config, edge_a.clone(), surface_a.clone(), - other_edge.clone(), + (edge_b.clone(), surface_b.clone()), ) .all(|d| d < config.distinct_min_distance) { errors.push( Self::CoincidentEdgesNotIdentical( edge_a.clone(), - other_edge.0.clone(), + edge_b.clone(), ) .into(), ) From 5bbd1a11d8a5c4e46b6e3e7d8cff127960878ccc Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 12:06:47 +0200 Subject: [PATCH 12/13] Un-tangle arguments --- crates/fj-core/src/validate/shell.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index 5aa5ad175..b967a3956 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -68,7 +68,8 @@ fn distances( config: &ValidationConfig, edge_a: Handle, surface_a: Handle, - (edge_b, surface_b): (Handle, Handle), + edge_b: Handle, + surface_b: Handle, ) -> impl Iterator { fn sample( percent: f64, @@ -140,7 +141,8 @@ impl ShellValidationError { config, edge_a.clone(), surface_a.clone(), - (edge_b.clone(), surface_b.clone()), + edge_b.clone(), + surface_b.clone(), ) .any(|d| d > config.identical_max_distance) { @@ -162,7 +164,8 @@ impl ShellValidationError { config, edge_a.clone(), surface_a.clone(), - (edge_b.clone(), surface_b.clone()), + edge_b.clone(), + surface_b.clone(), ) .all(|d| d < config.distinct_min_distance) { From 97c06be88ade1483839c05d3fb63505b20c9b8b8 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 12:07:36 +0200 Subject: [PATCH 13/13] Inline redundant variables --- crates/fj-core/src/validate/shell.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index b967a3956..dfd6a62be 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -127,10 +127,8 @@ impl ShellValidationError { // data-structure like an octree. for (edge_a, surface_a) in &edges_and_surfaces { for (edge_b, surface_b) in &edges_and_surfaces { - let id = edge_a.global_form().id(); - let other_id = edge_b.global_form().id(); - - let identical = id == other_id; + let identical = + edge_a.global_form().id() == edge_b.global_form().id(); match identical { true => {