From a7b0e7f106cee7ea313b03bf2b90d8171cb2bfb2 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 20 Oct 2023 10:09:39 +0200 Subject: [PATCH 01/10] Update trait method name --- .../src/queries/bounding_vertices_of_edge.rs | 16 ++++++++-------- crates/fj-core/src/validate/shell.rs | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/fj-core/src/queries/bounding_vertices_of_edge.rs b/crates/fj-core/src/queries/bounding_vertices_of_edge.rs index 7c86118d9..f3fac8d10 100644 --- a/crates/fj-core/src/queries/bounding_vertices_of_edge.rs +++ b/crates/fj-core/src/queries/bounding_vertices_of_edge.rs @@ -10,14 +10,14 @@ pub trait BoundingVerticesOfEdge { /// /// Returns `None`, if the provided edge is not part of the object this /// method is called on. - fn bounding_vertices_of_edge( + fn bounding_vertices_of_half_edge( &self, edge: &Handle, ) -> Option>; } impl BoundingVerticesOfEdge for Cycle { - fn bounding_vertices_of_edge( + fn bounding_vertices_of_half_edge( &self, edge: &Handle, ) -> Option> { @@ -29,12 +29,12 @@ impl BoundingVerticesOfEdge for Cycle { } impl BoundingVerticesOfEdge for Region { - fn bounding_vertices_of_edge( + fn bounding_vertices_of_half_edge( &self, edge: &Handle, ) -> Option> { for cycle in self.all_cycles() { - if let Some(vertices) = cycle.bounding_vertices_of_edge(edge) { + if let Some(vertices) = cycle.bounding_vertices_of_half_edge(edge) { return Some(vertices); } } @@ -44,21 +44,21 @@ impl BoundingVerticesOfEdge for Region { } impl BoundingVerticesOfEdge for Face { - fn bounding_vertices_of_edge( + fn bounding_vertices_of_half_edge( &self, edge: &Handle, ) -> Option> { - self.region().bounding_vertices_of_edge(edge) + self.region().bounding_vertices_of_half_edge(edge) } } impl BoundingVerticesOfEdge for Shell { - fn bounding_vertices_of_edge( + fn bounding_vertices_of_half_edge( &self, edge: &Handle, ) -> Option> { for face in self.faces() { - if let Some(vertices) = face.bounding_vertices_of_edge(edge) { + if let Some(vertices) = face.bounding_vertices_of_half_edge(edge) { return Some(vertices); } } diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index 550552743..2110967fe 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -230,7 +230,7 @@ impl ShellValidationError { let have_same_boundary = { let bounding_vertices_of = |edge| { shell - .bounding_vertices_of_edge(edge) + .bounding_vertices_of_half_edge(edge) .expect("Expected edge to be part of shell") .normalize() }; @@ -332,7 +332,7 @@ impl ShellValidationError { for edge in cycle.half_edges() { let curve = HandleWrapper::from(edge.curve().clone()); let boundary = cycle - .bounding_vertices_of_edge(edge) + .bounding_vertices_of_half_edge(edge) .expect( "Just got edge from this cycle; must be part of it", ) From 3f99eb9ccfef08949dafe408dc84d9641810b7ea Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 20 Oct 2023 10:10:01 +0200 Subject: [PATCH 02/10] Update trait name --- .../fj-core/src/queries/bounding_vertices_of_edge.rs | 10 +++++----- crates/fj-core/src/queries/mod.rs | 2 +- crates/fj-core/src/validate/shell.rs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/fj-core/src/queries/bounding_vertices_of_edge.rs b/crates/fj-core/src/queries/bounding_vertices_of_edge.rs index f3fac8d10..b64bd0615 100644 --- a/crates/fj-core/src/queries/bounding_vertices_of_edge.rs +++ b/crates/fj-core/src/queries/bounding_vertices_of_edge.rs @@ -5,7 +5,7 @@ use crate::{ }; /// Determine the bounding vertices of an edge -pub trait BoundingVerticesOfEdge { +pub trait BoundingVerticesOfHalfEdge { /// Determine the bounding vertices of an edge /// /// Returns `None`, if the provided edge is not part of the object this @@ -16,7 +16,7 @@ pub trait BoundingVerticesOfEdge { ) -> Option>; } -impl BoundingVerticesOfEdge for Cycle { +impl BoundingVerticesOfHalfEdge for Cycle { fn bounding_vertices_of_half_edge( &self, edge: &Handle, @@ -28,7 +28,7 @@ impl BoundingVerticesOfEdge for Cycle { } } -impl BoundingVerticesOfEdge for Region { +impl BoundingVerticesOfHalfEdge for Region { fn bounding_vertices_of_half_edge( &self, edge: &Handle, @@ -43,7 +43,7 @@ impl BoundingVerticesOfEdge for Region { } } -impl BoundingVerticesOfEdge for Face { +impl BoundingVerticesOfHalfEdge for Face { fn bounding_vertices_of_half_edge( &self, edge: &Handle, @@ -52,7 +52,7 @@ impl BoundingVerticesOfEdge for Face { } } -impl BoundingVerticesOfEdge for Shell { +impl BoundingVerticesOfHalfEdge for Shell { fn bounding_vertices_of_half_edge( &self, edge: &Handle, diff --git a/crates/fj-core/src/queries/mod.rs b/crates/fj-core/src/queries/mod.rs index 06f064a3f..462790264 100644 --- a/crates/fj-core/src/queries/mod.rs +++ b/crates/fj-core/src/queries/mod.rs @@ -14,5 +14,5 @@ mod bounding_vertices_of_edge; pub use self::{ all_edges_with_surface::AllEdgesWithSurface, - bounding_vertices_of_edge::BoundingVerticesOfEdge, + bounding_vertices_of_edge::BoundingVerticesOfHalfEdge, }; diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index 2110967fe..69376e0f2 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -5,7 +5,7 @@ use fj_math::{Point, Scalar}; use crate::{ geometry::{CurveBoundaries, SurfaceGeometry}, objects::{HalfEdge, Shell, Surface}, - queries::{AllEdgesWithSurface, BoundingVerticesOfEdge}, + queries::{AllEdgesWithSurface, BoundingVerticesOfHalfEdge}, storage::{Handle, HandleWrapper}, }; From 4c3bc94389f975f25aa3a3b7695b958bd9b41890 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 20 Oct 2023 10:10:41 +0200 Subject: [PATCH 03/10] Update module name --- ..._vertices_of_edge.rs => bounding_vertices_of_half_edge.rs} | 0 crates/fj-core/src/queries/mod.rs | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename crates/fj-core/src/queries/{bounding_vertices_of_edge.rs => bounding_vertices_of_half_edge.rs} (100%) diff --git a/crates/fj-core/src/queries/bounding_vertices_of_edge.rs b/crates/fj-core/src/queries/bounding_vertices_of_half_edge.rs similarity index 100% rename from crates/fj-core/src/queries/bounding_vertices_of_edge.rs rename to crates/fj-core/src/queries/bounding_vertices_of_half_edge.rs diff --git a/crates/fj-core/src/queries/mod.rs b/crates/fj-core/src/queries/mod.rs index 462790264..808ad0e34 100644 --- a/crates/fj-core/src/queries/mod.rs +++ b/crates/fj-core/src/queries/mod.rs @@ -10,9 +10,9 @@ //! them for various objects that have the information to answer the query. mod all_edges_with_surface; -mod bounding_vertices_of_edge; +mod bounding_vertices_of_half_edge; pub use self::{ all_edges_with_surface::AllEdgesWithSurface, - bounding_vertices_of_edge::BoundingVerticesOfHalfEdge, + bounding_vertices_of_half_edge::BoundingVerticesOfHalfEdge, }; From 7687420ebf0adcf05c4447a55e5a62b843d79397 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 20 Oct 2023 10:11:48 +0200 Subject: [PATCH 04/10] Update docs of `BoundingVerticesOfHalfEdge` --- .../fj-core/src/queries/bounding_vertices_of_half_edge.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/queries/bounding_vertices_of_half_edge.rs b/crates/fj-core/src/queries/bounding_vertices_of_half_edge.rs index b64bd0615..f6b4e600b 100644 --- a/crates/fj-core/src/queries/bounding_vertices_of_half_edge.rs +++ b/crates/fj-core/src/queries/bounding_vertices_of_half_edge.rs @@ -4,11 +4,11 @@ use crate::{ storage::Handle, }; -/// Determine the bounding vertices of an edge +/// Determine the bounding vertices of a half-edge pub trait BoundingVerticesOfHalfEdge { - /// Determine the bounding vertices of an edge + /// Determine the bounding vertices of a half-edge /// - /// Returns `None`, if the provided edge is not part of the object this + /// Returns `None`, if the provided half-edge is not part of the object this /// method is called on. fn bounding_vertices_of_half_edge( &self, From 945f76627755abacab5b40c9b12e12b436a7210f Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 20 Oct 2023 10:12:37 +0200 Subject: [PATCH 05/10] Update argument names --- .../queries/bounding_vertices_of_half_edge.rs | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/crates/fj-core/src/queries/bounding_vertices_of_half_edge.rs b/crates/fj-core/src/queries/bounding_vertices_of_half_edge.rs index f6b4e600b..92f1d243b 100644 --- a/crates/fj-core/src/queries/bounding_vertices_of_half_edge.rs +++ b/crates/fj-core/src/queries/bounding_vertices_of_half_edge.rs @@ -12,17 +12,17 @@ pub trait BoundingVerticesOfHalfEdge { /// method is called on. fn bounding_vertices_of_half_edge( &self, - edge: &Handle, + half_edge: &Handle, ) -> Option>; } impl BoundingVerticesOfHalfEdge for Cycle { fn bounding_vertices_of_half_edge( &self, - edge: &Handle, + half_edge: &Handle, ) -> Option> { - let start = edge.start_vertex().clone(); - let end = self.half_edges().after(edge)?.start_vertex().clone(); + let start = half_edge.start_vertex().clone(); + let end = self.half_edges().after(half_edge)?.start_vertex().clone(); Some(CurveBoundary::from([start, end])) } @@ -31,10 +31,12 @@ impl BoundingVerticesOfHalfEdge for Cycle { impl BoundingVerticesOfHalfEdge for Region { fn bounding_vertices_of_half_edge( &self, - edge: &Handle, + half_edge: &Handle, ) -> Option> { for cycle in self.all_cycles() { - if let Some(vertices) = cycle.bounding_vertices_of_half_edge(edge) { + if let Some(vertices) = + cycle.bounding_vertices_of_half_edge(half_edge) + { return Some(vertices); } } @@ -46,19 +48,21 @@ impl BoundingVerticesOfHalfEdge for Region { impl BoundingVerticesOfHalfEdge for Face { fn bounding_vertices_of_half_edge( &self, - edge: &Handle, + half_edge: &Handle, ) -> Option> { - self.region().bounding_vertices_of_half_edge(edge) + self.region().bounding_vertices_of_half_edge(half_edge) } } impl BoundingVerticesOfHalfEdge for Shell { fn bounding_vertices_of_half_edge( &self, - edge: &Handle, + half_edge: &Handle, ) -> Option> { for face in self.faces() { - if let Some(vertices) = face.bounding_vertices_of_half_edge(edge) { + if let Some(vertices) = + face.bounding_vertices_of_half_edge(half_edge) + { return Some(vertices); } } From ec3b8dae5d9a54b894db12c5d69dbe5a7eea377b Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 20 Oct 2023 10:13:14 +0200 Subject: [PATCH 06/10] Update trait method name --- crates/fj-core/src/queries/all_edges_with_surface.rs | 8 ++++---- crates/fj-core/src/validate/shell.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/fj-core/src/queries/all_edges_with_surface.rs b/crates/fj-core/src/queries/all_edges_with_surface.rs index e2901009a..4ba10ccf9 100644 --- a/crates/fj-core/src/queries/all_edges_with_surface.rs +++ b/crates/fj-core/src/queries/all_edges_with_surface.rs @@ -6,14 +6,14 @@ use crate::{ /// Access all edges referenced by the object and the surface they're on pub trait AllEdgesWithSurface { /// Access all edges referenced by the object and the surface they're on - fn all_edges_with_surface( + fn all_half_edges_with_surface( &self, result: &mut Vec<(Handle, Handle)>, ); } impl AllEdgesWithSurface for Face { - fn all_edges_with_surface( + fn all_half_edges_with_surface( &self, result: &mut Vec<(Handle, Handle)>, ) { @@ -30,12 +30,12 @@ impl AllEdgesWithSurface for Face { } impl AllEdgesWithSurface for Shell { - fn all_edges_with_surface( + fn all_half_edges_with_surface( &self, result: &mut Vec<(Handle, Handle)>, ) { for face in self.faces() { - face.all_edges_with_surface(result); + face.all_half_edges_with_surface(result); } } } diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index 69376e0f2..181b853c2 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -118,7 +118,7 @@ impl ShellValidationError { errors: &mut Vec, ) { let mut edges_and_surfaces = Vec::new(); - shell.all_edges_with_surface(&mut edges_and_surfaces); + shell.all_half_edges_with_surface(&mut edges_and_surfaces); for (edge_a, surface_a) in &edges_and_surfaces { for (edge_b, surface_b) in &edges_and_surfaces { @@ -211,7 +211,7 @@ impl ShellValidationError { errors: &mut Vec, ) { let mut edges_and_surfaces = Vec::new(); - shell.all_edges_with_surface(&mut edges_and_surfaces); + shell.all_half_edges_with_surface(&mut edges_and_surfaces); // 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 From 5789c7c5270de451a58c958516f03898690147ad Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 20 Oct 2023 10:13:34 +0200 Subject: [PATCH 07/10] Update trait name --- crates/fj-core/src/queries/all_edges_with_surface.rs | 6 +++--- crates/fj-core/src/queries/mod.rs | 2 +- crates/fj-core/src/validate/shell.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/fj-core/src/queries/all_edges_with_surface.rs b/crates/fj-core/src/queries/all_edges_with_surface.rs index 4ba10ccf9..bba0ffb7c 100644 --- a/crates/fj-core/src/queries/all_edges_with_surface.rs +++ b/crates/fj-core/src/queries/all_edges_with_surface.rs @@ -4,7 +4,7 @@ use crate::{ }; /// Access all edges referenced by the object and the surface they're on -pub trait AllEdgesWithSurface { +pub trait AllHalfEdgesWithSurface { /// Access all edges referenced by the object and the surface they're on fn all_half_edges_with_surface( &self, @@ -12,7 +12,7 @@ pub trait AllEdgesWithSurface { ); } -impl AllEdgesWithSurface for Face { +impl AllHalfEdgesWithSurface for Face { fn all_half_edges_with_surface( &self, result: &mut Vec<(Handle, Handle)>, @@ -29,7 +29,7 @@ impl AllEdgesWithSurface for Face { } } -impl AllEdgesWithSurface for Shell { +impl AllHalfEdgesWithSurface for Shell { fn all_half_edges_with_surface( &self, result: &mut Vec<(Handle, Handle)>, diff --git a/crates/fj-core/src/queries/mod.rs b/crates/fj-core/src/queries/mod.rs index 808ad0e34..0c0621562 100644 --- a/crates/fj-core/src/queries/mod.rs +++ b/crates/fj-core/src/queries/mod.rs @@ -13,6 +13,6 @@ mod all_edges_with_surface; mod bounding_vertices_of_half_edge; pub use self::{ - all_edges_with_surface::AllEdgesWithSurface, + all_edges_with_surface::AllHalfEdgesWithSurface, bounding_vertices_of_half_edge::BoundingVerticesOfHalfEdge, }; diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index 181b853c2..a14a0d878 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -5,7 +5,7 @@ use fj_math::{Point, Scalar}; use crate::{ geometry::{CurveBoundaries, SurfaceGeometry}, objects::{HalfEdge, Shell, Surface}, - queries::{AllEdgesWithSurface, BoundingVerticesOfHalfEdge}, + queries::{AllHalfEdgesWithSurface, BoundingVerticesOfHalfEdge}, storage::{Handle, HandleWrapper}, }; From 5b2d34f6c03028b8b8bedd7a59c02d38bffebf53 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 20 Oct 2023 10:14:11 +0200 Subject: [PATCH 08/10] Update module name --- ...l_edges_with_surface.rs => all_half_edges_with_surface.rs} | 0 crates/fj-core/src/queries/mod.rs | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename crates/fj-core/src/queries/{all_edges_with_surface.rs => all_half_edges_with_surface.rs} (100%) diff --git a/crates/fj-core/src/queries/all_edges_with_surface.rs b/crates/fj-core/src/queries/all_half_edges_with_surface.rs similarity index 100% rename from crates/fj-core/src/queries/all_edges_with_surface.rs rename to crates/fj-core/src/queries/all_half_edges_with_surface.rs diff --git a/crates/fj-core/src/queries/mod.rs b/crates/fj-core/src/queries/mod.rs index 0c0621562..03ac82d26 100644 --- a/crates/fj-core/src/queries/mod.rs +++ b/crates/fj-core/src/queries/mod.rs @@ -9,10 +9,10 @@ //! This module provides traits express such non-trivial queries, and implements //! them for various objects that have the information to answer the query. -mod all_edges_with_surface; +mod all_half_edges_with_surface; mod bounding_vertices_of_half_edge; pub use self::{ - all_edges_with_surface::AllHalfEdgesWithSurface, + all_half_edges_with_surface::AllHalfEdgesWithSurface, bounding_vertices_of_half_edge::BoundingVerticesOfHalfEdge, }; From 0a151ea6280f23ea025a67ca00f15d651d39f0bc Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 20 Oct 2023 10:15:24 +0200 Subject: [PATCH 09/10] Update documentation of `AllHalfEdgesWithSurface` --- crates/fj-core/src/queries/all_half_edges_with_surface.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-core/src/queries/all_half_edges_with_surface.rs b/crates/fj-core/src/queries/all_half_edges_with_surface.rs index bba0ffb7c..d4b5559d4 100644 --- a/crates/fj-core/src/queries/all_half_edges_with_surface.rs +++ b/crates/fj-core/src/queries/all_half_edges_with_surface.rs @@ -3,9 +3,9 @@ use crate::{ storage::Handle, }; -/// Access all edges referenced by the object and the surface they're on +/// Access all half-edges referenced by an object, and the surface they're on pub trait AllHalfEdgesWithSurface { - /// Access all edges referenced by the object and the surface they're on + /// Access all half-edges of the object, and the surface they're on fn all_half_edges_with_surface( &self, result: &mut Vec<(Handle, Handle)>, From eaa7337cd033ffc3ac409fa4d4a4e1cdd0354a46 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 20 Oct 2023 10:15:46 +0200 Subject: [PATCH 10/10] Update argument name --- crates/fj-core/src/queries/all_half_edges_with_surface.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-core/src/queries/all_half_edges_with_surface.rs b/crates/fj-core/src/queries/all_half_edges_with_surface.rs index d4b5559d4..300e1b830 100644 --- a/crates/fj-core/src/queries/all_half_edges_with_surface.rs +++ b/crates/fj-core/src/queries/all_half_edges_with_surface.rs @@ -23,7 +23,7 @@ impl AllHalfEdgesWithSurface for Face { .half_edges() .iter() .cloned() - .map(|edge| (edge, self.surface().clone())), + .map(|half_edge| (half_edge, self.surface().clone())), ); } }