From d9f4d08858434344f0e53afe6a37b102a3b11401 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:00:55 +0200 Subject: [PATCH 01/24] Rename `RangeOnPath` to `BoundaryOnCurve` I intend to use this struct more broadly, outside of the approximation code, and this is the start of a cleanup effort meant to enable this. --- crates/fj-core/src/algorithms/approx/edge.rs | 20 ++++++++++---------- crates/fj-core/src/algorithms/approx/path.rs | 18 +++++++++--------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/edge.rs b/crates/fj-core/src/algorithms/approx/edge.rs index a3310ece7..bdce2d8aa 100644 --- a/crates/fj-core/src/algorithms/approx/edge.rs +++ b/crates/fj-core/src/algorithms/approx/edge.rs @@ -15,7 +15,7 @@ use crate::{ storage::{Handle, ObjectId}, }; -use super::{path::RangeOnPath, Approx, ApproxPoint, Tolerance}; +use super::{path::BoundaryOnCurve, Approx, ApproxPoint, Tolerance}; impl Approx for (&HalfEdge, &Surface) { type Approximation = HalfEdgeApprox; @@ -29,7 +29,7 @@ impl Approx for (&HalfEdge, &Surface) { let (half_edge, surface) = self; let boundary = half_edge.boundary(); - let range = RangeOnPath { boundary }; + let range = BoundaryOnCurve { boundary }; let position_surface = half_edge.start_position(); let position_global = match cache.get_position(half_edge.start_vertex()) @@ -148,7 +148,7 @@ impl HalfEdgeApprox { fn approx_edge( path: &SurfacePath, surface: &Surface, - range: RangeOnPath, + range: BoundaryOnCurve, tolerance: impl Into, ) -> GlobalEdgeApprox { // There are different cases of varying complexity. Circles are the hard @@ -192,7 +192,7 @@ fn approx_edge( } (SurfacePath::Line(line), _) => { let range_u = - RangeOnPath::from(range.boundary.map(|point_curve| { + BoundaryOnCurve::from(range.boundary.map(|point_curve| { [path.point_from_path_coords(point_curve).u] })); @@ -224,7 +224,7 @@ fn approx_edge( /// A cache for results of an approximation #[derive(Default)] pub struct EdgeCache { - edge_approx: BTreeMap<(ObjectId, RangeOnPath), GlobalEdgeApprox>, + edge_approx: BTreeMap<(ObjectId, BoundaryOnCurve), GlobalEdgeApprox>, vertex_approx: BTreeMap>, } @@ -238,7 +238,7 @@ impl EdgeCache { pub fn get_edge( &self, handle: Handle, - range: RangeOnPath, + range: BoundaryOnCurve, ) -> Option { if let Some(approx) = self.edge_approx.get(&(handle.id(), range)) { return Some(approx.clone()); @@ -258,7 +258,7 @@ impl EdgeCache { pub fn insert_edge( &mut self, handle: Handle, - range: RangeOnPath, + range: BoundaryOnCurve, approx: GlobalEdgeApprox, ) -> GlobalEdgeApprox { self.edge_approx @@ -303,7 +303,7 @@ mod tests { use pretty_assertions::assert_eq; use crate::{ - algorithms::approx::{path::RangeOnPath, Approx, ApproxPoint}, + algorithms::approx::{path::BoundaryOnCurve, Approx, ApproxPoint}, geometry::{GlobalPath, SurfaceGeometry}, objects::{HalfEdge, Surface}, operations::BuildHalfEdge, @@ -346,7 +346,7 @@ mod tests { let mut services = Services::new(); let path = GlobalPath::circle_from_radius(1.); - let range = RangeOnPath::from([[0.], [TAU]]); + let range = BoundaryOnCurve::from([[0.], [TAU]]); let surface = Surface::new(SurfaceGeometry { u: path, @@ -386,7 +386,7 @@ mod tests { let approx = (&half_edge, surface.deref()).approx(tolerance); let expected_approx = - (&half_edge.path(), RangeOnPath::from([[0.], [TAU]])) + (&half_edge.path(), BoundaryOnCurve::from([[0.], [TAU]])) .approx(tolerance) .into_iter() .map(|(_, point_surface)| { diff --git a/crates/fj-core/src/algorithms/approx/path.rs b/crates/fj-core/src/algorithms/approx/path.rs index 981bad08a..fec75b7f1 100644 --- a/crates/fj-core/src/algorithms/approx/path.rs +++ b/crates/fj-core/src/algorithms/approx/path.rs @@ -36,7 +36,7 @@ use crate::geometry::{GlobalPath, SurfacePath}; use super::{Approx, Tolerance}; -impl Approx for (&SurfacePath, RangeOnPath) { +impl Approx for (&SurfacePath, BoundaryOnCurve) { type Approximation = Vec<(Point<1>, Point<2>)>; type Cache = (); @@ -56,7 +56,7 @@ impl Approx for (&SurfacePath, RangeOnPath) { } } -impl Approx for (GlobalPath, RangeOnPath) { +impl Approx for (GlobalPath, BoundaryOnCurve) { type Approximation = Vec<(Point<1>, Point<3>)>; type Cache = (); @@ -78,12 +78,12 @@ impl Approx for (GlobalPath, RangeOnPath) { /// The range on which a path should be approximated #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] -pub struct RangeOnPath { +pub struct BoundaryOnCurve { /// The boundary of the range pub boundary: [Point<1>; 2], } -impl RangeOnPath { +impl BoundaryOnCurve { /// Reverse the direction of the range pub fn reverse(self) -> Self { let [a, b] = self.boundary; @@ -91,7 +91,7 @@ impl RangeOnPath { } } -impl From<[T; 2]> for RangeOnPath +impl From<[T; 2]> for BoundaryOnCurve where T: Into>, { @@ -107,7 +107,7 @@ where /// from the circle. fn approx_circle( circle: &Circle, - range: impl Into, + range: impl Into, tolerance: Tolerance, ) -> Vec<(Point<1>, Point)> { let range = range.into(); @@ -152,7 +152,7 @@ impl PathApproxParams { pub fn points( &self, - range: impl Into, + range: impl Into, ) -> impl Iterator> + '_ { let range = range.into(); @@ -195,7 +195,7 @@ mod tests { use fj_math::{Circle, Point, Scalar}; - use crate::algorithms::approx::{path::RangeOnPath, Tolerance}; + use crate::algorithms::approx::{path::BoundaryOnCurve, Tolerance}; use super::PathApproxParams; @@ -245,7 +245,7 @@ mod tests { test_path([[TAU - 2.], [0.]], [2., 1.]); fn test_path( - range: impl Into, + range: impl Into, expected_coords: impl IntoIterator>, ) { // Choose radius and tolerance such, that we need 4 vertices to From 46bb8c73ac5291b6192137a5c06787f68d5b4618 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:02:53 +0200 Subject: [PATCH 02/24] Update variable name --- crates/fj-core/src/algorithms/approx/edge.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/edge.rs b/crates/fj-core/src/algorithms/approx/edge.rs index bdce2d8aa..a19e24c97 100644 --- a/crates/fj-core/src/algorithms/approx/edge.rs +++ b/crates/fj-core/src/algorithms/approx/edge.rs @@ -29,7 +29,7 @@ impl Approx for (&HalfEdge, &Surface) { let (half_edge, surface) = self; let boundary = half_edge.boundary(); - let range = BoundaryOnCurve { boundary }; + let boundary = BoundaryOnCurve { boundary }; let position_surface = half_edge.start_position(); let position_global = match cache.get_position(half_edge.start_vertex()) @@ -88,19 +88,19 @@ impl Approx for (&HalfEdge, &Surface) { // Only item 2. is something we can do right here. Item 1. requires // a change to the object graph. let cached_approx = - cache.get_edge(half_edge.global_form().clone(), range); + cache.get_edge(half_edge.global_form().clone(), boundary); let approx = match cached_approx { Some(approx) => approx, None => { let approx = approx_edge( &half_edge.path(), surface, - range, + boundary, tolerance, ); cache.insert_edge( half_edge.global_form().clone(), - range, + boundary, approx, ) } From 34d4aaa78e698fd8c87b242261efcf550dd58c8c Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:03:11 +0200 Subject: [PATCH 03/24] Inline redundant variable --- crates/fj-core/src/algorithms/approx/edge.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/edge.rs b/crates/fj-core/src/algorithms/approx/edge.rs index a19e24c97..0e786bc97 100644 --- a/crates/fj-core/src/algorithms/approx/edge.rs +++ b/crates/fj-core/src/algorithms/approx/edge.rs @@ -28,8 +28,9 @@ impl Approx for (&HalfEdge, &Surface) { ) -> Self::Approximation { let (half_edge, surface) = self; - let boundary = half_edge.boundary(); - let boundary = BoundaryOnCurve { boundary }; + let boundary = BoundaryOnCurve { + boundary: half_edge.boundary(), + }; let position_surface = half_edge.start_position(); let position_global = match cache.get_position(half_edge.start_vertex()) From 60292a2eddf96001f7af6f65a16a21e996d82d3b Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:03:48 +0200 Subject: [PATCH 04/24] Update argument name --- crates/fj-core/src/algorithms/approx/edge.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/edge.rs b/crates/fj-core/src/algorithms/approx/edge.rs index 0e786bc97..fb2cc7e5f 100644 --- a/crates/fj-core/src/algorithms/approx/edge.rs +++ b/crates/fj-core/src/algorithms/approx/edge.rs @@ -149,7 +149,7 @@ impl HalfEdgeApprox { fn approx_edge( path: &SurfacePath, surface: &Surface, - range: BoundaryOnCurve, + boundary: BoundaryOnCurve, tolerance: impl Into, ) -> GlobalEdgeApprox { // There are different cases of varying complexity. Circles are the hard @@ -165,7 +165,7 @@ fn approx_edge( ) } (SurfacePath::Circle(_), GlobalPath::Line(_)) => { - (path, range) + (path, boundary) .approx_with_cache(tolerance, &mut ()) .into_iter() .map(|(point_curve, point_surface)| { @@ -193,7 +193,7 @@ fn approx_edge( } (SurfacePath::Line(line), _) => { let range_u = - BoundaryOnCurve::from(range.boundary.map(|point_curve| { + BoundaryOnCurve::from(boundary.boundary.map(|point_curve| { [path.point_from_path_coords(point_curve).u] })); From 548b0e1b57e9587c0f35efdb1ea5fd8eebd9677c Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:04:18 +0200 Subject: [PATCH 05/24] Update argument name --- crates/fj-core/src/algorithms/approx/edge.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/edge.rs b/crates/fj-core/src/algorithms/approx/edge.rs index fb2cc7e5f..355fec37c 100644 --- a/crates/fj-core/src/algorithms/approx/edge.rs +++ b/crates/fj-core/src/algorithms/approx/edge.rs @@ -239,13 +239,13 @@ impl EdgeCache { pub fn get_edge( &self, handle: Handle, - range: BoundaryOnCurve, + boundary: BoundaryOnCurve, ) -> Option { - if let Some(approx) = self.edge_approx.get(&(handle.id(), range)) { + if let Some(approx) = self.edge_approx.get(&(handle.id(), boundary)) { return Some(approx.clone()); } if let Some(approx) = - self.edge_approx.get(&(handle.id(), range.reverse())) + self.edge_approx.get(&(handle.id(), boundary.reverse())) { // If we have a cache entry for the reverse range, we need to use // that too! From 3bdaf6455afc70c0ae88c5c5a32beda4cf061c7f Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:04:37 +0200 Subject: [PATCH 06/24] Update word in comment --- crates/fj-core/src/algorithms/approx/edge.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-core/src/algorithms/approx/edge.rs b/crates/fj-core/src/algorithms/approx/edge.rs index 355fec37c..53dddda81 100644 --- a/crates/fj-core/src/algorithms/approx/edge.rs +++ b/crates/fj-core/src/algorithms/approx/edge.rs @@ -247,7 +247,7 @@ impl EdgeCache { if let Some(approx) = self.edge_approx.get(&(handle.id(), boundary.reverse())) { - // If we have a cache entry for the reverse range, we need to use + // If we have a cache entry for the reverse boundary, we need to use // that too! return Some(approx.clone().reverse()); } From 24dd5f778ea6d82d88b67fd8ef2727aa81050c1d Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:05:48 +0200 Subject: [PATCH 07/24] Update argument name --- crates/fj-core/src/algorithms/approx/edge.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/edge.rs b/crates/fj-core/src/algorithms/approx/edge.rs index 53dddda81..c5af84c3a 100644 --- a/crates/fj-core/src/algorithms/approx/edge.rs +++ b/crates/fj-core/src/algorithms/approx/edge.rs @@ -259,11 +259,11 @@ impl EdgeCache { pub fn insert_edge( &mut self, handle: Handle, - range: BoundaryOnCurve, + boundary: BoundaryOnCurve, approx: GlobalEdgeApprox, ) -> GlobalEdgeApprox { self.edge_approx - .insert((handle.id(), range), approx.clone()) + .insert((handle.id(), boundary), approx.clone()) .unwrap_or(approx) } From d22aaef28cd1211435d984c8c1ac8eb44dbcd319 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:06:21 +0200 Subject: [PATCH 08/24] Update variable name --- crates/fj-core/src/algorithms/approx/edge.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/edge.rs b/crates/fj-core/src/algorithms/approx/edge.rs index c5af84c3a..b53f2b8cb 100644 --- a/crates/fj-core/src/algorithms/approx/edge.rs +++ b/crates/fj-core/src/algorithms/approx/edge.rs @@ -347,7 +347,7 @@ mod tests { let mut services = Services::new(); let path = GlobalPath::circle_from_radius(1.); - let range = BoundaryOnCurve::from([[0.], [TAU]]); + let boundary = BoundaryOnCurve::from([[0.], [TAU]]); let surface = Surface::new(SurfaceGeometry { u: path, @@ -355,14 +355,14 @@ mod tests { }); let half_edge = HalfEdge::line_segment( [[0., 1.], [TAU, 1.]], - Some(range.boundary), + Some(boundary.boundary), &mut services, ); let tolerance = 1.; let approx = (&half_edge, &surface).approx(tolerance); - let expected_approx = (path, range) + let expected_approx = (path, boundary) .approx(tolerance) .into_iter() .map(|(point_local, _)| { From b82266c271892c3814498a2c1f8bbfa72126e9ab Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:06:56 +0200 Subject: [PATCH 09/24] Update argument name --- crates/fj-core/src/algorithms/approx/path.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/path.rs b/crates/fj-core/src/algorithms/approx/path.rs index fec75b7f1..0a71f2bb5 100644 --- a/crates/fj-core/src/algorithms/approx/path.rs +++ b/crates/fj-core/src/algorithms/approx/path.rs @@ -107,10 +107,10 @@ where /// from the circle. fn approx_circle( circle: &Circle, - range: impl Into, + boundary: impl Into, tolerance: Tolerance, ) -> Vec<(Point<1>, Point)> { - let range = range.into(); + let range = boundary.into(); let params = PathApproxParams::for_circle(circle, tolerance); let mut points = Vec::new(); From 3d71d4d0a785dc836a7479e7447a965cac306826 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:07:31 +0200 Subject: [PATCH 10/24] Update variable name --- crates/fj-core/src/algorithms/approx/path.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/path.rs b/crates/fj-core/src/algorithms/approx/path.rs index 0a71f2bb5..222b5a6c6 100644 --- a/crates/fj-core/src/algorithms/approx/path.rs +++ b/crates/fj-core/src/algorithms/approx/path.rs @@ -110,12 +110,12 @@ fn approx_circle( boundary: impl Into, tolerance: Tolerance, ) -> Vec<(Point<1>, Point)> { - let range = boundary.into(); + let boundary = boundary.into(); let params = PathApproxParams::for_circle(circle, tolerance); let mut points = Vec::new(); - for point_curve in params.points(range) { + for point_curve in params.points(boundary) { let point_global = circle.point_from_circle_coords(point_curve); points.push((point_curve, point_global)); } From c6599ad7bf945981240b1ce3ac1b7358f1c1a983 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:08:00 +0200 Subject: [PATCH 11/24] Update argument name --- crates/fj-core/src/algorithms/approx/path.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/path.rs b/crates/fj-core/src/algorithms/approx/path.rs index 222b5a6c6..0a957972a 100644 --- a/crates/fj-core/src/algorithms/approx/path.rs +++ b/crates/fj-core/src/algorithms/approx/path.rs @@ -152,9 +152,9 @@ impl PathApproxParams { pub fn points( &self, - range: impl Into, + boundary: impl Into, ) -> impl Iterator> + '_ { - let range = range.into(); + let range = boundary.into(); let [a, b] = range.boundary.map(|point| point.t / self.increment()); let direction = (b - a).sign(); From d0f3cc105576210253f2799ae5acc9a525344fc2 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:08:20 +0200 Subject: [PATCH 12/24] Update variable name --- crates/fj-core/src/algorithms/approx/path.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/path.rs b/crates/fj-core/src/algorithms/approx/path.rs index 0a957972a..977c45ba8 100644 --- a/crates/fj-core/src/algorithms/approx/path.rs +++ b/crates/fj-core/src/algorithms/approx/path.rs @@ -154,9 +154,9 @@ impl PathApproxParams { &self, boundary: impl Into, ) -> impl Iterator> + '_ { - let range = boundary.into(); + let boundary = boundary.into(); - let [a, b] = range.boundary.map(|point| point.t / self.increment()); + let [a, b] = boundary.boundary.map(|point| point.t / self.increment()); let direction = (b - a).sign(); let [min, max] = if a < b { [a, b] } else { [b, a] }; From f87de6d001385bcbe4afb0764f8cb1059cd03416 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:08:43 +0200 Subject: [PATCH 13/24] Update argument name --- crates/fj-core/src/algorithms/approx/path.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/path.rs b/crates/fj-core/src/algorithms/approx/path.rs index 977c45ba8..fd8212b2e 100644 --- a/crates/fj-core/src/algorithms/approx/path.rs +++ b/crates/fj-core/src/algorithms/approx/path.rs @@ -245,7 +245,7 @@ mod tests { test_path([[TAU - 2.], [0.]], [2., 1.]); fn test_path( - range: impl Into, + boundary: impl Into, expected_coords: impl IntoIterator>, ) { // Choose radius and tolerance such, that we need 4 vertices to @@ -257,7 +257,7 @@ mod tests { let circle = Circle::from_center_and_radius([0., 0.], radius); let params = PathApproxParams::for_circle(&circle, tolerance); - let points = params.points(range).collect::>(); + let points = params.points(boundary).collect::>(); let expected_points = expected_coords .into_iter() From bee1de658603f0bf31bec4b1f2fb9612f39818a7 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:10:13 +0200 Subject: [PATCH 14/24] Update struct field name --- crates/fj-core/src/algorithms/approx/edge.rs | 6 +++--- crates/fj-core/src/algorithms/approx/path.rs | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/edge.rs b/crates/fj-core/src/algorithms/approx/edge.rs index b53f2b8cb..e69ada459 100644 --- a/crates/fj-core/src/algorithms/approx/edge.rs +++ b/crates/fj-core/src/algorithms/approx/edge.rs @@ -29,7 +29,7 @@ impl Approx for (&HalfEdge, &Surface) { let (half_edge, surface) = self; let boundary = BoundaryOnCurve { - boundary: half_edge.boundary(), + inner: half_edge.boundary(), }; let position_surface = half_edge.start_position(); @@ -193,7 +193,7 @@ fn approx_edge( } (SurfacePath::Line(line), _) => { let range_u = - BoundaryOnCurve::from(boundary.boundary.map(|point_curve| { + BoundaryOnCurve::from(boundary.inner.map(|point_curve| { [path.point_from_path_coords(point_curve).u] })); @@ -355,7 +355,7 @@ mod tests { }); let half_edge = HalfEdge::line_segment( [[0., 1.], [TAU, 1.]], - Some(boundary.boundary), + Some(boundary.inner), &mut services, ); diff --git a/crates/fj-core/src/algorithms/approx/path.rs b/crates/fj-core/src/algorithms/approx/path.rs index fd8212b2e..74cc68b82 100644 --- a/crates/fj-core/src/algorithms/approx/path.rs +++ b/crates/fj-core/src/algorithms/approx/path.rs @@ -80,14 +80,14 @@ impl Approx for (GlobalPath, BoundaryOnCurve) { #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] pub struct BoundaryOnCurve { /// The boundary of the range - pub boundary: [Point<1>; 2], + pub inner: [Point<1>; 2], } impl BoundaryOnCurve { /// Reverse the direction of the range pub fn reverse(self) -> Self { - let [a, b] = self.boundary; - Self { boundary: [b, a] } + let [a, b] = self.inner; + Self { inner: [b, a] } } } @@ -96,8 +96,8 @@ where T: Into>, { fn from(boundary: [T; 2]) -> Self { - let boundary = boundary.map(Into::into); - Self { boundary } + let inner = boundary.map(Into::into); + Self { inner } } } @@ -156,7 +156,7 @@ impl PathApproxParams { ) -> impl Iterator> + '_ { let boundary = boundary.into(); - let [a, b] = boundary.boundary.map(|point| point.t / self.increment()); + let [a, b] = boundary.inner.map(|point| point.t / self.increment()); let direction = (b - a).sign(); let [min, max] = if a < b { [a, b] } else { [b, a] }; From b5235cacc3f6de5c3a95d6c75c9af04995036848 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:11:22 +0200 Subject: [PATCH 15/24] Update documentation of `BoundaryOnCurve` --- crates/fj-core/src/algorithms/approx/path.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/path.rs b/crates/fj-core/src/algorithms/approx/path.rs index 74cc68b82..55d9bb8f1 100644 --- a/crates/fj-core/src/algorithms/approx/path.rs +++ b/crates/fj-core/src/algorithms/approx/path.rs @@ -76,15 +76,15 @@ impl Approx for (GlobalPath, BoundaryOnCurve) { } } -/// The range on which a path should be approximated +/// A boundary on a curve #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] pub struct BoundaryOnCurve { - /// The boundary of the range + /// The raw representation of the boundary pub inner: [Point<1>; 2], } impl BoundaryOnCurve { - /// Reverse the direction of the range + /// Reverse the direction of the boundary pub fn reverse(self) -> Self { let [a, b] = self.inner; Self { inner: [b, a] } From e3e86d216ce7688d1679fe46a9920f521f3d833d Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:14:06 +0200 Subject: [PATCH 16/24] Move `BoundaryOnCurve` to `geometry` I'd like to use it outside of the approximation code. --- crates/fj-core/src/algorithms/approx/edge.rs | 8 +++--- crates/fj-core/src/algorithms/approx/path.rs | 27 +------------------- crates/fj-core/src/geometry/boundary.rs | 26 +++++++++++++++++++ crates/fj-core/src/geometry/mod.rs | 2 ++ 4 files changed, 33 insertions(+), 30 deletions(-) create mode 100644 crates/fj-core/src/geometry/boundary.rs diff --git a/crates/fj-core/src/algorithms/approx/edge.rs b/crates/fj-core/src/algorithms/approx/edge.rs index e69ada459..8ca4c8f25 100644 --- a/crates/fj-core/src/algorithms/approx/edge.rs +++ b/crates/fj-core/src/algorithms/approx/edge.rs @@ -10,12 +10,12 @@ use std::collections::BTreeMap; use fj_math::Point; use crate::{ - geometry::{GlobalPath, SurfacePath}, + geometry::{BoundaryOnCurve, GlobalPath, SurfacePath}, objects::{GlobalEdge, HalfEdge, Surface, Vertex}, storage::{Handle, ObjectId}, }; -use super::{path::BoundaryOnCurve, Approx, ApproxPoint, Tolerance}; +use super::{Approx, ApproxPoint, Tolerance}; impl Approx for (&HalfEdge, &Surface) { type Approximation = HalfEdgeApprox; @@ -304,8 +304,8 @@ mod tests { use pretty_assertions::assert_eq; use crate::{ - algorithms::approx::{path::BoundaryOnCurve, Approx, ApproxPoint}, - geometry::{GlobalPath, SurfaceGeometry}, + algorithms::approx::{Approx, ApproxPoint}, + geometry::{BoundaryOnCurve, GlobalPath, SurfaceGeometry}, objects::{HalfEdge, Surface}, operations::BuildHalfEdge, services::Services, diff --git a/crates/fj-core/src/algorithms/approx/path.rs b/crates/fj-core/src/algorithms/approx/path.rs index 55d9bb8f1..b06415248 100644 --- a/crates/fj-core/src/algorithms/approx/path.rs +++ b/crates/fj-core/src/algorithms/approx/path.rs @@ -32,7 +32,7 @@ use std::iter; use fj_math::{Circle, Point, Scalar, Sign}; -use crate::geometry::{GlobalPath, SurfacePath}; +use crate::geometry::{BoundaryOnCurve, GlobalPath, SurfacePath}; use super::{Approx, Tolerance}; @@ -76,31 +76,6 @@ impl Approx for (GlobalPath, BoundaryOnCurve) { } } -/// A boundary on a curve -#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] -pub struct BoundaryOnCurve { - /// The raw representation of the boundary - pub inner: [Point<1>; 2], -} - -impl BoundaryOnCurve { - /// Reverse the direction of the boundary - pub fn reverse(self) -> Self { - let [a, b] = self.inner; - Self { inner: [b, a] } - } -} - -impl From<[T; 2]> for BoundaryOnCurve -where - T: Into>, -{ - fn from(boundary: [T; 2]) -> Self { - let inner = boundary.map(Into::into); - Self { inner } - } -} - /// Approximate a circle /// /// `tolerance` specifies how much the approximation is allowed to deviate diff --git a/crates/fj-core/src/geometry/boundary.rs b/crates/fj-core/src/geometry/boundary.rs new file mode 100644 index 000000000..b03504491 --- /dev/null +++ b/crates/fj-core/src/geometry/boundary.rs @@ -0,0 +1,26 @@ +use fj_math::Point; + +/// A boundary on a curve +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] +pub struct BoundaryOnCurve { + /// The raw representation of the boundary + pub inner: [Point<1>; 2], +} + +impl BoundaryOnCurve { + /// Reverse the direction of the boundary + pub fn reverse(self) -> Self { + let [a, b] = self.inner; + Self { inner: [b, a] } + } +} + +impl From<[T; 2]> for BoundaryOnCurve +where + T: Into>, +{ + fn from(boundary: [T; 2]) -> Self { + let inner = boundary.map(Into::into); + Self { inner } + } +} diff --git a/crates/fj-core/src/geometry/mod.rs b/crates/fj-core/src/geometry/mod.rs index 45dca87b6..cb5a1cb36 100644 --- a/crates/fj-core/src/geometry/mod.rs +++ b/crates/fj-core/src/geometry/mod.rs @@ -1,9 +1,11 @@ //! Types that are tied to objects, but aren't objects themselves +mod boundary; mod path; mod surface; pub use self::{ + boundary::BoundaryOnCurve, path::{GlobalPath, SurfacePath}, surface::SurfaceGeometry, }; From dc5421e99cb3eefdfa0625155daa6e5c4d9c518e Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:15:36 +0200 Subject: [PATCH 17/24] Derive `Hash` for `BoundaryOnCurve` --- crates/fj-core/src/geometry/boundary.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-core/src/geometry/boundary.rs b/crates/fj-core/src/geometry/boundary.rs index b03504491..c38a02563 100644 --- a/crates/fj-core/src/geometry/boundary.rs +++ b/crates/fj-core/src/geometry/boundary.rs @@ -1,7 +1,7 @@ use fj_math::Point; /// A boundary on a curve -#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] pub struct BoundaryOnCurve { /// The raw representation of the boundary pub inner: [Point<1>; 2], From e35456de4868f4fefba478b3026980abddfaf0cc Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:17:07 +0200 Subject: [PATCH 18/24] Use `BoundaryOnCurve` in `HalfEdge` --- crates/fj-core/src/objects/kinds/edge.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/fj-core/src/objects/kinds/edge.rs b/crates/fj-core/src/objects/kinds/edge.rs index d174ce009..b675f6cc7 100644 --- a/crates/fj-core/src/objects/kinds/edge.rs +++ b/crates/fj-core/src/objects/kinds/edge.rs @@ -1,7 +1,7 @@ use fj_math::Point; use crate::{ - geometry::SurfacePath, + geometry::{BoundaryOnCurve, SurfacePath}, objects::Vertex, storage::{Handle, HandleWrapper}, }; @@ -41,7 +41,7 @@ use crate::{ #[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] pub struct HalfEdge { path: SurfacePath, - boundary: [Point<1>; 2], + boundary: BoundaryOnCurve, start_vertex: HandleWrapper, global_form: HandleWrapper, } @@ -50,13 +50,13 @@ impl HalfEdge { /// Create an instance of `HalfEdge` pub fn new( path: SurfacePath, - boundary: [Point<1>; 2], + boundary: impl Into, start_vertex: Handle, global_form: Handle, ) -> Self { Self { path, - boundary, + boundary: boundary.into(), start_vertex: start_vertex.into(), global_form: global_form.into(), } @@ -69,7 +69,7 @@ impl HalfEdge { /// Access the boundary points of the half-edge on the curve pub fn boundary(&self) -> [Point<1>; 2] { - self.boundary + self.boundary.inner } /// Compute the surface position where the half-edge starts @@ -78,7 +78,7 @@ impl HalfEdge { // `HalfEdge` "owns" its start position. There is no competing code that // could compute the surface position from slightly different data. - let [start, _] = self.boundary; + let [start, _] = self.boundary.inner; self.path.point_from_path_coords(start) } From 483cbcedd193651c1497c8bab6d7f61c76598329 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:20:33 +0200 Subject: [PATCH 19/24] Refactor to prepare for follow-on change --- crates/fj-core/src/validate/shell.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index 5e42e65f1..cdf47dae3 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -73,8 +73,8 @@ fn distances( percent: f64, (edge, surface): (&Handle, SurfaceGeometry), ) -> Point<3> { - let boundary = edge.boundary(); - let path_coords = boundary[0] + (boundary[1] - boundary[0]) * percent; + let [start, end] = edge.boundary(); + let path_coords = start + (end - start) * percent; let surface_coords = edge.path().point_from_path_coords(path_coords); surface.point_from_surface_coords(surface_coords) } From 6e46b97f0e961ed674ed400549bd283199daf374 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:21:23 +0200 Subject: [PATCH 20/24] Return `BoundaryOnCurve` from `HalfEdge::boundary` --- crates/fj-core/src/algorithms/approx/edge.rs | 4 +--- crates/fj-core/src/algorithms/bounding_volume/edge.rs | 2 +- crates/fj-core/src/algorithms/intersect/curve_edge.rs | 1 + crates/fj-core/src/algorithms/intersect/ray_edge.rs | 1 + crates/fj-core/src/algorithms/sweep/edge.rs | 4 ++-- crates/fj-core/src/algorithms/sweep/face.rs | 2 +- crates/fj-core/src/objects/kinds/cycle.rs | 2 +- crates/fj-core/src/objects/kinds/edge.rs | 4 ++-- crates/fj-core/src/operations/reverse/cycle.rs | 2 +- crates/fj-core/src/validate/cycle.rs | 2 +- crates/fj-core/src/validate/edge.rs | 2 +- crates/fj-core/src/validate/shell.rs | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/edge.rs b/crates/fj-core/src/algorithms/approx/edge.rs index 8ca4c8f25..a6ef669f4 100644 --- a/crates/fj-core/src/algorithms/approx/edge.rs +++ b/crates/fj-core/src/algorithms/approx/edge.rs @@ -28,9 +28,7 @@ impl Approx for (&HalfEdge, &Surface) { ) -> Self::Approximation { let (half_edge, surface) = self; - let boundary = BoundaryOnCurve { - inner: half_edge.boundary(), - }; + let boundary = half_edge.boundary(); let position_surface = half_edge.start_position(); let position_global = match cache.get_position(half_edge.start_vertex()) diff --git a/crates/fj-core/src/algorithms/bounding_volume/edge.rs b/crates/fj-core/src/algorithms/bounding_volume/edge.rs index ceea6bf9a..50be621af 100644 --- a/crates/fj-core/src/algorithms/bounding_volume/edge.rs +++ b/crates/fj-core/src/algorithms/bounding_volume/edge.rs @@ -18,7 +18,7 @@ impl super::BoundingVolume<2> for HalfEdge { }) } SurfacePath::Line(_) => { - let points = self.boundary().map(|point_curve| { + let points = self.boundary().inner.map(|point_curve| { self.path().point_from_path_coords(point_curve) }); diff --git a/crates/fj-core/src/algorithms/intersect/curve_edge.rs b/crates/fj-core/src/algorithms/intersect/curve_edge.rs index e5678a330..934b79fe9 100644 --- a/crates/fj-core/src/algorithms/intersect/curve_edge.rs +++ b/crates/fj-core/src/algorithms/intersect/curve_edge.rs @@ -44,6 +44,7 @@ impl CurveEdgeIntersection { let edge_vertices = half_edge .boundary() + .inner .map(|point| edge_path_as_line.point_from_line_coords(point)); Segment::from_points(edge_vertices) diff --git a/crates/fj-core/src/algorithms/intersect/ray_edge.rs b/crates/fj-core/src/algorithms/intersect/ray_edge.rs index 5c5311d26..dab988e9d 100644 --- a/crates/fj-core/src/algorithms/intersect/ray_edge.rs +++ b/crates/fj-core/src/algorithms/intersect/ray_edge.rs @@ -26,6 +26,7 @@ impl Intersect for (&HorizontalRayToTheRight<2>, &Handle) { let points = edge .boundary() + .inner .map(|point| line.point_from_line_coords(point)); let segment = Segment::from_points(points); diff --git a/crates/fj-core/src/algorithms/sweep/edge.rs b/crates/fj-core/src/algorithms/sweep/edge.rs index d0510fe4b..929011469 100644 --- a/crates/fj-core/src/algorithms/sweep/edge.rs +++ b/crates/fj-core/src/algorithms/sweep/edge.rs @@ -47,7 +47,7 @@ impl Sweep for (&HalfEdge, &Handle, &Surface, Option) { // Let's figure out the surface coordinates of the edge vertices. let surface_points = { - let [a, b] = edge.boundary(); + let [a, b] = edge.boundary().inner; [ [a.t, Scalar::ZERO], @@ -65,7 +65,7 @@ impl Sweep for (&HalfEdge, &Handle, &Surface, Option) { // Now, the boundaries of each edge. let boundaries = { - let [a, b] = edge.boundary(); + let [a, b] = edge.boundary().inner; let [c, d] = [0., 1.].map(|coord| Point::from([coord])); [[a, b], [c, d], [b, a], [d, c]] diff --git a/crates/fj-core/src/algorithms/sweep/face.rs b/crates/fj-core/src/algorithms/sweep/face.rs index 4eb6c2ad3..29578450d 100644 --- a/crates/fj-core/src/algorithms/sweep/face.rs +++ b/crates/fj-core/src/algorithms/sweep/face.rs @@ -75,7 +75,7 @@ impl Sweep for Handle { top_edges.push(( top_edge, half_edge.path(), - half_edge.boundary(), + half_edge.boundary().inner, )); } diff --git a/crates/fj-core/src/objects/kinds/cycle.rs b/crates/fj-core/src/objects/kinds/cycle.rs index 61b9f401e..bc7558307 100644 --- a/crates/fj-core/src/objects/kinds/cycle.rs +++ b/crates/fj-core/src/objects/kinds/cycle.rs @@ -82,7 +82,7 @@ impl Cycle { .next() .expect("Invalid cycle: expected at least one half-edge"); - let [a, b] = first.boundary(); + let [a, b] = first.boundary().inner; let edge_direction_positive = a < b; let circle = match first.path() { diff --git a/crates/fj-core/src/objects/kinds/edge.rs b/crates/fj-core/src/objects/kinds/edge.rs index b675f6cc7..5154fd799 100644 --- a/crates/fj-core/src/objects/kinds/edge.rs +++ b/crates/fj-core/src/objects/kinds/edge.rs @@ -68,8 +68,8 @@ impl HalfEdge { } /// Access the boundary points of the half-edge on the curve - pub fn boundary(&self) -> [Point<1>; 2] { - self.boundary.inner + pub fn boundary(&self) -> BoundaryOnCurve { + self.boundary } /// Compute the surface position where the half-edge starts diff --git a/crates/fj-core/src/operations/reverse/cycle.rs b/crates/fj-core/src/operations/reverse/cycle.rs index 1f71c845a..5545b550f 100644 --- a/crates/fj-core/src/operations/reverse/cycle.rs +++ b/crates/fj-core/src/operations/reverse/cycle.rs @@ -12,7 +12,7 @@ impl Reverse for Cycle { .half_edge_pairs() .map(|(current, next)| { let boundary = { - let [a, b] = current.boundary(); + let [a, b] = current.boundary().inner; [b, a] }; diff --git a/crates/fj-core/src/validate/cycle.rs b/crates/fj-core/src/validate/cycle.rs index 9aa5852a4..a837c8843 100644 --- a/crates/fj-core/src/validate/cycle.rs +++ b/crates/fj-core/src/validate/cycle.rs @@ -65,7 +65,7 @@ impl CycleValidationError { ) { for (first, second) in cycle.half_edge_pairs() { let end_of_first = { - let [_, end] = first.boundary(); + let [_, end] = first.boundary().inner; first.path().point_from_path_coords(end) }; let start_of_second = second.start_position(); diff --git a/crates/fj-core/src/validate/edge.rs b/crates/fj-core/src/validate/edge.rs index 3b4efbf2e..9516664b6 100644 --- a/crates/fj-core/src/validate/edge.rs +++ b/crates/fj-core/src/validate/edge.rs @@ -54,7 +54,7 @@ impl HalfEdgeValidationError { config: &ValidationConfig, errors: &mut Vec, ) { - let [back_position, front_position] = half_edge.boundary(); + let [back_position, front_position] = half_edge.boundary().inner; let distance = (back_position - front_position).magnitude(); if distance < config.distinct_min_distance { diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index cdf47dae3..c324f24d4 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -73,7 +73,7 @@ fn distances( percent: f64, (edge, surface): (&Handle, SurfaceGeometry), ) -> Point<3> { - let [start, end] = edge.boundary(); + let [start, end] = edge.boundary().inner; let path_coords = start + (end - start) * percent; let surface_coords = edge.path().point_from_path_coords(path_coords); surface.point_from_surface_coords(surface_coords) From 5b0e7360a9ac77cc549839939e6011ecf16d4ca9 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:22:26 +0200 Subject: [PATCH 21/24] Inline redundant variable --- crates/fj-core/src/algorithms/approx/edge.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/edge.rs b/crates/fj-core/src/algorithms/approx/edge.rs index a6ef669f4..e8d4c5f0b 100644 --- a/crates/fj-core/src/algorithms/approx/edge.rs +++ b/crates/fj-core/src/algorithms/approx/edge.rs @@ -28,8 +28,6 @@ impl Approx for (&HalfEdge, &Surface) { ) -> Self::Approximation { let (half_edge, surface) = self; - let boundary = half_edge.boundary(); - let position_surface = half_edge.start_position(); let position_global = match cache.get_position(half_edge.start_vertex()) { @@ -86,20 +84,22 @@ impl Approx for (&HalfEdge, &Surface) { // // Only item 2. is something we can do right here. Item 1. requires // a change to the object graph. - let cached_approx = - cache.get_edge(half_edge.global_form().clone(), boundary); + let cached_approx = cache.get_edge( + half_edge.global_form().clone(), + half_edge.boundary(), + ); let approx = match cached_approx { Some(approx) => approx, None => { let approx = approx_edge( &half_edge.path(), surface, - boundary, + half_edge.boundary(), tolerance, ); cache.insert_edge( half_edge.global_form().clone(), - boundary, + half_edge.boundary(), approx, ) } From a0e2190b37e0fcdf27e66a2957e7a8475d950a96 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:23:51 +0200 Subject: [PATCH 22/24] Make more use of `BoundaryOnCurve` --- crates/fj-core/src/algorithms/sweep/face.rs | 2 +- crates/fj-core/src/operations/join/cycle.rs | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/fj-core/src/algorithms/sweep/face.rs b/crates/fj-core/src/algorithms/sweep/face.rs index 29578450d..4eb6c2ad3 100644 --- a/crates/fj-core/src/algorithms/sweep/face.rs +++ b/crates/fj-core/src/algorithms/sweep/face.rs @@ -75,7 +75,7 @@ impl Sweep for Handle { top_edges.push(( top_edge, half_edge.path(), - half_edge.boundary().inner, + half_edge.boundary(), )); } diff --git a/crates/fj-core/src/operations/join/cycle.rs b/crates/fj-core/src/operations/join/cycle.rs index e630c6d3c..e59c25d42 100644 --- a/crates/fj-core/src/operations/join/cycle.rs +++ b/crates/fj-core/src/operations/join/cycle.rs @@ -1,10 +1,9 @@ use std::ops::RangeInclusive; -use fj_math::Point; use itertools::Itertools; use crate::{ - geometry::SurfacePath, + geometry::{BoundaryOnCurve, SurfacePath}, objects::{Cycle, HalfEdge}, operations::{BuildHalfEdge, Insert, UpdateCycle, UpdateHalfEdge}, services::Services, @@ -17,7 +16,9 @@ pub trait JoinCycle { #[must_use] fn add_joined_edges(&self, edges: Es, services: &mut Services) -> Self where - Es: IntoIterator, SurfacePath, [Point<1>; 2])>, + Es: IntoIterator< + Item = (Handle, SurfacePath, BoundaryOnCurve), + >, Es::IntoIter: Clone + ExactSizeIterator; /// Join the cycle to another @@ -62,12 +63,14 @@ pub trait JoinCycle { impl JoinCycle for Cycle { fn add_joined_edges(&self, edges: Es, services: &mut Services) -> Self where - Es: IntoIterator, SurfacePath, [Point<1>; 2])>, + Es: IntoIterator< + Item = (Handle, SurfacePath, BoundaryOnCurve), + >, Es::IntoIter: Clone + ExactSizeIterator, { self.add_half_edges(edges.into_iter().circular_tuple_windows().map( |((prev, _, _), (half_edge, curve, boundary))| { - HalfEdge::unjoined(curve, boundary, services) + HalfEdge::unjoined(curve, boundary.inner, services) .replace_start_vertex(prev.start_vertex().clone()) .replace_global_form(half_edge.global_form().clone()) .insert(services) From 0e3c7161798b4f7558e129a7465c06adbbb47ea3 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:24:49 +0200 Subject: [PATCH 23/24] Make more use of `BoundaryOnCurve` --- crates/fj-core/src/operations/build/edge.rs | 4 ++-- crates/fj-core/src/operations/join/cycle.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/operations/build/edge.rs b/crates/fj-core/src/operations/build/edge.rs index f4f82e749..6e850e549 100644 --- a/crates/fj-core/src/operations/build/edge.rs +++ b/crates/fj-core/src/operations/build/edge.rs @@ -2,7 +2,7 @@ use fj_interop::ext::ArrayExt; use fj_math::{Arc, Point, Scalar}; use crate::{ - geometry::SurfacePath, + geometry::{BoundaryOnCurve, SurfacePath}, objects::{GlobalEdge, HalfEdge, Vertex}, operations::Insert, services::Services, @@ -13,7 +13,7 @@ pub trait BuildHalfEdge { /// Create a half-edge that is not joined to another fn unjoined( path: SurfacePath, - boundary: [Point<1>; 2], + boundary: impl Into, services: &mut Services, ) -> HalfEdge { let start_vertex = Vertex::new().insert(services); diff --git a/crates/fj-core/src/operations/join/cycle.rs b/crates/fj-core/src/operations/join/cycle.rs index e59c25d42..4782300e2 100644 --- a/crates/fj-core/src/operations/join/cycle.rs +++ b/crates/fj-core/src/operations/join/cycle.rs @@ -70,7 +70,7 @@ impl JoinCycle for Cycle { { self.add_half_edges(edges.into_iter().circular_tuple_windows().map( |((prev, _, _), (half_edge, curve, boundary))| { - HalfEdge::unjoined(curve, boundary.inner, services) + HalfEdge::unjoined(curve, boundary, services) .replace_start_vertex(prev.start_vertex().clone()) .replace_global_form(half_edge.global_form().clone()) .insert(services) From 8607aa08d2d8d940011e7e0d3d37b5353fefbd89 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 17 Jul 2023 11:26:52 +0200 Subject: [PATCH 24/24] Refactor to consolidate redundant code --- crates/fj-core/src/operations/reverse/cycle.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/crates/fj-core/src/operations/reverse/cycle.rs b/crates/fj-core/src/operations/reverse/cycle.rs index 5545b550f..62cac2ef1 100644 --- a/crates/fj-core/src/operations/reverse/cycle.rs +++ b/crates/fj-core/src/operations/reverse/cycle.rs @@ -11,14 +11,9 @@ impl Reverse for Cycle { let mut edges = self .half_edge_pairs() .map(|(current, next)| { - let boundary = { - let [a, b] = current.boundary().inner; - [b, a] - }; - HalfEdge::new( current.path(), - boundary, + current.boundary().reverse(), next.start_vertex().clone(), current.global_form().clone(), )