From fcf2432992ea97ed1c957d5092e5b31a6165451a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 23 Feb 2024 12:34:40 +0100 Subject: [PATCH 01/14] Simplify function argument --- crates/fj-core/src/algorithms/approx/curve.rs | 114 +++++++++--------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/curve.rs b/crates/fj-core/src/algorithms/approx/curve.rs index de4ca250f..78d44c226 100644 --- a/crates/fj-core/src/algorithms/approx/curve.rs +++ b/crates/fj-core/src/algorithms/approx/curve.rs @@ -5,7 +5,7 @@ use std::collections::BTreeMap; use fj_math::Point; use crate::{ - geometry::{CurveBoundary, GlobalPath, SurfacePath}, + geometry::{CurveBoundary, GlobalPath, SurfaceGeometry, SurfacePath}, objects::{Curve, Surface}, storage::{Handle, HandleWrapper}, Core, @@ -37,7 +37,7 @@ impl Approx None => { let approx = approx_curve( &surface_path, - surface, + &surface.geometry(), boundary, tolerance, core, @@ -51,7 +51,7 @@ impl Approx fn approx_curve( path: &SurfacePath, - surface: &Surface, + surface: &SurfaceGeometry, boundary: CurveBoundary>, tolerance: impl Into, core: &mut Core, @@ -62,63 +62,63 @@ fn approx_curve( // This will probably all be unified eventually, as `SurfacePath` and // `GlobalPath` grow APIs that are better suited to implementing this code // in a more abstract way. - let points = - match (path, surface.geometry().u) { - (SurfacePath::Circle(_), GlobalPath::Circle(_)) => { - todo!( + let points = match (path, surface.u) { + (SurfacePath::Circle(_), GlobalPath::Circle(_)) => { + todo!( "Approximating a circle on a curved surface not supported yet." ) + } + (SurfacePath::Circle(_), GlobalPath::Line(_)) => { + (path, boundary) + .approx_with_cache(tolerance, &mut (), core) + .into_iter() + .map(|(point_curve, point_surface)| { + // We're throwing away `point_surface` here, which is a + // bit weird, as we're recomputing it later (outside of + // this function). + // + // It should be fine though: + // + // 1. We're throwing this version away, so there's no + // danger of inconsistency between this and the later + // version. + // 2. This version should have been computed using the + // same path and parameters and the later version + // will be, so they should be the same anyway. + // 3. Not all other cases handled in this function have + // a surface point available, so it needs to be + // computed later anyway, in the general case. + + let point_global = + surface.point_from_surface_coords(point_surface); + (point_curve, point_global) + }) + .collect() + } + (SurfacePath::Line(line), _) => { + let range_u = + CurveBoundary::from(boundary.inner.map(|point_curve| { + [path.point_from_path_coords(point_curve).u] + })); + + let approx_u = (surface.u, range_u).approx_with_cache( + tolerance, + &mut (), + core, + ); + + let mut points = Vec::new(); + for (u, _) in approx_u { + let t = (u.t - line.origin().u) / line.direction().u; + let point_surface = path.point_from_path_coords([t]); + let point_global = + surface.point_from_surface_coords(point_surface); + points.push((u, point_global)); } - (SurfacePath::Circle(_), GlobalPath::Line(_)) => { - (path, boundary) - .approx_with_cache(tolerance, &mut (), core) - .into_iter() - .map(|(point_curve, point_surface)| { - // We're throwing away `point_surface` here, which is a - // bit weird, as we're recomputing it later (outside of - // this function). - // - // It should be fine though: - // - // 1. We're throwing this version away, so there's no - // danger of inconsistency between this and the later - // version. - // 2. This version should have been computed using the - // same path and parameters and the later version - // will be, so they should be the same anyway. - // 3. Not all other cases handled in this function have - // a surface point available, so it needs to be - // computed later anyway, in the general case. - - let point_global = surface - .geometry() - .point_from_surface_coords(point_surface); - (point_curve, point_global) - }) - .collect() - } - (SurfacePath::Line(line), _) => { - let range_u = - CurveBoundary::from(boundary.inner.map(|point_curve| { - [path.point_from_path_coords(point_curve).u] - })); - - let approx_u = (surface.geometry().u, range_u) - .approx_with_cache(tolerance, &mut (), core); - - let mut points = Vec::new(); - for (u, _) in approx_u { - let t = (u.t - line.origin().u) / line.direction().u; - let point_surface = path.point_from_path_coords([t]); - let point_global = surface - .geometry() - .point_from_surface_coords(point_surface); - points.push((u, point_global)); - } - - points - } - }; + + points + } + }; let points = points .into_iter() From efe392632b904fc8f9d24326fec2553a0428b820 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 23 Feb 2024 12:37:33 +0100 Subject: [PATCH 02/14] Simplify `Approx` implementation for curves --- crates/fj-core/src/algorithms/approx/curve.rs | 30 +++++++++---------- crates/fj-core/src/algorithms/approx/edge.rs | 13 ++++++-- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/curve.rs b/crates/fj-core/src/algorithms/approx/curve.rs index 78d44c226..7f4c679a0 100644 --- a/crates/fj-core/src/algorithms/approx/curve.rs +++ b/crates/fj-core/src/algorithms/approx/curve.rs @@ -6,7 +6,7 @@ use fj_math::Point; use crate::{ geometry::{CurveBoundary, GlobalPath, SurfaceGeometry, SurfacePath}, - objects::{Curve, Surface}, + objects::Curve, storage::{Handle, HandleWrapper}, Core, }; @@ -17,7 +17,7 @@ impl Approx for ( &Handle, SurfacePath, - &Surface, + &SurfaceGeometry, CurveBoundary>, ) { @@ -37,7 +37,7 @@ impl Approx None => { let approx = approx_curve( &surface_path, - &surface.geometry(), + surface, boundary, tolerance, core, @@ -183,14 +183,14 @@ impl CurveApproxCache { #[cfg(test)] mod tests { - use std::{f64::consts::TAU, ops::Deref}; + use std::f64::consts::TAU; use pretty_assertions::assert_eq; use crate::{ algorithms::approx::{Approx, ApproxPoint}, geometry::{CurveBoundary, GlobalPath, SurfaceGeometry, SurfacePath}, - objects::{Curve, Surface}, + objects::Curve, operations::insert::Insert, Core, }; @@ -203,10 +203,10 @@ mod tests { let (surface_path, boundary) = SurfacePath::line_from_points([[1., 1.], [2., 1.]]); let boundary = CurveBoundary::from(boundary); - let surface = core.layers.objects.surfaces.xz_plane(); + let surface = core.layers.objects.surfaces.xz_plane().geometry(); let tolerance = 1.; - let approx = (&curve, surface_path, surface.deref(), boundary) + let approx = (&curve, surface_path, &surface, boundary) .approx(tolerance, &mut core); assert_eq!(approx.points, vec![]); @@ -220,10 +220,10 @@ mod tests { let (surface_path, boundary) = SurfacePath::line_from_points([[1., 1.], [2., 1.]]); let boundary = CurveBoundary::from(boundary); - let surface = Surface::new(SurfaceGeometry { + let surface = SurfaceGeometry { u: GlobalPath::circle_from_radius(1.), v: [0., 0., 1.].into(), - }); + }; let tolerance = 1.; let approx = (&curve, surface_path, &surface, boundary) @@ -243,10 +243,10 @@ mod tests { ([TAU], [TAU, 1.]), ]); let boundary = CurveBoundary::from([[0.], [TAU]]); - let surface = Surface::new(SurfaceGeometry { + let surface = SurfaceGeometry { u: global_path, v: [0., 0., 1.].into(), - }); + }; let tolerance = 1.; let approx = (&curve, surface_path, &surface, boundary) @@ -259,7 +259,7 @@ mod tests { let point_surface = surface_path.point_from_path_coords(point_local); let point_global = - surface.geometry().point_from_surface_coords(point_surface); + surface.point_from_surface_coords(point_surface); ApproxPoint::new(point_local, point_global) }) .collect::>(); @@ -274,10 +274,10 @@ mod tests { let surface_path = SurfacePath::circle_from_center_and_radius([0., 0.], 1.); let boundary = CurveBoundary::from([[0.], [TAU]]); - let surface = core.layers.objects.surfaces.xz_plane(); + let surface = core.layers.objects.surfaces.xz_plane().geometry(); let tolerance = 1.; - let approx = (&curve, surface_path, surface.deref(), boundary) + let approx = (&curve, surface_path, &surface, boundary) .approx(tolerance, &mut core); let expected_approx = (&surface_path, boundary) @@ -287,7 +287,7 @@ mod tests { let point_surface = surface_path.point_from_path_coords(point_local); let point_global = - surface.geometry().point_from_surface_coords(point_surface); + surface.point_from_surface_coords(point_surface); ApproxPoint::new(point_local, point_global) }) .collect::>(); diff --git a/crates/fj-core/src/algorithms/approx/edge.rs b/crates/fj-core/src/algorithms/approx/edge.rs index 961944c0c..cfe213a14 100644 --- a/crates/fj-core/src/algorithms/approx/edge.rs +++ b/crates/fj-core/src/algorithms/approx/edge.rs @@ -45,8 +45,17 @@ impl Approx for (&HalfEdge, &Surface) { let first = ApproxPoint::new(start_position_surface, start_position); let rest = { - let approx = (edge.curve(), edge.path(), surface, edge.boundary()) - .approx_with_cache(tolerance, &mut cache.curve, core); + let approx = ( + edge.curve(), + edge.path(), + &surface.geometry(), + edge.boundary(), + ) + .approx_with_cache( + tolerance, + &mut cache.curve, + core, + ); approx.points.into_iter().map(|point| { let point_surface = From 18b714c75b7cc2f22fd3ad73ccef0a29ade404e7 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 23 Feb 2024 12:39:08 +0100 Subject: [PATCH 03/14] Simplify `Approx` implementation for half-edges --- crates/fj-core/src/algorithms/approx/cycle.rs | 2 +- crates/fj-core/src/algorithms/approx/edge.rs | 25 +++++-------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/cycle.rs b/crates/fj-core/src/algorithms/approx/cycle.rs index e14f884d2..b05400143 100644 --- a/crates/fj-core/src/algorithms/approx/cycle.rs +++ b/crates/fj-core/src/algorithms/approx/cycle.rs @@ -33,7 +33,7 @@ impl Approx for (&Cycle, &Surface) { .half_edges() .iter() .map(|edge| { - (edge.deref(), surface) + (edge.deref(), &surface.geometry()) .approx_with_cache(tolerance, cache, core) }) .collect(); diff --git a/crates/fj-core/src/algorithms/approx/edge.rs b/crates/fj-core/src/algorithms/approx/edge.rs index cfe213a14..88decf722 100644 --- a/crates/fj-core/src/algorithms/approx/edge.rs +++ b/crates/fj-core/src/algorithms/approx/edge.rs @@ -5,17 +5,14 @@ //! approximations are usually used to build cycle approximations, and this way, //! the caller doesn't have to deal with duplicate vertices. -use crate::{ - objects::{HalfEdge, Surface}, - Core, -}; +use crate::{geometry::SurfaceGeometry, objects::HalfEdge, Core}; use super::{ curve::CurveApproxCache, vertex::VertexApproxCache, Approx, ApproxPoint, Tolerance, }; -impl Approx for (&HalfEdge, &Surface) { +impl Approx for (&HalfEdge, &SurfaceGeometry) { type Approximation = HalfEdgeApprox; type Cache = HalfEdgeApproxCache; @@ -33,9 +30,8 @@ impl Approx for (&HalfEdge, &Surface) { { Some(position) => position, None => { - let position_global = surface - .geometry() - .point_from_surface_coords(start_position_surface); + let position_global = + surface.point_from_surface_coords(start_position_surface); cache .start_position .insert(edge.start_vertex().clone(), position_global) @@ -45,17 +41,8 @@ impl Approx for (&HalfEdge, &Surface) { let first = ApproxPoint::new(start_position_surface, start_position); let rest = { - let approx = ( - edge.curve(), - edge.path(), - &surface.geometry(), - edge.boundary(), - ) - .approx_with_cache( - tolerance, - &mut cache.curve, - core, - ); + let approx = (edge.curve(), edge.path(), surface, edge.boundary()) + .approx_with_cache(tolerance, &mut cache.curve, core); approx.points.into_iter().map(|point| { let point_surface = From 7dd818e4b72f04ad403280bd30a3694051344b4b Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 23 Feb 2024 12:40:23 +0100 Subject: [PATCH 04/14] Simplify `Approx` implementation for cycles --- crates/fj-core/src/algorithms/approx/cycle.rs | 9 +++------ crates/fj-core/src/algorithms/approx/face.rs | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/cycle.rs b/crates/fj-core/src/algorithms/approx/cycle.rs index b05400143..cfa546d7b 100644 --- a/crates/fj-core/src/algorithms/approx/cycle.rs +++ b/crates/fj-core/src/algorithms/approx/cycle.rs @@ -6,17 +6,14 @@ use std::ops::Deref; use fj_math::Segment; -use crate::{ - objects::{Cycle, Surface}, - Core, -}; +use crate::{geometry::SurfaceGeometry, objects::Cycle, Core}; use super::{ edge::{HalfEdgeApprox, HalfEdgeApproxCache}, Approx, ApproxPoint, Tolerance, }; -impl Approx for (&Cycle, &Surface) { +impl Approx for (&Cycle, &SurfaceGeometry) { type Approximation = CycleApprox; type Cache = HalfEdgeApproxCache; @@ -33,7 +30,7 @@ impl Approx for (&Cycle, &Surface) { .half_edges() .iter() .map(|edge| { - (edge.deref(), &surface.geometry()) + (edge.deref(), surface) .approx_with_cache(tolerance, cache, core) }) .collect(); diff --git a/crates/fj-core/src/algorithms/approx/face.rs b/crates/fj-core/src/algorithms/approx/face.rs index cbdb5f2a2..fa07879b1 100644 --- a/crates/fj-core/src/algorithms/approx/face.rs +++ b/crates/fj-core/src/algorithms/approx/face.rs @@ -91,12 +91,12 @@ impl Approx for &Face { // it have nothing to do with its curvature. let exterior = - (self.region().exterior().deref(), self.surface().deref()) + (self.region().exterior().deref(), &self.surface().geometry()) .approx_with_cache(tolerance, cache, core); let mut interiors = BTreeSet::new(); for cycle in self.region().interiors() { - let cycle = (cycle.deref(), self.surface().deref()) + let cycle = (cycle.deref(), &self.surface().geometry()) .approx_with_cache(tolerance, cache, core); interiors.insert(cycle); } From 20a3d5da74eccc9fb8d5bc07af3e47dc1e2abaf9 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 23 Feb 2024 12:42:43 +0100 Subject: [PATCH 05/14] Remove unused `ApproxPoint::from_surface_point` --- crates/fj-core/src/algorithms/approx/mod.rs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/mod.rs b/crates/fj-core/src/algorithms/approx/mod.rs index ad9ba4bf8..983368a6d 100644 --- a/crates/fj-core/src/algorithms/approx/mod.rs +++ b/crates/fj-core/src/algorithms/approx/mod.rs @@ -19,7 +19,7 @@ use std::{ use fj_math::Point; -use crate::{objects::Surface, Core}; +use crate::Core; pub use self::tolerance::{InvalidTolerance, Tolerance}; @@ -79,19 +79,6 @@ impl ApproxPoint { } } -impl ApproxPoint<2> { - /// Create an instance of `ApproxPoint` from a surface point - pub fn from_surface_point( - point_surface: impl Into>, - surface: &Surface, - ) -> Self { - let point_surface = point_surface.into(); - let point_global = - surface.geometry().point_from_surface_coords(point_surface); - ApproxPoint::new(point_surface, point_global) - } -} - impl Eq for ApproxPoint {} impl PartialEq for ApproxPoint { From dbbf8f042c3f78284831ed63794b5a2c0d4b34fa Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 23 Feb 2024 12:57:30 +0100 Subject: [PATCH 06/14] Simplify argument in `SweepSurfacePath` --- .../fj-core/src/operations/sweep/half_edge.rs | 6 +++-- crates/fj-core/src/operations/sweep/path.rs | 24 +++++++------------ 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/crates/fj-core/src/operations/sweep/half_edge.rs b/crates/fj-core/src/operations/sweep/half_edge.rs index 6b1e6d3d1..a6975891b 100644 --- a/crates/fj-core/src/operations/sweep/half_edge.rs +++ b/crates/fj-core/src/operations/sweep/half_edge.rs @@ -57,8 +57,10 @@ impl SweepHalfEdge for HalfEdge { ) -> (Face, Handle) { let path = path.into(); - let surface = - self.path().sweep_surface_path(surface, path).insert(core); + let surface = self + .path() + .sweep_surface_path(&surface.geometry(), path) + .insert(core); // Next, we need to define the boundaries of the face. Let's start with // the global vertices and edges. diff --git a/crates/fj-core/src/operations/sweep/path.rs b/crates/fj-core/src/operations/sweep/path.rs index 06bf9b9ae..f4f57cde4 100644 --- a/crates/fj-core/src/operations/sweep/path.rs +++ b/crates/fj-core/src/operations/sweep/path.rs @@ -23,7 +23,7 @@ pub trait SweepSurfacePath { /// fn sweep_surface_path( &self, - surface: &Surface, + surface: &SurfaceGeometry, path: impl Into>, ) -> Surface; } @@ -31,10 +31,10 @@ pub trait SweepSurfacePath { impl SweepSurfacePath for SurfacePath { fn sweep_surface_path( &self, - surface: &Surface, + surface: &SurfaceGeometry, path: impl Into>, ) -> Surface { - match surface.geometry().u { + match surface.u { GlobalPath::Circle(_) => { // Sweeping a `Curve` creates a `Surface`. The u-axis of that // `Surface` is a `GlobalPath`, which we are computing below. @@ -60,24 +60,18 @@ impl SweepSurfacePath for SurfacePath { let u = match self { SurfacePath::Circle(circle) => { - let center = surface - .geometry() - .point_from_surface_coords(circle.center()); - let a = - surface.geometry().vector_from_surface_coords(circle.a()); - let b = - surface.geometry().vector_from_surface_coords(circle.b()); + let center = surface.point_from_surface_coords(circle.center()); + let a = surface.vector_from_surface_coords(circle.a()); + let b = surface.vector_from_surface_coords(circle.b()); let circle = Circle::new(center, a, b); GlobalPath::Circle(circle) } SurfacePath::Line(line) => { - let origin = - surface.geometry().point_from_surface_coords(line.origin()); - let direction = surface - .geometry() - .vector_from_surface_coords(line.direction()); + let origin = surface.point_from_surface_coords(line.origin()); + let direction = + surface.vector_from_surface_coords(line.direction()); let line = Line::from_origin_and_direction(origin, direction); From b6078a73e8cb9d62f251cb94e08d74971b72223d Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 23 Feb 2024 12:58:34 +0100 Subject: [PATCH 07/14] Simplify argument in `SweepHalfEdge` --- crates/fj-core/src/operations/sweep/cycle.rs | 2 +- crates/fj-core/src/operations/sweep/half_edge.rs | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/crates/fj-core/src/operations/sweep/cycle.rs b/crates/fj-core/src/operations/sweep/cycle.rs index 6b7c4b092..10ff608da 100644 --- a/crates/fj-core/src/operations/sweep/cycle.rs +++ b/crates/fj-core/src/operations/sweep/cycle.rs @@ -65,7 +65,7 @@ impl SweepCycle for Cycle { let (side_face, top_edge) = bottom_half_edge.sweep_half_edge( bottom_half_edge_next.start_vertex().clone(), - surface, + &surface.geometry(), color, path, cache, diff --git a/crates/fj-core/src/operations/sweep/half_edge.rs b/crates/fj-core/src/operations/sweep/half_edge.rs index a6975891b..00bae3ace 100644 --- a/crates/fj-core/src/operations/sweep/half_edge.rs +++ b/crates/fj-core/src/operations/sweep/half_edge.rs @@ -2,7 +2,8 @@ use fj_interop::{ext::ArrayExt, Color}; use fj_math::{Point, Scalar, Vector}; use crate::{ - objects::{Cycle, Face, HalfEdge, Region, Surface, Vertex}, + geometry::SurfaceGeometry, + objects::{Cycle, Face, HalfEdge, Region, Vertex}, operations::{ build::{BuildCycle, BuildHalfEdge}, insert::Insert, @@ -37,7 +38,7 @@ pub trait SweepHalfEdge { fn sweep_half_edge( &self, end_vertex: Handle, - surface: &Surface, + surface: &SurfaceGeometry, color: Option, path: impl Into>, cache: &mut SweepCache, @@ -49,7 +50,7 @@ impl SweepHalfEdge for HalfEdge { fn sweep_half_edge( &self, end_vertex: Handle, - surface: &Surface, + surface: &SurfaceGeometry, color: Option, path: impl Into>, cache: &mut SweepCache, @@ -57,10 +58,8 @@ impl SweepHalfEdge for HalfEdge { ) -> (Face, Handle) { let path = path.into(); - let surface = self - .path() - .sweep_surface_path(&surface.geometry(), path) - .insert(core); + let surface = + self.path().sweep_surface_path(surface, path).insert(core); // Next, we need to define the boundaries of the face. Let's start with // the global vertices and edges. From 16efca2f8374b434e7b7d87e59323a313f295558 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 23 Feb 2024 12:59:19 +0100 Subject: [PATCH 08/14] Simplify argument in `SweepCycle` --- crates/fj-core/src/operations/sweep/cycle.rs | 9 +++++---- crates/fj-core/src/operations/sweep/region.rs | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/fj-core/src/operations/sweep/cycle.rs b/crates/fj-core/src/operations/sweep/cycle.rs index 10ff608da..b64ec1860 100644 --- a/crates/fj-core/src/operations/sweep/cycle.rs +++ b/crates/fj-core/src/operations/sweep/cycle.rs @@ -2,7 +2,8 @@ use fj_interop::Color; use fj_math::Vector; use crate::{ - objects::{Cycle, Face, Surface}, + geometry::SurfaceGeometry, + objects::{Cycle, Face}, operations::{ build::BuildCycle, join::JoinCycle, sweep::half_edge::SweepHalfEdge, }, @@ -37,7 +38,7 @@ pub trait SweepCycle { /// operation is called in, and therefore falls outside of its scope. fn sweep_cycle( &self, - surface: &Surface, + surface: &SurfaceGeometry, color: Option, path: impl Into>, cache: &mut SweepCache, @@ -48,7 +49,7 @@ pub trait SweepCycle { impl SweepCycle for Cycle { fn sweep_cycle( &self, - surface: &Surface, + surface: &SurfaceGeometry, color: Option, path: impl Into>, cache: &mut SweepCache, @@ -65,7 +66,7 @@ impl SweepCycle for Cycle { let (side_face, top_edge) = bottom_half_edge.sweep_half_edge( bottom_half_edge_next.start_vertex().clone(), - &surface.geometry(), + surface, color, path, cache, diff --git a/crates/fj-core/src/operations/sweep/region.rs b/crates/fj-core/src/operations/sweep/region.rs index 88600bd57..feb4ca3d9 100644 --- a/crates/fj-core/src/operations/sweep/region.rs +++ b/crates/fj-core/src/operations/sweep/region.rs @@ -103,7 +103,7 @@ fn sweep_cycle( core: &mut Core, ) -> Handle { let swept_cycle = bottom_cycle.reverse(core).sweep_cycle( - bottom_surface, + &bottom_surface.geometry(), color, path, cache, From 39214f1e2aacd21d09680aba9d553b2a59e01f57 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 23 Feb 2024 13:00:01 +0100 Subject: [PATCH 09/14] Simplify argument in private function --- crates/fj-core/src/operations/sweep/region.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/fj-core/src/operations/sweep/region.rs b/crates/fj-core/src/operations/sweep/region.rs index feb4ca3d9..78cd701d0 100644 --- a/crates/fj-core/src/operations/sweep/region.rs +++ b/crates/fj-core/src/operations/sweep/region.rs @@ -2,6 +2,7 @@ use fj_interop::Color; use fj_math::Vector; use crate::{ + geometry::SurfaceGeometry, objects::{Cycle, Face, Region, Surface}, operations::{ insert::Insert, reverse::Reverse, transform::TransformObject, @@ -54,7 +55,7 @@ impl SweepRegion for Region { let top_exterior = sweep_cycle( self.exterior(), - surface, + &surface.geometry(), color, &mut faces, path, @@ -68,7 +69,7 @@ impl SweepRegion for Region { .map(|bottom_cycle| { sweep_cycle( bottom_cycle, - surface, + &surface.geometry(), color, &mut faces, path, @@ -95,7 +96,7 @@ impl SweepRegion for Region { fn sweep_cycle( bottom_cycle: &Cycle, - bottom_surface: &Surface, + bottom_surface: &SurfaceGeometry, color: Option, faces: &mut Vec, path: Vector<3>, @@ -103,7 +104,7 @@ fn sweep_cycle( core: &mut Core, ) -> Handle { let swept_cycle = bottom_cycle.reverse(core).sweep_cycle( - &bottom_surface.geometry(), + bottom_surface, color, path, cache, From 5295c0db0b759a020ee459684367d9c6a5044d22 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 23 Feb 2024 13:05:00 +0100 Subject: [PATCH 10/14] Simplify argument of private function --- crates/fj-core/src/validate/shell.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index b9b9b45f0..175fab281 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -95,7 +95,7 @@ impl ShellValidationError { fn compare_curve_coords( edge_a: &Handle, - surface_a: &Handle, + surface_a: &SurfaceGeometry, edge_b: &Handle, surface_b: &Handle, config: &ValidationConfig, @@ -115,9 +115,8 @@ impl ShellValidationError { let b_surface = edge_b.path().point_from_path_coords(point_curve); - let a_global = surface_a - .geometry() - .point_from_surface_coords(a_surface); + let a_global = + surface_a.point_from_surface_coords(a_surface); let b_global = surface_b .geometry() .point_from_surface_coords(b_surface); @@ -141,7 +140,7 @@ impl ShellValidationError { compare_curve_coords( edge_a, - surface_a, + &surface_a.geometry(), edge_b, surface_b, config, @@ -149,7 +148,7 @@ impl ShellValidationError { ); compare_curve_coords( edge_b, - surface_b, + &surface_b.geometry(), edge_a, surface_a, config, From 42e40a7e74341fafc0246f413b8bec2964c14dfe Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 23 Feb 2024 13:05:47 +0100 Subject: [PATCH 11/14] Simplify argument of private function --- crates/fj-core/src/validate/shell.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index 175fab281..b22a95f45 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -97,7 +97,7 @@ impl ShellValidationError { edge_a: &Handle, surface_a: &SurfaceGeometry, edge_b: &Handle, - surface_b: &Handle, + surface_b: &SurfaceGeometry, config: &ValidationConfig, mismatches: &mut Vec, ) { @@ -117,9 +117,8 @@ impl ShellValidationError { let a_global = surface_a.point_from_surface_coords(a_surface); - let b_global = surface_b - .geometry() - .point_from_surface_coords(b_surface); + let b_global = + surface_b.point_from_surface_coords(b_surface); let distance = (a_global - b_global).magnitude(); @@ -142,7 +141,7 @@ impl ShellValidationError { edge_a, &surface_a.geometry(), edge_b, - surface_b, + &surface_b.geometry(), config, &mut mismatches, ); @@ -150,7 +149,7 @@ impl ShellValidationError { edge_b, &surface_b.geometry(), edge_a, - surface_a, + &surface_a.geometry(), config, &mut mismatches, ); From ec255a3460a37c198576e43bddcc61871c4b128d Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 23 Feb 2024 13:06:56 +0100 Subject: [PATCH 12/14] Simplify argument of private function --- 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 b22a95f45..db6846c9b 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -365,7 +365,7 @@ fn distances( ) -> impl Iterator { fn sample( percent: f64, - (edge, surface): (&Handle, SurfaceGeometry), + (edge, surface): (&Handle, &SurfaceGeometry), ) -> Point<3> { let [start, end] = edge.boundary().inner; let path_coords = start + (end - start) * percent; @@ -382,8 +382,8 @@ 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, surface_a.geometry())); - let sample2 = sample(1.0 - percent, (&edge_b, surface_b.geometry())); + let sample1 = sample(percent, (&edge_a, &surface_a.geometry())); + let sample2 = sample(1.0 - percent, (&edge_b, &surface_b.geometry())); distances.push(sample1.distance_to(&sample2)) } distances.into_iter() From 64f783474b1a175e27c5aefcdab23838369dbd1a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 23 Feb 2024 13:07:33 +0100 Subject: [PATCH 13/14] Simplify argument of private function --- 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 db6846c9b..acb1faa5b 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -235,7 +235,7 @@ impl ShellValidationError { // `distinct_min_distance`, that's a problem. if distances( half_edge_a.clone(), - surface_a.clone(), + &surface_a.geometry(), half_edge_b.clone(), surface_b.clone(), ) @@ -359,7 +359,7 @@ impl fmt::Display for CoincidentHalfEdgeVertices { /// Returns an [`Iterator`] of the distance at each sample. fn distances( edge_a: Handle, - surface_a: Handle, + surface_a: &SurfaceGeometry, edge_b: Handle, surface_b: Handle, ) -> impl Iterator { @@ -382,7 +382,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, &surface_a.geometry())); + let sample1 = sample(percent, (&edge_a, surface_a)); let sample2 = sample(1.0 - percent, (&edge_b, &surface_b.geometry())); distances.push(sample1.distance_to(&sample2)) } From 7cb44bf790c2da648911d751d59d0739de37c392 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 23 Feb 2024 13:08:23 +0100 Subject: [PATCH 14/14] Simplify argument of private function --- crates/fj-core/src/validate/shell.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index acb1faa5b..25764efe2 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -4,7 +4,7 @@ use fj_math::{Point, Scalar}; use crate::{ geometry::{CurveBoundary, SurfaceGeometry}, - objects::{Curve, HalfEdge, Shell, Surface, Vertex}, + objects::{Curve, HalfEdge, Shell, Vertex}, queries::{ AllHalfEdgesWithSurface, BoundingVerticesOfHalfEdge, SiblingOfHalfEdge, }, @@ -237,7 +237,7 @@ impl ShellValidationError { half_edge_a.clone(), &surface_a.geometry(), half_edge_b.clone(), - surface_b.clone(), + &surface_b.geometry(), ) .all(|d| d < config.distinct_min_distance) { @@ -361,7 +361,7 @@ fn distances( edge_a: Handle, surface_a: &SurfaceGeometry, edge_b: Handle, - surface_b: Handle, + surface_b: &SurfaceGeometry, ) -> impl Iterator { fn sample( percent: f64, @@ -383,7 +383,7 @@ fn distances( for i in 0..sample_count { let percent = i as f64 * step; let sample1 = sample(percent, (&edge_a, surface_a)); - let sample2 = sample(1.0 - percent, (&edge_b, &surface_b.geometry())); + let sample2 = sample(1.0 - percent, (&edge_b, surface_b)); distances.push(sample1.distance_to(&sample2)) } distances.into_iter()