From 3b169f3241322a905258f682a3580abe7b010898 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 24 Feb 2023 13:29:40 +0100 Subject: [PATCH 01/12] Add `SurfacePath::u_axis` --- crates/fj-kernel/src/builder/curve.rs | 7 +++---- crates/fj-kernel/src/geometry/path.rs | 9 +++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/crates/fj-kernel/src/builder/curve.rs b/crates/fj-kernel/src/builder/curve.rs index acc790cf1..05aa3916a 100644 --- a/crates/fj-kernel/src/builder/curve.rs +++ b/crates/fj-kernel/src/builder/curve.rs @@ -50,10 +50,9 @@ pub trait CurveBuilder { impl CurveBuilder for PartialCurve { fn update_as_u_axis(&mut self) -> SurfacePath { - let a = Point::origin(); - let b = a + Vector::unit_u(); - - self.update_as_line_from_points([a, b]) + let path = SurfacePath::u_axis(); + self.path = Some(path.into()); + path } fn update_as_v_axis(&mut self) -> SurfacePath { diff --git a/crates/fj-kernel/src/geometry/path.rs b/crates/fj-kernel/src/geometry/path.rs index cf85a2d73..20f2e3d6a 100644 --- a/crates/fj-kernel/src/geometry/path.rs +++ b/crates/fj-kernel/src/geometry/path.rs @@ -43,6 +43,15 @@ impl SurfacePath { Self::Circle(Circle::from_center_and_radius(center, radius)) } + /// Build a line that represents the u-axis of the surface its on + pub fn u_axis() -> Self { + let a = Point::origin(); + let b = a + Vector::unit_u(); + + let (self_, _) = Self::line_from_points([a, b]); + self_ + } + /// Construct a line from two points /// /// Also returns the coordinates of the points on the path. From 2d7cc85a828aa2445db1ca5ebff44c8e1e86a337 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 24 Feb 2023 13:30:47 +0100 Subject: [PATCH 02/12] Add `SurfacePath::v_axis` --- crates/fj-kernel/src/builder/curve.rs | 9 ++++----- crates/fj-kernel/src/geometry/path.rs | 9 +++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/fj-kernel/src/builder/curve.rs b/crates/fj-kernel/src/builder/curve.rs index 05aa3916a..19916b222 100644 --- a/crates/fj-kernel/src/builder/curve.rs +++ b/crates/fj-kernel/src/builder/curve.rs @@ -1,4 +1,4 @@ -use fj_math::{Point, Scalar, Vector}; +use fj_math::{Point, Scalar}; use crate::{geometry::path::SurfacePath, partial::PartialCurve}; @@ -56,10 +56,9 @@ impl CurveBuilder for PartialCurve { } fn update_as_v_axis(&mut self) -> SurfacePath { - let a = Point::origin(); - let b = a + Vector::unit_v(); - - self.update_as_line_from_points([a, b]) + let path = SurfacePath::v_axis(); + self.path = Some(path.into()); + path } fn update_as_circle_from_radius( diff --git a/crates/fj-kernel/src/geometry/path.rs b/crates/fj-kernel/src/geometry/path.rs index 20f2e3d6a..e8866e0f9 100644 --- a/crates/fj-kernel/src/geometry/path.rs +++ b/crates/fj-kernel/src/geometry/path.rs @@ -52,6 +52,15 @@ impl SurfacePath { self_ } + /// Build a line that represents the v-axis of the surface its on + pub fn v_axis() -> Self { + let a = Point::origin(); + let b = a + Vector::unit_v(); + + let (self_, _) = Self::line_from_points([a, b]); + self_ + } + /// Construct a line from two points /// /// Also returns the coordinates of the points on the path. From 133bda985a7affdd3bc297d5918bbb5e9014a8ec Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 24 Feb 2023 13:43:58 +0100 Subject: [PATCH 03/12] Remove references from doc comments --- crates/fj-kernel/src/algorithms/intersect/curve_edge.rs | 4 ++-- crates/fj-kernel/src/algorithms/intersect/curve_face.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs index bec4fa99f..cfa61a0f4 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs @@ -7,7 +7,7 @@ use crate::{ use super::LineSegmentIntersection; -/// The intersection between a [`Curve`] and a [`HalfEdge`] +/// The intersection between a curve and a [`HalfEdge`] #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] pub enum CurveEdgeIntersection { /// The curve and edge intersect at a point @@ -29,7 +29,7 @@ impl CurveEdgeIntersection { /// # Panics /// /// Currently, only intersections between lines and line segments can be - /// computed. Panics, if a different type of [`Curve`] or [`HalfEdge`] is + /// computed. Panics, if a different type of curve or [`HalfEdge`] is /// passed. pub fn compute(curve: &Curve, half_edge: &HalfEdge) -> Option { let curve_as_line = match curve.path() { diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index 386ec6de7..6db4015d8 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -7,7 +7,7 @@ use crate::objects::{Curve, Face}; use super::CurveEdgeIntersection; -/// The intersections between a [`Curve`] and a [`Face`], in curve coordinates +/// The intersections between a curve and a [`Face`], in curve coordinates #[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] pub struct CurveFaceIntersection { /// The intervals where the curve and face intersect, in curve coordinates From e4f1db813984486ad3e3b954b64fe367de62cbe3 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 24 Feb 2023 13:45:30 +0100 Subject: [PATCH 04/12] Don't require actual `Curve` in intersect code --- .../src/algorithms/intersect/curve_edge.rs | 23 ++++++++++--------- .../src/algorithms/intersect/curve_face.rs | 3 ++- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs index cfa61a0f4..c6cf0e877 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs @@ -1,9 +1,6 @@ use fj_math::{Point, Segment}; -use crate::{ - geometry::path::SurfacePath, - objects::{Curve, HalfEdge}, -}; +use crate::{geometry::path::SurfacePath, objects::HalfEdge}; use super::LineSegmentIntersection; @@ -31,8 +28,8 @@ impl CurveEdgeIntersection { /// Currently, only intersections between lines and line segments can be /// computed. Panics, if a different type of curve or [`HalfEdge`] is /// passed. - pub fn compute(curve: &Curve, half_edge: &HalfEdge) -> Option { - let curve_as_line = match curve.path() { + pub fn compute(curve: &SurfacePath, half_edge: &HalfEdge) -> Option { + let curve_as_line = match curve { SurfacePath::Line(line) => line, _ => todo!("Curve-edge intersection only supports lines"), }; @@ -53,7 +50,7 @@ impl CurveEdgeIntersection { }; let intersection = - LineSegmentIntersection::compute(&curve_as_line, &edge_as_segment)?; + LineSegmentIntersection::compute(curve_as_line, &edge_as_segment)?; let intersection = match intersection { LineSegmentIntersection::Point { point_on_line } => Self::Point { @@ -98,7 +95,8 @@ mod tests { half_edge.build(&mut services.objects) }; - let intersection = CurveEdgeIntersection::compute(&curve, &half_edge); + let intersection = + CurveEdgeIntersection::compute(&curve.path(), &half_edge); assert_eq!( intersection, @@ -125,7 +123,8 @@ mod tests { half_edge.build(&mut services.objects) }; - let intersection = CurveEdgeIntersection::compute(&curve, &half_edge); + let intersection = + CurveEdgeIntersection::compute(&curve.path(), &half_edge); assert_eq!( intersection, @@ -152,7 +151,8 @@ mod tests { half_edge.build(&mut services.objects) }; - let intersection = CurveEdgeIntersection::compute(&curve, &half_edge); + let intersection = + CurveEdgeIntersection::compute(&curve.path(), &half_edge); assert!(intersection.is_none()); } @@ -173,7 +173,8 @@ mod tests { half_edge.build(&mut services.objects) }; - let intersection = CurveEdgeIntersection::compute(&curve, &half_edge); + let intersection = + CurveEdgeIntersection::compute(&curve.path(), &half_edge); assert_eq!( intersection, diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index 6db4015d8..7691b8a94 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -34,7 +34,8 @@ impl CurveFaceIntersection { let mut intersections = Vec::new(); for half_edge in half_edges { - let intersection = CurveEdgeIntersection::compute(curve, half_edge); + let intersection = + CurveEdgeIntersection::compute(&curve.path(), half_edge); if let Some(intersection) = intersection { match intersection { From 9865766f0ad07ff40d17384d402d36c0574fae68 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 24 Feb 2023 13:46:41 +0100 Subject: [PATCH 05/12] Simplify tests --- .../src/algorithms/intersect/curve_edge.rs | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs index c6cf0e877..337e08f13 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs @@ -72,8 +72,9 @@ mod tests { use fj_math::Point; use crate::{ - builder::{CurveBuilder, HalfEdgeBuilder}, - partial::{PartialCurve, PartialHalfEdge, PartialObject}, + builder::HalfEdgeBuilder, + geometry::path::SurfacePath, + partial::{PartialHalfEdge, PartialObject}, services::Services, }; @@ -84,9 +85,7 @@ mod tests { let mut services = Services::new(); let surface = services.objects.surfaces.xy_plane(); - let mut curve = PartialCurve::default(); - curve.update_as_u_axis(); - let curve = curve.build(&mut services.objects); + let curve = SurfacePath::u_axis(); let half_edge = { let mut half_edge = PartialHalfEdge::default(); half_edge.update_as_line_segment_from_points([[1., -1.], [1., 1.]]); @@ -95,8 +94,7 @@ mod tests { half_edge.build(&mut services.objects) }; - let intersection = - CurveEdgeIntersection::compute(&curve.path(), &half_edge); + let intersection = CurveEdgeIntersection::compute(&curve, &half_edge); assert_eq!( intersection, @@ -111,9 +109,7 @@ mod tests { let mut services = Services::new(); let surface = services.objects.surfaces.xy_plane(); - let mut curve = PartialCurve::default(); - curve.update_as_u_axis(); - let curve = curve.build(&mut services.objects); + let curve = SurfacePath::u_axis(); let half_edge = { let mut half_edge = PartialHalfEdge::default(); half_edge @@ -123,8 +119,7 @@ mod tests { half_edge.build(&mut services.objects) }; - let intersection = - CurveEdgeIntersection::compute(&curve.path(), &half_edge); + let intersection = CurveEdgeIntersection::compute(&curve, &half_edge); assert_eq!( intersection, @@ -139,9 +134,7 @@ mod tests { let mut services = Services::new(); let surface = services.objects.surfaces.xy_plane(); - let mut curve = PartialCurve::default(); - curve.update_as_u_axis(); - let curve = curve.build(&mut services.objects); + let curve = SurfacePath::u_axis(); let half_edge = { let mut half_edge = PartialHalfEdge::default(); half_edge @@ -151,8 +144,7 @@ mod tests { half_edge.build(&mut services.objects) }; - let intersection = - CurveEdgeIntersection::compute(&curve.path(), &half_edge); + let intersection = CurveEdgeIntersection::compute(&curve, &half_edge); assert!(intersection.is_none()); } @@ -162,9 +154,7 @@ mod tests { let mut services = Services::new(); let surface = services.objects.surfaces.xy_plane(); - let mut curve = PartialCurve::default(); - curve.update_as_u_axis(); - let curve = curve.build(&mut services.objects); + let curve = SurfacePath::u_axis(); let half_edge = { let mut half_edge = PartialHalfEdge::default(); half_edge.update_as_line_segment_from_points([[-1., 0.], [1., 0.]]); @@ -173,8 +163,7 @@ mod tests { half_edge.build(&mut services.objects) }; - let intersection = - CurveEdgeIntersection::compute(&curve.path(), &half_edge); + let intersection = CurveEdgeIntersection::compute(&curve, &half_edge); assert_eq!( intersection, From ecd9d01960c540fdf09b4650113c7b4a891eb3c2 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 24 Feb 2023 13:53:51 +0100 Subject: [PATCH 06/12] Simplify doc comment --- crates/fj-kernel/src/algorithms/intersect/curve_face.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index 7691b8a94..d4ddcac39 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -27,7 +27,7 @@ impl CurveFaceIntersection { Self { intervals } } - /// Compute the intersections between a [`Curve`] and a [`Face`] + /// Compute the intersection pub fn compute(curve: &Curve, face: &Face) -> Self { let half_edges = face.all_cycles().flat_map(|cycle| cycle.half_edges()); From 29a91d050fedb7e1a51a9c21a3a3a6c548d0cde4 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 24 Feb 2023 13:45:30 +0100 Subject: [PATCH 07/12] Don't require actual `Curve` in intersect code --- .../fj-kernel/src/algorithms/intersect/curve_face.rs | 12 +++++++----- .../fj-kernel/src/algorithms/intersect/face_face.rs | 4 +++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index d4ddcac39..fab2a67c7 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -3,7 +3,7 @@ use std::vec; use fj_interop::ext::SliceExt; use fj_math::Point; -use crate::objects::{Curve, Face}; +use crate::{geometry::path::SurfacePath, objects::Face}; use super::CurveEdgeIntersection; @@ -28,14 +28,13 @@ impl CurveFaceIntersection { } /// Compute the intersection - pub fn compute(curve: &Curve, face: &Face) -> Self { + pub fn compute(curve: &SurfacePath, face: &Face) -> Self { let half_edges = face.all_cycles().flat_map(|cycle| cycle.half_edges()); let mut intersections = Vec::new(); for half_edge in half_edges { - let intersection = - CurveEdgeIntersection::compute(&curve.path(), half_edge); + let intersection = CurveEdgeIntersection::compute(curve, half_edge); if let Some(intersection) = intersection { match intersection { @@ -198,7 +197,10 @@ mod tests { let expected = CurveFaceIntersection::from_intervals([[[1.], [2.]], [[4.], [5.]]]); - assert_eq!(CurveFaceIntersection::compute(&curve, &face), expected); + assert_eq!( + CurveFaceIntersection::compute(&curve.path(), &face), + expected + ); } #[test] diff --git a/crates/fj-kernel/src/algorithms/intersect/face_face.rs b/crates/fj-kernel/src/algorithms/intersect/face_face.rs index 30b9b2460..d5c7696f1 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_face.rs @@ -44,7 +44,9 @@ impl FaceFaceIntersection { .each_ref_ext() .into_iter_fixed() .zip(faces) - .map(|(curve, face)| CurveFaceIntersection::compute(curve, face)) + .map(|(curve, face)| { + CurveFaceIntersection::compute(&curve.path(), face) + }) .collect::<[_; 2]>(); let intersection_intervals = { From 550360c070aae8de1deb80308ccc80a2e3b78bdd Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 24 Feb 2023 13:59:53 +0100 Subject: [PATCH 08/12] Simplify intersection test result --- .../src/algorithms/intersect/face_face.rs | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/face_face.rs b/crates/fj-kernel/src/algorithms/intersect/face_face.rs index d5c7696f1..920cd76a7 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_face.rs @@ -2,9 +2,9 @@ use fj_interop::ext::ArrayExt; use iter_fixed::IntoIteratorFixed; use crate::{ - objects::{Curve, Face, Objects}, + geometry::path::SurfacePath, + objects::{Face, Objects}, services::Service, - storage::Handle, }; use super::{CurveFaceIntersection, SurfaceSurfaceIntersection}; @@ -18,7 +18,7 @@ pub struct FaceFaceIntersection { /// representation of the intersection on the respective face's surface. /// /// They both represent the same global curve. - pub intersection_curves: [Handle; 2], + pub intersection_curves: [SurfacePath; 2], /// The interval of this intersection, in curve coordinates /// @@ -36,7 +36,9 @@ impl FaceFaceIntersection { let intersection_curves = match SurfaceSurfaceIntersection::compute(surfaces, objects) { - Some(intersection) => intersection.intersection_curves, + Some(intersection) => { + intersection.intersection_curves.map(|curve| curve.path()) + } None => return None, }; @@ -44,9 +46,7 @@ impl FaceFaceIntersection { .each_ref_ext() .into_iter_fixed() .zip(faces) - .map(|(curve, face)| { - CurveFaceIntersection::compute(&curve.path(), face) - }) + .map(|(curve, face)| CurveFaceIntersection::compute(curve, face)) .collect::<[_; 2]>(); let intersection_intervals = { @@ -71,9 +71,9 @@ mod tests { use crate::{ algorithms::intersect::CurveFaceIntersection, - builder::{CurveBuilder, CycleBuilder}, - insert::Insert, - partial::{Partial, PartialCurve, PartialFace, PartialObject}, + builder::CycleBuilder, + geometry::path::SurfacePath, + partial::{Partial, PartialFace, PartialObject}, services::Services, }; @@ -139,11 +139,8 @@ mod tests { FaceFaceIntersection::compute([&a, &b], &mut services.objects); let expected_curves = surfaces.map(|_| { - let mut curve = PartialCurve::default(); - curve.update_as_line_from_points([[0., 0.], [1., 0.]]); - curve - .build(&mut services.objects) - .insert(&mut services.objects) + let (path, _) = SurfacePath::line_from_points([[0., 0.], [1., 0.]]); + path }); let expected_intervals = CurveFaceIntersection::from_intervals([[[-1.], [1.]]]); From 879e005ab97cf98e4aa346ab59bea6a56f34880f Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 24 Feb 2023 14:01:59 +0100 Subject: [PATCH 09/12] Simplify intersection test result --- .../src/algorithms/intersect/face_face.rs | 4 +-- .../algorithms/intersect/surface_surface.rs | 31 +++++-------------- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/face_face.rs b/crates/fj-kernel/src/algorithms/intersect/face_face.rs index 920cd76a7..7e6a23b80 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_face.rs @@ -36,9 +36,7 @@ impl FaceFaceIntersection { let intersection_curves = match SurfaceSurfaceIntersection::compute(surfaces, objects) { - Some(intersection) => { - intersection.intersection_curves.map(|curve| curve.path()) - } + Some(intersection) => intersection.intersection_curves, None => return None, }; diff --git a/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs b/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs index 9406e92d4..4b71b2e1a 100644 --- a/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs +++ b/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs @@ -2,8 +2,7 @@ use fj_math::{Line, Plane, Point, Scalar}; use crate::{ geometry::path::{GlobalPath, SurfacePath}, - insert::Insert, - objects::{Curve, Objects, Surface}, + objects::{Objects, Surface}, services::Service, storage::Handle, }; @@ -12,14 +11,14 @@ use crate::{ #[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] pub struct SurfaceSurfaceIntersection { /// The intersection curves - pub intersection_curves: [Handle; 2], + pub intersection_curves: [SurfacePath; 2], } impl SurfaceSurfaceIntersection { /// Compute the intersection between two surfaces pub fn compute( surfaces: [Handle; 2], - objects: &mut Service, + _: &mut Service, ) -> Option { // Algorithm from Real-Time Collision Detection by Christer Ericson. See // section 5.4.4, Intersection of Two Planes. @@ -53,10 +52,8 @@ impl SurfaceSurfaceIntersection { let line = Line::from_origin_and_direction(origin, direction); - let curves = planes.map(|plane| { - let path = SurfacePath::Line(plane.project_line(&line)); - Curve::new(path).insert(objects) - }); + let curves = + planes.map(|plane| SurfacePath::Line(plane.project_line(&line))); Some(Self { intersection_curves: curves, @@ -83,10 +80,7 @@ mod tests { use pretty_assertions::assert_eq; use crate::{ - algorithms::transform::TransformObject, - builder::CurveBuilder, - insert::Insert, - partial::{PartialCurve, PartialObject}, + algorithms::transform::TransformObject, geometry::path::SurfacePath, services::Services, }; @@ -114,17 +108,8 @@ mod tests { None, ); - let mut expected_xy = PartialCurve::default(); - expected_xy.update_as_u_axis(); - let expected_xy = expected_xy - .build(&mut services.objects) - .insert(&mut services.objects); - - let mut expected_xz = PartialCurve::default(); - expected_xz.update_as_u_axis(); - let expected_xz = expected_xz - .build(&mut services.objects) - .insert(&mut services.objects); + let expected_xy = SurfacePath::u_axis(); + let expected_xz = SurfacePath::u_axis(); assert_eq!( SurfaceSurfaceIntersection::compute( From 196df2cd3f481a4b9f3a9b30a301b1f0477f1aea Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 24 Feb 2023 14:03:13 +0100 Subject: [PATCH 10/12] Remove unused argument --- .../src/algorithms/intersect/face_face.rs | 4 +-- .../algorithms/intersect/surface_surface.rs | 30 +++++++------------ 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/face_face.rs b/crates/fj-kernel/src/algorithms/intersect/face_face.rs index 7e6a23b80..9525ed985 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_face.rs @@ -30,12 +30,12 @@ impl FaceFaceIntersection { /// Compute the intersections between two faces pub fn compute( faces: [&Face; 2], - objects: &mut Service, + _: &mut Service, ) -> Option { let surfaces = faces.map(|face| face.surface().clone()); let intersection_curves = - match SurfaceSurfaceIntersection::compute(surfaces, objects) { + match SurfaceSurfaceIntersection::compute(surfaces) { Some(intersection) => intersection.intersection_curves, None => return None, }; diff --git a/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs b/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs index 4b71b2e1a..b6927ff1f 100644 --- a/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs +++ b/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs @@ -2,8 +2,7 @@ use fj_math::{Line, Plane, Point, Scalar}; use crate::{ geometry::path::{GlobalPath, SurfacePath}, - objects::{Objects, Surface}, - services::Service, + objects::Surface, storage::Handle, }; @@ -16,10 +15,7 @@ pub struct SurfaceSurfaceIntersection { impl SurfaceSurfaceIntersection { /// Compute the intersection between two surfaces - pub fn compute( - surfaces: [Handle; 2], - _: &mut Service, - ) -> Option { + pub fn compute(surfaces: [Handle; 2]) -> Option { // Algorithm from Real-Time Collision Detection by Christer Ericson. See // section 5.4.4, Intersection of Two Planes. // @@ -95,16 +91,13 @@ mod tests { // Coincident and parallel planes don't have an intersection curve. assert_eq!( - SurfaceSurfaceIntersection::compute( - [ - xy.clone(), - xy.clone().transform( - &Transform::translation([0., 0., 1.],), - &mut services.objects - ) - ], - &mut services.objects - ), + SurfaceSurfaceIntersection::compute([ + xy.clone(), + xy.clone().transform( + &Transform::translation([0., 0., 1.],), + &mut services.objects + ) + ],), None, ); @@ -112,10 +105,7 @@ mod tests { let expected_xz = SurfacePath::u_axis(); assert_eq!( - SurfaceSurfaceIntersection::compute( - [xy, xz], - &mut services.objects - ), + SurfaceSurfaceIntersection::compute([xy, xz],), Some(SurfaceSurfaceIntersection { intersection_curves: [expected_xy, expected_xz], }) From 870c996411b2b37bac6a10694dc09a864578c2d9 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 24 Feb 2023 14:03:53 +0100 Subject: [PATCH 11/12] Remove unused argument --- .../src/algorithms/intersect/face_face.rs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/face_face.rs b/crates/fj-kernel/src/algorithms/intersect/face_face.rs index 9525ed985..96e2f35a8 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_face.rs @@ -1,11 +1,7 @@ use fj_interop::ext::ArrayExt; use iter_fixed::IntoIteratorFixed; -use crate::{ - geometry::path::SurfacePath, - objects::{Face, Objects}, - services::Service, -}; +use crate::{geometry::path::SurfacePath, objects::Face}; use super::{CurveFaceIntersection, SurfaceSurfaceIntersection}; @@ -28,10 +24,7 @@ pub struct FaceFaceIntersection { impl FaceFaceIntersection { /// Compute the intersections between two faces - pub fn compute( - faces: [&Face; 2], - _: &mut Service, - ) -> Option { + pub fn compute(faces: [&Face; 2]) -> Option { let surfaces = faces.map(|face| face.surface().clone()); let intersection_curves = @@ -102,8 +95,7 @@ mod tests { face.build(&mut services.objects) }); - let intersection = - FaceFaceIntersection::compute([&a, &b], &mut services.objects); + let intersection = FaceFaceIntersection::compute([&a, &b]); assert!(intersection.is_none()); } @@ -133,8 +125,7 @@ mod tests { face.build(&mut services.objects) }); - let intersection = - FaceFaceIntersection::compute([&a, &b], &mut services.objects); + let intersection = FaceFaceIntersection::compute([&a, &b]); let expected_curves = surfaces.map(|_| { let (path, _) = SurfacePath::line_from_points([[0., 0.], [1., 0.]]); From 51623d53285017f3de0d4bc4d46e31f98550ba15 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 24 Feb 2023 14:05:33 +0100 Subject: [PATCH 12/12] Simplify test --- .../src/algorithms/intersect/curve_face.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index fab2a67c7..c6acad738 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -150,8 +150,9 @@ where #[cfg(test)] mod tests { use crate::{ - builder::{CurveBuilder, CycleBuilder, FaceBuilder}, - partial::{Partial, PartialCurve, PartialFace, PartialObject}, + builder::{CycleBuilder, FaceBuilder}, + geometry::path::SurfacePath, + partial::{Partial, PartialFace, PartialObject}, services::Services, }; @@ -161,9 +162,7 @@ mod tests { fn compute() { let mut services = Services::new(); - let mut curve = PartialCurve::default(); - curve.update_as_line_from_points([[-3., 0.], [-2., 0.]]); - let curve = curve.build(&mut services.objects); + let (curve, _) = SurfacePath::line_from_points([[-3., 0.], [-2., 0.]]); #[rustfmt::skip] let exterior = [ @@ -197,10 +196,7 @@ mod tests { let expected = CurveFaceIntersection::from_intervals([[[1.], [2.]], [[4.], [5.]]]); - assert_eq!( - CurveFaceIntersection::compute(&curve.path(), &face), - expected - ); + assert_eq!(CurveFaceIntersection::compute(&curve, &face), expected); } #[test]