diff --git a/crates/fj-core/src/algorithms/intersect/ray_face.rs b/crates/fj-core/src/algorithms/intersect/ray_face.rs index 81226b09f..e5cf63e17 100644 --- a/crates/fj-core/src/algorithms/intersect/ray_face.rs +++ b/crates/fj-core/src/algorithms/intersect/ray_face.rs @@ -177,7 +177,7 @@ mod tests { }) .insert(&mut core.services) }); - let face = face.translate([-1., 0., 0.], &mut core.services); + let face = face.translate([-1., 0., 0.], &mut core); assert_eq!((&ray, &face).intersect(), None); } @@ -201,7 +201,7 @@ mod tests { }) .insert(&mut core.services) }); - let face = face.translate([1., 0., 0.], &mut core.services); + let face = face.translate([1., 0., 0.], &mut core); assert_eq!( (&ray, &face).intersect(), @@ -228,7 +228,7 @@ mod tests { }) .insert(&mut core.services) }); - let face = face.translate([0., 0., 2.], &mut core.services); + let face = face.translate([0., 0., 2.], &mut core); assert_eq!((&ray, &face).intersect(), None); } @@ -252,7 +252,7 @@ mod tests { }) .insert(&mut core.services) }); - let face = face.translate([1., 1., 0.], &mut core.services); + let face = face.translate([1., 1., 0.], &mut core); let edge = face .region() @@ -286,7 +286,7 @@ mod tests { }) .insert(&mut core.services) }); - let face = face.translate([1., 1., 1.], &mut core.services); + let face = face.translate([1., 1., 1.], &mut core); let vertex = face .region() @@ -347,7 +347,7 @@ mod tests { }) .insert(&mut core.services) }); - let face = face.translate([0., 0., 1.], &mut core.services); + let face = face.translate([0., 0., 1.], &mut core); assert_eq!((&ray, &face).intersect(), None); } diff --git a/crates/fj-core/src/algorithms/intersect/surface_surface.rs b/crates/fj-core/src/algorithms/intersect/surface_surface.rs index 6938c77c2..2b77545ac 100644 --- a/crates/fj-core/src/algorithms/intersect/surface_surface.rs +++ b/crates/fj-core/src/algorithms/intersect/surface_surface.rs @@ -94,7 +94,7 @@ mod tests { xy.clone(), xy.clone().transform( &Transform::translation([0., 0., 1.],), - &mut core.services + &mut core ) ],), None, diff --git a/crates/fj-core/src/operations/build/shell.rs b/crates/fj-core/src/operations/build/shell.rs index 430d7b7aa..e111964ee 100644 --- a/crates/fj-core/src/operations/build/shell.rs +++ b/crates/fj-core/src/operations/build/shell.rs @@ -152,10 +152,8 @@ pub trait BuildShell { .update_half_edge( cycle.half_edges().nth_circular(0), |edge| { - edge.reverse_curve_coordinate_systems( - &mut core.services, - ) - .insert(&mut core.services) + edge.reverse_curve_coordinate_systems(core) + .insert(&mut core.services) }, ) .join_to( @@ -175,10 +173,8 @@ pub trait BuildShell { .update_half_edge( cycle.half_edges().nth_circular(1), |edge| { - edge.reverse_curve_coordinate_systems( - &mut core.services, - ) - .insert(&mut core.services) + edge.reverse_curve_coordinate_systems(core) + .insert(&mut core.services) }, ) .join_to( @@ -190,10 +186,8 @@ pub trait BuildShell { .update_half_edge( cycle.half_edges().nth_circular(0), |edge| { - edge.reverse_curve_coordinate_systems( - &mut core.services, - ) - .insert(&mut core.services) + edge.reverse_curve_coordinate_systems(core) + .insert(&mut core.services) }, ) .join_to( @@ -213,28 +207,22 @@ pub trait BuildShell { .update_half_edge( cycle.half_edges().nth_circular(0), |edge| { - edge.reverse_curve_coordinate_systems( - &mut core.services, - ) - .insert(&mut core.services) + edge.reverse_curve_coordinate_systems(core) + .insert(&mut core.services) }, ) .update_half_edge( cycle.half_edges().nth_circular(1), |edge| { - edge.reverse_curve_coordinate_systems( - &mut core.services, - ) - .insert(&mut core.services) + edge.reverse_curve_coordinate_systems(core) + .insert(&mut core.services) }, ) .update_half_edge( cycle.half_edges().nth_circular(2), |edge| { - edge.reverse_curve_coordinate_systems( - &mut core.services, - ) - .insert(&mut core.services) + edge.reverse_curve_coordinate_systems(core) + .insert(&mut core.services) }, ) .join_to( diff --git a/crates/fj-core/src/operations/reverse/cycle.rs b/crates/fj-core/src/operations/reverse/cycle.rs index 04a6566d1..53ec902bd 100644 --- a/crates/fj-core/src/operations/reverse/cycle.rs +++ b/crates/fj-core/src/operations/reverse/cycle.rs @@ -1,7 +1,6 @@ use crate::{ objects::{Cycle, HalfEdge}, operations::insert::Insert, - services::Services, Instance, }; @@ -30,13 +29,10 @@ impl Reverse for Cycle { } impl ReverseCurveCoordinateSystems for Cycle { - fn reverse_curve_coordinate_systems( - &self, - services: &mut Services, - ) -> Self { + fn reverse_curve_coordinate_systems(&self, core: &mut Instance) -> Self { let edges = self.half_edges().iter().map(|edge| { - edge.reverse_curve_coordinate_systems(services) - .insert(services) + edge.reverse_curve_coordinate_systems(core) + .insert(&mut core.services) }); Cycle::new(edges) diff --git a/crates/fj-core/src/operations/reverse/edge.rs b/crates/fj-core/src/operations/reverse/edge.rs index 3820d0422..95c1a35c5 100644 --- a/crates/fj-core/src/operations/reverse/edge.rs +++ b/crates/fj-core/src/operations/reverse/edge.rs @@ -1,9 +1,9 @@ -use crate::{objects::HalfEdge, services::Services}; +use crate::{objects::HalfEdge, Instance}; use super::ReverseCurveCoordinateSystems; impl ReverseCurveCoordinateSystems for HalfEdge { - fn reverse_curve_coordinate_systems(&self, _: &mut Services) -> Self { + fn reverse_curve_coordinate_systems(&self, _: &mut Instance) -> Self { let path = self.path().reverse(); let boundary = self.boundary().reverse(); diff --git a/crates/fj-core/src/operations/reverse/face.rs b/crates/fj-core/src/operations/reverse/face.rs index d3f7f3afe..bf8dd0e56 100644 --- a/crates/fj-core/src/operations/reverse/face.rs +++ b/crates/fj-core/src/operations/reverse/face.rs @@ -6,7 +6,6 @@ use crate::{ build::Polygon, insert::{Insert, IsInsertedNo, IsInsertedYes}, }, - services::Services, Instance, }; @@ -36,14 +35,11 @@ impl Reverse for Polygon { } impl ReverseCurveCoordinateSystems for Face { - fn reverse_curve_coordinate_systems( - &self, - services: &mut Services, - ) -> Self { + fn reverse_curve_coordinate_systems(&self, core: &mut Instance) -> Self { let region = self .region() - .reverse_curve_coordinate_systems(services) - .insert(services); + .reverse_curve_coordinate_systems(core) + .insert(&mut core.services); Face::new(self.surface().clone(), region) } } @@ -51,14 +47,8 @@ impl ReverseCurveCoordinateSystems for Face { impl ReverseCurveCoordinateSystems for Polygon { - fn reverse_curve_coordinate_systems( - &self, - services: &mut Services, - ) -> Self { - let face = self - .face - .borrow() - .reverse_curve_coordinate_systems(services); + fn reverse_curve_coordinate_systems(&self, core: &mut Instance) -> Self { + let face = self.face.borrow().reverse_curve_coordinate_systems(core); self.replace_face(face) } } @@ -66,14 +56,11 @@ impl ReverseCurveCoordinateSystems impl ReverseCurveCoordinateSystems for Polygon { - fn reverse_curve_coordinate_systems( - &self, - services: &mut Services, - ) -> Self { + fn reverse_curve_coordinate_systems(&self, core: &mut Instance) -> Self { let face: &Face = self.face.borrow(); let face = face - .reverse_curve_coordinate_systems(services) - .insert(services); + .reverse_curve_coordinate_systems(core) + .insert(&mut core.services); self.replace_face(face) } diff --git a/crates/fj-core/src/operations/reverse/mod.rs b/crates/fj-core/src/operations/reverse/mod.rs index 86b9b88ce..3ebad8284 100644 --- a/crates/fj-core/src/operations/reverse/mod.rs +++ b/crates/fj-core/src/operations/reverse/mod.rs @@ -1,6 +1,6 @@ //! Reverse the direction/orientation of objects -use crate::{services::Services, Instance}; +use crate::Instance; mod cycle; mod edge; @@ -20,6 +20,5 @@ pub trait ReverseCurveCoordinateSystems { /// /// This will not have any effect on object positions in global coordinates. #[must_use] - fn reverse_curve_coordinate_systems(&self, services: &mut Services) - -> Self; + fn reverse_curve_coordinate_systems(&self, core: &mut Instance) -> Self; } diff --git a/crates/fj-core/src/operations/reverse/region.rs b/crates/fj-core/src/operations/reverse/region.rs index 638ca675e..624719a02 100644 --- a/crates/fj-core/src/operations/reverse/region.rs +++ b/crates/fj-core/src/operations/reverse/region.rs @@ -1,6 +1,4 @@ -use crate::{ - objects::Region, operations::insert::Insert, services::Services, Instance, -}; +use crate::{objects::Region, operations::insert::Insert, Instance}; use super::{Reverse, ReverseCurveCoordinateSystems}; @@ -17,18 +15,15 @@ impl Reverse for Region { } impl ReverseCurveCoordinateSystems for Region { - fn reverse_curve_coordinate_systems( - &self, - services: &mut Services, - ) -> Self { + fn reverse_curve_coordinate_systems(&self, core: &mut Instance) -> Self { let exterior = self .exterior() - .reverse_curve_coordinate_systems(services) - .insert(services); + .reverse_curve_coordinate_systems(core) + .insert(&mut core.services); let interiors = self.interiors().iter().map(|cycle| { cycle - .reverse_curve_coordinate_systems(services) - .insert(services) + .reverse_curve_coordinate_systems(core) + .insert(&mut core.services) }); Region::new(exterior, interiors, self.color()) diff --git a/crates/fj-core/src/operations/sweep/region.rs b/crates/fj-core/src/operations/sweep/region.rs index bc54c7148..2388c421a 100644 --- a/crates/fj-core/src/operations/sweep/region.rs +++ b/crates/fj-core/src/operations/sweep/region.rs @@ -77,9 +77,8 @@ impl SweepRegion for Region { .collect::>(); let top_face = { - let top_surface = surface - .translate(path, &mut core.services) - .insert(&mut core.services); + let top_surface = + surface.translate(path, core).insert(&mut core.services); let top_region = Region::new(top_exterior, top_interiors, self.color()) .insert(&mut core.services); diff --git a/crates/fj-core/src/operations/transform/curve.rs b/crates/fj-core/src/operations/transform/curve.rs index 0651e69dd..5b17aed34 100644 --- a/crates/fj-core/src/operations/transform/curve.rs +++ b/crates/fj-core/src/operations/transform/curve.rs @@ -1,6 +1,6 @@ use fj_math::Transform; -use crate::{objects::Curve, services::Services}; +use crate::{objects::Curve, Instance}; use super::{TransformCache, TransformObject}; @@ -8,7 +8,7 @@ impl TransformObject for Curve { fn transform_with_cache( &self, _: &Transform, - _: &mut Services, + _: &mut Instance, _: &mut TransformCache, ) -> Self { // There's nothing to actually transform here, as `Curve` holds no data. diff --git a/crates/fj-core/src/operations/transform/cycle.rs b/crates/fj-core/src/operations/transform/cycle.rs index 66e2938ef..6f64536da 100644 --- a/crates/fj-core/src/operations/transform/cycle.rs +++ b/crates/fj-core/src/operations/transform/cycle.rs @@ -1,6 +1,6 @@ use fj_math::Transform; -use crate::{objects::Cycle, services::Services}; +use crate::{objects::Cycle, Instance}; use super::{TransformCache, TransformObject}; @@ -8,12 +8,11 @@ impl TransformObject for Cycle { fn transform_with_cache( &self, transform: &Transform, - services: &mut Services, + core: &mut Instance, cache: &mut TransformCache, ) -> Self { let edges = self.half_edges().iter().map(|edge| { - edge.clone() - .transform_with_cache(transform, services, cache) + edge.clone().transform_with_cache(transform, core, cache) }); Self::new(edges) diff --git a/crates/fj-core/src/operations/transform/edge.rs b/crates/fj-core/src/operations/transform/edge.rs index 3ccba88cc..78781bf1e 100644 --- a/crates/fj-core/src/operations/transform/edge.rs +++ b/crates/fj-core/src/operations/transform/edge.rs @@ -1,6 +1,6 @@ use fj_math::Transform; -use crate::{objects::HalfEdge, services::Services}; +use crate::{objects::HalfEdge, Instance}; use super::{TransformCache, TransformObject}; @@ -8,7 +8,7 @@ impl TransformObject for HalfEdge { fn transform_with_cache( &self, transform: &Transform, - services: &mut Services, + core: &mut Instance, cache: &mut TransformCache, ) -> Self { // Don't need to transform the path, as that's defined in surface @@ -18,11 +18,11 @@ impl TransformObject for HalfEdge { let curve = self .curve() .clone() - .transform_with_cache(transform, services, cache); + .transform_with_cache(transform, core, cache); let start_vertex = self .start_vertex() .clone() - .transform_with_cache(transform, services, cache); + .transform_with_cache(transform, core, cache); Self::new(path, boundary, curve, start_vertex) } diff --git a/crates/fj-core/src/operations/transform/face.rs b/crates/fj-core/src/operations/transform/face.rs index 684271bb5..f217a1c18 100644 --- a/crates/fj-core/src/operations/transform/face.rs +++ b/crates/fj-core/src/operations/transform/face.rs @@ -1,6 +1,6 @@ use fj_math::Transform; -use crate::{objects::Face, services::Services}; +use crate::{objects::Face, Instance}; use super::{TransformCache, TransformObject}; @@ -8,17 +8,17 @@ impl TransformObject for Face { fn transform_with_cache( &self, transform: &Transform, - services: &mut Services, + core: &mut Instance, cache: &mut TransformCache, ) -> Self { let surface = self .surface() .clone() - .transform_with_cache(transform, services, cache); + .transform_with_cache(transform, core, cache); let region = self .region() .clone() - .transform_with_cache(transform, services, cache); + .transform_with_cache(transform, core, cache); Self::new(surface, region) } diff --git a/crates/fj-core/src/operations/transform/mod.rs b/crates/fj-core/src/operations/transform/mod.rs index e37de3d59..f31e65de0 100644 --- a/crates/fj-core/src/operations/transform/mod.rs +++ b/crates/fj-core/src/operations/transform/mod.rs @@ -17,8 +17,8 @@ use type_map::TypeMap; use crate::{ operations::insert::Insert, - services::Services, storage::{Handle, ObjectId}, + Instance, }; /// Transform an object @@ -32,20 +32,16 @@ use crate::{ /// hasn't been done so far, is that no one has put in the work yet. pub trait TransformObject: Sized { /// Transform the object - fn transform( - &self, - transform: &Transform, - services: &mut Services, - ) -> Self { + fn transform(&self, transform: &Transform, core: &mut Instance) -> Self { let mut cache = TransformCache::default(); - self.transform_with_cache(transform, services, &mut cache) + self.transform_with_cache(transform, core, &mut cache) } /// Transform the object using the provided cache fn transform_with_cache( &self, transform: &Transform, - services: &mut Services, + core: &mut Instance, cache: &mut TransformCache, ) -> Self; @@ -55,9 +51,9 @@ pub trait TransformObject: Sized { fn translate( &self, offset: impl Into>, - services: &mut Services, + core: &mut Instance, ) -> Self { - self.transform(&Transform::translation(offset), services) + self.transform(&Transform::translation(offset), core) } /// Rotate the object @@ -66,9 +62,9 @@ pub trait TransformObject: Sized { fn rotate( &self, axis_angle: impl Into>, - services: &mut Services, + core: &mut Instance, ) -> Self { - self.transform(&Transform::rotation(axis_angle), services) + self.transform(&Transform::rotation(axis_angle), core) } } @@ -79,7 +75,7 @@ where fn transform_with_cache( &self, transform: &Transform, - services: &mut Services, + core: &mut Instance, cache: &mut TransformCache, ) -> Self { if let Some(object) = cache.get(self) { @@ -88,8 +84,8 @@ where let transformed = self .clone_object() - .transform_with_cache(transform, services, cache) - .insert(services); + .transform_with_cache(transform, core, cache) + .insert(&mut core.services); cache.insert(self.clone(), transformed.clone()); diff --git a/crates/fj-core/src/operations/transform/region.rs b/crates/fj-core/src/operations/transform/region.rs index 3cef63d47..48e79e2bf 100644 --- a/crates/fj-core/src/operations/transform/region.rs +++ b/crates/fj-core/src/operations/transform/region.rs @@ -1,4 +1,4 @@ -use crate::objects::Region; +use crate::{objects::Region, Instance}; use super::TransformObject; @@ -6,7 +6,7 @@ impl TransformObject for Region { fn transform_with_cache( &self, transform: &fj_math::Transform, - services: &mut crate::services::Services, + core: &mut Instance, cache: &mut super::TransformCache, ) -> Self { // Color does not need to be transformed. @@ -15,9 +15,9 @@ impl TransformObject for Region { let exterior = self .exterior() .clone() - .transform_with_cache(transform, services, cache); + .transform_with_cache(transform, core, cache); let interiors = self.interiors().iter().cloned().map(|interior| { - interior.transform_with_cache(transform, services, cache) + interior.transform_with_cache(transform, core, cache) }); Region::new(exterior, interiors, color) diff --git a/crates/fj-core/src/operations/transform/shell.rs b/crates/fj-core/src/operations/transform/shell.rs index bb7cfba46..4132b6af1 100644 --- a/crates/fj-core/src/operations/transform/shell.rs +++ b/crates/fj-core/src/operations/transform/shell.rs @@ -1,6 +1,6 @@ use fj_math::Transform; -use crate::{objects::Shell, services::Services}; +use crate::{objects::Shell, Instance}; use super::{TransformCache, TransformObject}; @@ -8,13 +8,14 @@ impl TransformObject for Shell { fn transform_with_cache( &self, transform: &Transform, - services: &mut Services, + core: &mut Instance, cache: &mut TransformCache, ) -> Self { - let faces = - self.faces().iter().cloned().map(|face| { - face.transform_with_cache(transform, services, cache) - }); + let faces = self + .faces() + .iter() + .cloned() + .map(|face| face.transform_with_cache(transform, core, cache)); Self::new(faces) } diff --git a/crates/fj-core/src/operations/transform/solid.rs b/crates/fj-core/src/operations/transform/solid.rs index b0a77e2a8..a1c3ddb66 100644 --- a/crates/fj-core/src/operations/transform/solid.rs +++ b/crates/fj-core/src/operations/transform/solid.rs @@ -1,6 +1,6 @@ use fj_math::Transform; -use crate::{objects::Solid, services::Services}; +use crate::{objects::Solid, Instance}; use super::{TransformCache, TransformObject}; @@ -8,12 +8,13 @@ impl TransformObject for Solid { fn transform_with_cache( &self, transform: &Transform, - services: &mut Services, + core: &mut Instance, cache: &mut TransformCache, ) -> Self { - let shells = self.shells().iter().cloned().map(|shell| { - shell.transform_with_cache(transform, services, cache) - }); + let shells = + self.shells().iter().cloned().map(|shell| { + shell.transform_with_cache(transform, core, cache) + }); Self::new(shells) } diff --git a/crates/fj-core/src/operations/transform/surface.rs b/crates/fj-core/src/operations/transform/surface.rs index 5ae5fa21d..eb21e06d0 100644 --- a/crates/fj-core/src/operations/transform/surface.rs +++ b/crates/fj-core/src/operations/transform/surface.rs @@ -1,6 +1,6 @@ use fj_math::Transform; -use crate::{objects::Surface, services::Services}; +use crate::{objects::Surface, Instance}; use super::{TransformCache, TransformObject}; @@ -8,7 +8,7 @@ impl TransformObject for Surface { fn transform_with_cache( &self, transform: &Transform, - _: &mut Services, + _: &mut Instance, _: &mut TransformCache, ) -> Self { let geometry = self.geometry().transform(transform); diff --git a/crates/fj-core/src/operations/transform/vertex.rs b/crates/fj-core/src/operations/transform/vertex.rs index 02854d44f..c89bbe38a 100644 --- a/crates/fj-core/src/operations/transform/vertex.rs +++ b/crates/fj-core/src/operations/transform/vertex.rs @@ -1,6 +1,6 @@ use fj_math::Transform; -use crate::{objects::Vertex, services::Services}; +use crate::{objects::Vertex, Instance}; use super::{TransformCache, TransformObject}; @@ -8,7 +8,7 @@ impl TransformObject for Vertex { fn transform_with_cache( &self, _: &Transform, - _: &mut Services, + _: &mut Instance, _: &mut TransformCache, ) -> Self { // There's nothing to actually transform here, as `Vertex` holds no diff --git a/models/all/src/lib.rs b/models/all/src/lib.rs index 736b39820..d4f8e0c9e 100644 --- a/models/all/src/lib.rs +++ b/models/all/src/lib.rs @@ -33,8 +33,8 @@ pub fn model(core: &mut fj::core::Instance) -> Solid { let f = i as f64; let model = model - .translate(offset * f, &mut core.services) - .rotate(axis * angle_rad * f, &mut core.services); + .translate(offset * f, core) + .rotate(axis * angle_rad * f, core); all = all.merge(&model); }