From 536e7aff1ebfd1f72d61234fdf0fa57b07597cdf Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 28 Feb 2023 17:31:25 +0100 Subject: [PATCH 01/10] Add `HalfEdge::start_position` --- crates/fj-kernel/src/objects/full/edge.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/fj-kernel/src/objects/full/edge.rs b/crates/fj-kernel/src/objects/full/edge.rs index f0a0a4915..3ebe5aa48 100644 --- a/crates/fj-kernel/src/objects/full/edge.rs +++ b/crates/fj-kernel/src/objects/full/edge.rs @@ -79,6 +79,11 @@ impl HalfEdge { self.boundary } + /// Compute the surface position where the half-edge starts + pub fn start_surface_position(&self) -> Point<2> { + self.start_vertex.position() + } + /// Access the vertex from where this half-edge starts pub fn start_vertex(&self) -> &Handle { &self.start_vertex From 6b2446a05ae80e2fd26dc511dd06ed4d86d62813 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 28 Feb 2023 17:32:32 +0100 Subject: [PATCH 02/10] Replace use of `SurfaceVertex::position` --- crates/fj-kernel/src/algorithms/approx/edge.rs | 2 +- crates/fj-kernel/src/objects/full/edge.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/approx/edge.rs b/crates/fj-kernel/src/algorithms/approx/edge.rs index a3542dbb4..95bc0f724 100644 --- a/crates/fj-kernel/src/algorithms/approx/edge.rs +++ b/crates/fj-kernel/src/algorithms/approx/edge.rs @@ -30,7 +30,7 @@ impl Approx for (&Handle, &Surface) { let range = RangeOnPath { boundary }; let first = ApproxPoint::new( - half_edge.start_vertex().position(), + half_edge.start_position(), half_edge.start_vertex().global_form().position(), ) .with_source((half_edge.clone(), half_edge.boundary()[0])); diff --git a/crates/fj-kernel/src/objects/full/edge.rs b/crates/fj-kernel/src/objects/full/edge.rs index 3ebe5aa48..d2ed1e3e7 100644 --- a/crates/fj-kernel/src/objects/full/edge.rs +++ b/crates/fj-kernel/src/objects/full/edge.rs @@ -80,7 +80,7 @@ impl HalfEdge { } /// Compute the surface position where the half-edge starts - pub fn start_surface_position(&self) -> Point<2> { + pub fn start_position(&self) -> Point<2> { self.start_vertex.position() } From bea3bdd71e41d26e19f92ed8314e0d977abd5aaa Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 28 Feb 2023 17:32:32 +0100 Subject: [PATCH 03/10] Replace use of `SurfaceVertex::position` --- crates/fj-kernel/src/algorithms/intersect/face_point.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/face_point.rs b/crates/fj-kernel/src/algorithms/intersect/face_point.rs index 1f13c0a8e..5a234ed92 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_point.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_point.rs @@ -318,10 +318,7 @@ mod tests { let edge = face .exterior() .half_edges() - .find(|edge| { - let vertex = edge.start_vertex(); - vertex.position() == Point::from([0., 0.]) - }) + .find(|edge| edge.start_position() == Point::from([0., 0.])) .unwrap(); assert_eq!( intersection, From 735377e16240d674d8a5e9b98ddd4d5ce707849b Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 28 Feb 2023 17:38:28 +0100 Subject: [PATCH 04/10] Prepare code for follow-on change --- crates/fj-kernel/src/algorithms/intersect/face_point.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/face_point.rs b/crates/fj-kernel/src/algorithms/intersect/face_point.rs index 5a234ed92..769b6aa63 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_point.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_point.rs @@ -349,10 +349,10 @@ mod tests { let vertex = face .exterior() .half_edges() - .map(|half_edge| half_edge.start_vertex().clone()) - .find(|surface_vertex| { - surface_vertex.position() == Point::from([1., 0.]) + .find(|half_edge| { + half_edge.start_vertex().position() == Point::from([1., 0.]) }) + .map(|half_edge| half_edge.start_vertex().clone()) .unwrap(); assert_eq!( intersection, From 4f8e14791c88b576fb3d20ddebae43fd3b5cfe23 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 28 Feb 2023 17:38:47 +0100 Subject: [PATCH 05/10] Replace use of `SurfaceVertex::position` --- crates/fj-kernel/src/algorithms/intersect/face_point.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/face_point.rs b/crates/fj-kernel/src/algorithms/intersect/face_point.rs index 769b6aa63..6d6924570 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_point.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_point.rs @@ -350,7 +350,7 @@ mod tests { .exterior() .half_edges() .find(|half_edge| { - half_edge.start_vertex().position() == Point::from([1., 0.]) + half_edge.start_position() == Point::from([1., 0.]) }) .map(|half_edge| half_edge.start_vertex().clone()) .unwrap(); From ed41ca2c064d68e73cc234a3aba2ad5e20a25912 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 28 Feb 2023 17:40:10 +0100 Subject: [PATCH 06/10] Replace use of `SurfaceVertex::position` --- crates/fj-kernel/src/algorithms/intersect/ray_face.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs index df4937d90..5ef109eed 100644 --- a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs @@ -256,10 +256,7 @@ mod tests { let edge = face .exterior() .half_edges() - .find(|edge| { - let vertex = edge.start_vertex(); - vertex.position() == Point::from([-1., 1.]) - }) + .find(|edge| edge.start_position() == Point::from([-1., 1.])) .unwrap(); assert_eq!( (&ray, &face).intersect(), From 1b1a4a30b15573d13ceccb2e4d5e7a343c216292 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 28 Feb 2023 17:41:19 +0100 Subject: [PATCH 07/10] Prepare code for follow-on change --- crates/fj-kernel/src/algorithms/intersect/ray_face.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs index 5ef109eed..5844beb48 100644 --- a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs @@ -288,10 +288,10 @@ mod tests { let vertex = face .exterior() .half_edges() - .map(|half_edge| half_edge.start_vertex().clone()) - .find(|surface_vertex| { - surface_vertex.position() == Point::from([-1., -1.]) + .find(|half_edge| { + half_edge.start_vertex().position() == Point::from([-1., -1.]) }) + .map(|half_edge| half_edge.start_vertex().clone()) .unwrap(); assert_eq!( (&ray, &face).intersect(), From 942aeeac070db606091785418ae420ce66a80996 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 28 Feb 2023 17:41:37 +0100 Subject: [PATCH 08/10] Replace use of `SurfaceVertex::position` --- crates/fj-kernel/src/algorithms/intersect/ray_face.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs index 5844beb48..f117e480f 100644 --- a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs @@ -289,7 +289,7 @@ mod tests { .exterior() .half_edges() .find(|half_edge| { - half_edge.start_vertex().position() == Point::from([-1., -1.]) + half_edge.start_position() == Point::from([-1., -1.]) }) .map(|half_edge| half_edge.start_vertex().clone()) .unwrap(); From 9d187689c82932a5f95fb56d719ef9e302011858 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 28 Feb 2023 17:43:31 +0100 Subject: [PATCH 09/10] Replace use of `SurfaceVertex::position` --- crates/fj-kernel/src/objects/full/cycle.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/objects/full/cycle.rs b/crates/fj-kernel/src/objects/full/cycle.rs index be42f3fda..dd2abbb35 100644 --- a/crates/fj-kernel/src/objects/full/cycle.rs +++ b/crates/fj-kernel/src/objects/full/cycle.rs @@ -77,8 +77,7 @@ impl Cycle { let mut sum = Scalar::ZERO; for [a, b] in self.half_edges.as_slice().array_windows_ext() { - let [a, b] = - [a, b].map(|half_edge| half_edge.start_vertex().position()); + let [a, b] = [a, b].map(|half_edge| half_edge.start_position()); sum += (b.u - a.u) * (b.v + a.v); } From d7fe518095bd8613205b399640f407d8213c64a0 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 28 Feb 2023 18:35:43 +0100 Subject: [PATCH 10/10] Compute `HalfEdge` start position --- crates/fj-kernel/src/objects/full/edge.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/objects/full/edge.rs b/crates/fj-kernel/src/objects/full/edge.rs index d2ed1e3e7..a40b1b193 100644 --- a/crates/fj-kernel/src/objects/full/edge.rs +++ b/crates/fj-kernel/src/objects/full/edge.rs @@ -81,7 +81,12 @@ impl HalfEdge { /// Compute the surface position where the half-edge starts pub fn start_position(&self) -> Point<2> { - self.start_vertex.position() + // Computing the surface position from the curve position is fine. + // `HalfEdge` "owns" its start position. There is no competing code that + // could compute the surface position from slightly different data. + + let [start, _] = self.boundary; + self.curve.point_from_path_coords(start) } /// Access the vertex from where this half-edge starts