From da991f52a4a949ce7e6314542ba50da110639bfc Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 12 Dec 2023 10:51:21 +0100 Subject: [PATCH 1/4] Add `HoleLocation` --- crates/fj-core/src/operations/holes.rs | 23 +++++++++++++++-------- models/holes/src/lib.rs | 12 +++++++++--- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/crates/fj-core/src/operations/holes.rs b/crates/fj-core/src/operations/holes.rs index 4d408f8d8..5c37a406d 100644 --- a/crates/fj-core/src/operations/holes.rs +++ b/crates/fj-core/src/operations/holes.rs @@ -21,8 +21,7 @@ pub trait AddHole { /// Add a blind hole to the provided face of the shell fn add_blind_hole( &self, - face: &Handle, - position: impl Into>, + location: HoleLocation, radius: impl Into, path: impl Into>, services: &mut Services, @@ -32,14 +31,13 @@ pub trait AddHole { impl AddHole for Shell { fn add_blind_hole( &self, - face: &Handle, - position: impl Into>, + location: HoleLocation, radius: impl Into, path: impl Into>, services: &mut Services, ) -> Self { - let half_edge = - HalfEdge::circle(position, radius, services).insert(services); + let half_edge = HalfEdge::circle(location.position, radius, services) + .insert(services); let hole = Region::empty(services) .update_exterior(|_| { Cycle::empty() @@ -47,7 +45,7 @@ impl AddHole for Shell { .insert(services) }) .sweep_region( - face.surface(), + location.face.surface(), path, &mut SweepCache::default(), services, @@ -56,7 +54,7 @@ impl AddHole for Shell { .map(|face| face.insert(services)) .collect::>(); - self.update_face(face, |face| { + self.update_face(location.face, |face| { face.update_region(|region| { region .add_interiors([Cycle::empty() @@ -76,3 +74,12 @@ impl AddHole for Shell { .add_faces(hole) } } + +/// Defines the location of a hole +pub struct HoleLocation<'r> { + /// The face that the hole is in + pub face: &'r Handle, + + /// The position of the hole within the face, in surface coordinates + pub position: Point<2>, +} diff --git a/models/holes/src/lib.rs b/models/holes/src/lib.rs index 7867b17c7..c61f04e2c 100644 --- a/models/holes/src/lib.rs +++ b/models/holes/src/lib.rs @@ -1,7 +1,11 @@ use fj::{ core::{ objects::Solid, - operations::{holes::AddHole, insert::Insert, update::UpdateSolid}, + operations::{ + holes::{AddHole, HoleLocation}, + insert::Insert, + update::UpdateSolid, + }, services::Services, storage::Handle, }, @@ -26,8 +30,10 @@ pub fn model( shell .add_blind_hole( - bottom_face, - hole_position, + HoleLocation { + face: bottom_face, + position: hole_position.into(), + }, radius, [Scalar::ZERO, Scalar::ZERO, depth], services, From a1abff54353ee0092adeb4fa05bf02ae519fb735 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 12 Dec 2023 10:56:06 +0100 Subject: [PATCH 2/4] Update doc comment --- crates/fj-core/src/operations/holes.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-core/src/operations/holes.rs b/crates/fj-core/src/operations/holes.rs index 5c37a406d..20d90a5ab 100644 --- a/crates/fj-core/src/operations/holes.rs +++ b/crates/fj-core/src/operations/holes.rs @@ -18,7 +18,7 @@ use super::{ /// Add a hole to a [`Shell`] pub trait AddHole { - /// Add a blind hole to the provided face of the shell + /// Add a blind hole at the provided location fn add_blind_hole( &self, location: HoleLocation, From 49cf9aedccdfeb6c758b207576e14916cfd45e79 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 12 Dec 2023 11:27:53 +0100 Subject: [PATCH 3/4] Inline redundant variable --- models/holes/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/models/holes/src/lib.rs b/models/holes/src/lib.rs index c61f04e2c..39418e5b5 100644 --- a/models/holes/src/lib.rs +++ b/models/holes/src/lib.rs @@ -25,14 +25,13 @@ pub fn model( .update_shell(cuboid.shells().first(), |shell| { let bottom_face = shell.faces().first(); - let hole_position = [0., 0.]; let depth = size / 2.; shell .add_blind_hole( HoleLocation { face: bottom_face, - position: hole_position.into(), + position: [0., 0.].into(), }, radius, [Scalar::ZERO, Scalar::ZERO, depth], From 0d5313883c86750f2292b622437ea80dfe9f9c79 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 12 Dec 2023 11:28:03 +0100 Subject: [PATCH 4/4] Remove redundant whitespace --- models/holes/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/models/holes/src/lib.rs b/models/holes/src/lib.rs index 39418e5b5..2ab641a71 100644 --- a/models/holes/src/lib.rs +++ b/models/holes/src/lib.rs @@ -24,7 +24,6 @@ pub fn model( cuboid .update_shell(cuboid.shells().first(), |shell| { let bottom_face = shell.faces().first(); - let depth = size / 2.; shell