diff --git a/crates/fj-core/src/operations/holes.rs b/crates/fj-core/src/operations/holes.rs index 4d408f8d8..20d90a5ab 100644 --- a/crates/fj-core/src/operations/holes.rs +++ b/crates/fj-core/src/operations/holes.rs @@ -18,11 +18,10 @@ 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, - 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..2ab641a71 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, }, @@ -20,14 +24,14 @@ pub fn model( cuboid .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( - bottom_face, - hole_position, + HoleLocation { + face: bottom_face, + position: [0., 0.].into(), + }, radius, [Scalar::ZERO, Scalar::ZERO, depth], services,