From 2174bef87918ea8f16cf74e525fe9317bd670ee9 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 13:46:10 +0100 Subject: [PATCH] Relax method argument --- .../src/algorithms/intersect/curve_face.rs | 5 ++++- .../src/algorithms/intersect/face_face.rs | 10 ++++++++-- .../src/algorithms/intersect/face_point.rs | 18 +++++++++--------- .../src/algorithms/intersect/ray_face.rs | 16 ++++++++-------- crates/fj-kernel/src/algorithms/sweep/face.rs | 18 ++++++++++++++---- .../src/algorithms/triangulate/mod.rs | 12 +++++++++--- crates/fj-kernel/src/builder/face.rs | 10 +++------- crates/fj-kernel/src/builder/shell.rs | 2 +- crates/fj-kernel/src/builder/sketch.rs | 7 +++++-- crates/fj-kernel/src/iter.rs | 4 ++-- crates/fj-kernel/src/validate/face.rs | 4 ++-- crates/fj-operations/src/sketch.rs | 5 ++++- 12 files changed, 69 insertions(+), 42 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index b5cf9b76f..383e6fa45 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -187,7 +187,10 @@ mod tests { let face = { let mut face = PartialFace::default(); - face.with_exterior_polygon_from_points(surface.clone(), exterior); + face.with_exterior_polygon_from_points( + Partial::from_full_entry_point(surface.clone()), + exterior, + ); face.with_interior_polygon_from_points( Partial::from_full_entry_point(surface), interior, diff --git a/crates/fj-kernel/src/algorithms/intersect/face_face.rs b/crates/fj-kernel/src/algorithms/intersect/face_face.rs index 8afb76673..3f38743e6 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_face.rs @@ -94,7 +94,10 @@ mod tests { ] .map(|surface| { let mut face = PartialFace::default(); - face.with_exterior_polygon_from_points(surface, points); + face.with_exterior_polygon_from_points( + Partial::from_full_entry_point(surface), + points, + ); face.build(&mut services.objects) }); @@ -122,7 +125,10 @@ mod tests { ]; let [a, b] = surfaces.clone().map(|surface| { let mut face = PartialFace::default(); - face.with_exterior_polygon_from_points(surface, points); + face.with_exterior_polygon_from_points( + Partial::from_full_entry_point(surface), + points, + ); face.build(&mut services.objects) }); diff --git a/crates/fj-kernel/src/algorithms/intersect/face_point.rs b/crates/fj-kernel/src/algorithms/intersect/face_point.rs index 630dd81bc..122c689c6 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_point.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_point.rs @@ -139,7 +139,7 @@ mod tests { builder::FaceBuilder, insert::Insert, iter::ObjectIters, - partial::{PartialFace, PartialObject}, + partial::{Partial, PartialFace, PartialObject}, services::Services, }; @@ -150,7 +150,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[0., 0.], [1., 1.], [0., 2.]], ); let face = face @@ -169,7 +169,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[0., 0.], [2., 1.], [0., 2.]], ); let face = face @@ -191,7 +191,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[4., 2.], [0., 4.], [0., 0.]], ); let face = face @@ -213,7 +213,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[0., 0.], [2., 1.], [3., 0.], [3., 4.]], ); let face = face @@ -235,7 +235,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[0., 0.], [2., 1.], [3., 1.], [0., 2.]], ); let face = face @@ -257,7 +257,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[0., 0.], [2., 1.], [3., 1.], [4., 0.], [4., 5.]], ); let face = face @@ -279,7 +279,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[0., 0.], [2., 0.], [0., 1.]], ); let face = face @@ -310,7 +310,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[0., 0.], [1., 0.], [0., 1.]], ); let face = face diff --git a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs index 76907a400..3050d5724 100644 --- a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs @@ -155,7 +155,7 @@ mod tests { builder::FaceBuilder, insert::Insert, iter::ObjectIters, - partial::{PartialFace, PartialObject}, + partial::{Partial, PartialFace, PartialObject}, services::Services, }; @@ -168,7 +168,7 @@ mod tests { let surface = services.objects.surfaces.yz_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], ); let face = face @@ -188,7 +188,7 @@ mod tests { let surface = services.objects.surfaces.yz_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], ); let face = face @@ -211,7 +211,7 @@ mod tests { let surface = services.objects.surfaces.yz_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], ); let face = face @@ -231,7 +231,7 @@ mod tests { let surface = services.objects.surfaces.yz_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], ); let face = face @@ -262,7 +262,7 @@ mod tests { let surface = services.objects.surfaces.yz_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], ); let face = face @@ -291,7 +291,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], ); let face = face @@ -313,7 +313,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], ); let face = face diff --git a/crates/fj-kernel/src/algorithms/sweep/face.rs b/crates/fj-kernel/src/algorithms/sweep/face.rs index b4044c2db..0cb5b7bf0 100644 --- a/crates/fj-kernel/src/algorithms/sweep/face.rs +++ b/crates/fj-kernel/src/algorithms/sweep/face.rs @@ -113,14 +113,19 @@ mod tests { .sweep(UP, &mut services.objects); let mut bottom = PartialFace::default(); - bottom.with_exterior_polygon_from_points(surface.clone(), TRIANGLE); + bottom.with_exterior_polygon_from_points( + Partial::from_full_entry_point(surface.clone()), + TRIANGLE, + ); let bottom = bottom .build(&mut services.objects) .insert(&mut services.objects) .reverse(&mut services.objects); let mut top = PartialFace::default(); top.with_exterior_polygon_from_points( - surface.translate(UP, &mut services.objects), + Partial::from_full_entry_point( + surface.translate(UP, &mut services.objects), + ), TRIANGLE, ); let top = top @@ -169,7 +174,9 @@ mod tests { let mut bottom = PartialFace::default(); bottom.with_exterior_polygon_from_points( - surface.clone().translate(DOWN, &mut services.objects), + Partial::from_full_entry_point( + surface.clone().translate(DOWN, &mut services.objects), + ), TRIANGLE, ); let bottom = bottom @@ -177,7 +184,10 @@ mod tests { .insert(&mut services.objects) .reverse(&mut services.objects); let mut top = PartialFace::default(); - top.with_exterior_polygon_from_points(surface, TRIANGLE); + top.with_exterior_polygon_from_points( + Partial::from_full_entry_point(surface), + TRIANGLE, + ); let top = top .build(&mut services.objects) .insert(&mut services.objects); diff --git a/crates/fj-kernel/src/algorithms/triangulate/mod.rs b/crates/fj-kernel/src/algorithms/triangulate/mod.rs index f663c3714..3776989ba 100644 --- a/crates/fj-kernel/src/algorithms/triangulate/mod.rs +++ b/crates/fj-kernel/src/algorithms/triangulate/mod.rs @@ -98,7 +98,10 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); - face.with_exterior_polygon_from_points(surface, [a, b, c, d]); + face.with_exterior_polygon_from_points( + Partial::from_full_entry_point(surface), + [a, b, c, d], + ); let face = face .build(&mut services.objects) .insert(&mut services.objects); @@ -134,7 +137,10 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); - face.with_exterior_polygon_from_points(surface.clone(), [a, b, c, d]); + face.with_exterior_polygon_from_points( + Partial::from_full_entry_point(surface.clone()), + [a, b, c, d], + ); face.with_interior_polygon_from_points( Partial::from_full_entry_point(surface.clone()), [e, f, g, h], @@ -197,7 +203,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface.clone(), + Partial::from_full_entry_point(surface.clone()), [a, b, c, d, e], ); let face = face diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index ebbac4eca..30605c8e3 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -3,7 +3,6 @@ use fj_math::Point; use crate::{ objects::Surface, partial::{Partial, PartialCycle, PartialFace}, - storage::Handle, }; use super::CycleBuilder; @@ -13,7 +12,7 @@ pub trait FaceBuilder { /// Update the [`PartialFace`] with an exterior polygon fn with_exterior_polygon_from_points( &mut self, - surface: Handle, + surface: Partial, points: impl IntoIterator>>, ); @@ -28,14 +27,11 @@ pub trait FaceBuilder { impl FaceBuilder for PartialFace { fn with_exterior_polygon_from_points( &mut self, - surface: Handle, + surface: Partial, points: impl IntoIterator>>, ) { let mut cycle = PartialCycle::default(); - cycle.with_poly_chain_from_points( - Partial::from_full_entry_point(surface), - points, - ); + cycle.with_poly_chain_from_points(surface, points); cycle.close_with_line_segment(); self.exterior = Partial::from_partial(cycle); diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index 3dd32888e..eecedc379 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -55,7 +55,7 @@ impl ShellBuilder { let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[-h, -h], [h, -h], [h, h], [-h, h]], ); diff --git a/crates/fj-kernel/src/builder/sketch.rs b/crates/fj-kernel/src/builder/sketch.rs index 20682748b..701c39857 100644 --- a/crates/fj-kernel/src/builder/sketch.rs +++ b/crates/fj-kernel/src/builder/sketch.rs @@ -3,7 +3,7 @@ use fj_math::Point; use crate::{ insert::Insert, objects::{Face, FaceSet, Objects, Sketch, Surface}, - partial::{PartialFace, PartialObject}, + partial::{Partial, PartialFace, PartialObject}, services::Service, storage::Handle, }; @@ -36,7 +36,10 @@ impl SketchBuilder { objects: &mut Service, ) -> Self { let mut face = PartialFace::default(); - face.with_exterior_polygon_from_points(surface, points); + face.with_exterior_polygon_from_points( + Partial::from_full_entry_point(surface), + points, + ); let face = face.build(objects).insert(objects); self.faces.extend([face]); diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index e5820ecf7..649a86726 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -440,7 +440,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut object = PartialFace::default(); object.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[0., 0.], [1., 0.], [0., 1.]], ); let object = object @@ -558,7 +558,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[0., 0.], [1., 0.], [0., 1.]], ); let face = face diff --git a/crates/fj-kernel/src/validate/face.rs b/crates/fj-kernel/src/validate/face.rs index a89e42d4d..05660334c 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -122,7 +122,7 @@ mod tests { let valid = { let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface.clone(), + Partial::from_full_entry_point(surface.clone()), [[0., 0.], [3., 0.], [0., 3.]], ); face.with_interior_polygon_from_points( @@ -162,7 +162,7 @@ mod tests { let valid = { let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface.clone(), + Partial::from_full_entry_point(surface.clone()), [[0., 0.], [3., 0.], [0., 3.]], ); face.with_interior_polygon_from_points( diff --git a/crates/fj-operations/src/sketch.rs b/crates/fj-operations/src/sketch.rs index 859dd23ae..4fb98eb79 100644 --- a/crates/fj-operations/src/sketch.rs +++ b/crates/fj-operations/src/sketch.rs @@ -60,7 +60,10 @@ impl Shape for fj::Sketch { .map(Point::from); let mut face = PartialFace::default(); - face.with_exterior_polygon_from_points(surface, points); + face.with_exterior_polygon_from_points( + Partial::from_full_entry_point(surface), + points, + ); face.color = Some(Color(self.color())); face.build(objects).insert(objects)