From 9d50557b6169359b51ced8b7de5834cd12c9637c Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 28 Feb 2024 13:11:53 +0100 Subject: [PATCH 1/4] Add `Geometry::of_surface` --- crates/fj-core/src/geometry/geometry.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/fj-core/src/geometry/geometry.rs b/crates/fj-core/src/geometry/geometry.rs index b2e68dea0..5df602ba2 100644 --- a/crates/fj-core/src/geometry/geometry.rs +++ b/crates/fj-core/src/geometry/geometry.rs @@ -54,4 +54,16 @@ impl Geometry { ) { self.surface.insert(surface.clone().into(), geometry); } + + /// # Access the geometry of the provided surface + /// + /// ## Panics + /// + /// Panics, if the geometry of surface is not defined. + pub fn of_surface(&self, surface: &Handle) -> SurfaceGeometry { + self.surface + .get(&surface.clone().into()) + .copied() + .expect("Expected geometry of surface to be defined") + } } From 03d485fb3c438ae4f71e886c59985b74260102a4 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 28 Feb 2024 13:52:50 +0100 Subject: [PATCH 2/4] Remove unnecessary `pub` --- crates/fj-core/src/geometry/geometry.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/fj-core/src/geometry/geometry.rs b/crates/fj-core/src/geometry/geometry.rs index 5df602ba2..792dc93e1 100644 --- a/crates/fj-core/src/geometry/geometry.rs +++ b/crates/fj-core/src/geometry/geometry.rs @@ -11,8 +11,7 @@ use super::{GlobalPath, SurfaceGeometry}; /// Geometric data that is associated with topological objects pub struct Geometry { - /// The geometry of surfaces - pub surface: BTreeMap, SurfaceGeometry>, + surface: BTreeMap, SurfaceGeometry>, } impl Geometry { From 65dffcbc4f53453797f0575f3f480c8963b05029 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 28 Feb 2024 13:15:33 +0100 Subject: [PATCH 3/4] Make basis plane geometry easier to access --- crates/fj-core/src/algorithms/approx/curve.rs | 4 +-- crates/fj-core/src/geometry/geometry.rs | 29 +++++++++++++++++-- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/curve.rs b/crates/fj-core/src/algorithms/approx/curve.rs index 7f4c679a0..e27ca58c6 100644 --- a/crates/fj-core/src/algorithms/approx/curve.rs +++ b/crates/fj-core/src/algorithms/approx/curve.rs @@ -203,7 +203,7 @@ mod tests { let (surface_path, boundary) = SurfacePath::line_from_points([[1., 1.], [2., 1.]]); let boundary = CurveBoundary::from(boundary); - let surface = core.layers.objects.surfaces.xz_plane().geometry(); + let surface = core.layers.geometry.xz_plane(); let tolerance = 1.; let approx = (&curve, surface_path, &surface, boundary) @@ -274,7 +274,7 @@ mod tests { let surface_path = SurfacePath::circle_from_center_and_radius([0., 0.], 1.); let boundary = CurveBoundary::from([[0.], [TAU]]); - let surface = core.layers.objects.surfaces.xz_plane().geometry(); + let surface = core.layers.geometry.xz_plane(); let tolerance = 1.; let approx = (&curve, surface_path, &surface, boundary) diff --git a/crates/fj-core/src/geometry/geometry.rs b/crates/fj-core/src/geometry/geometry.rs index 792dc93e1..3b8f4ee00 100644 --- a/crates/fj-core/src/geometry/geometry.rs +++ b/crates/fj-core/src/geometry/geometry.rs @@ -12,6 +12,10 @@ use super::{GlobalPath, SurfaceGeometry}; /// Geometric data that is associated with topological objects pub struct Geometry { surface: BTreeMap, SurfaceGeometry>, + + xy_plane: Handle, + xz_plane: Handle, + yz_plane: Handle, } impl Geometry { @@ -19,24 +23,28 @@ impl Geometry { pub fn new(objects: &Objects) -> Self { let mut self_ = Self { surface: BTreeMap::new(), + + xy_plane: objects.surfaces.xy_plane(), + xz_plane: objects.surfaces.xz_plane(), + yz_plane: objects.surfaces.yz_plane(), }; self_.define_surface_inner( - objects.surfaces.xy_plane(), + self_.xy_plane.clone(), SurfaceGeometry { u: GlobalPath::x_axis(), v: Vector::unit_y(), }, ); self_.define_surface_inner( - objects.surfaces.xz_plane(), + self_.xz_plane.clone(), SurfaceGeometry { u: GlobalPath::x_axis(), v: Vector::unit_z(), }, ); self_.define_surface_inner( - objects.surfaces.yz_plane(), + self_.yz_plane.clone(), SurfaceGeometry { u: GlobalPath::y_axis(), v: Vector::unit_z(), @@ -65,4 +73,19 @@ impl Geometry { .copied() .expect("Expected geometry of surface to be defined") } + + /// Access the geometry of the xy-plane + pub fn xy_plane(&self) -> SurfaceGeometry { + self.of_surface(&self.xy_plane) + } + + /// Access the geometry of the xz-plane + pub fn xz_plane(&self) -> SurfaceGeometry { + self.of_surface(&self.xz_plane) + } + + /// Access the geometry of the yz-plane + pub fn yz_plane(&self) -> SurfaceGeometry { + self.of_surface(&self.yz_plane) + } } From a6923b35534c497316942924403f174e73ea1377 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 28 Feb 2024 13:34:58 +0100 Subject: [PATCH 4/4] Update formatting --- crates/fj-core/src/objects/any_object.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-core/src/objects/any_object.rs b/crates/fj-core/src/objects/any_object.rs index 6c047e2e2..989f363f9 100644 --- a/crates/fj-core/src/objects/any_object.rs +++ b/crates/fj-core/src/objects/any_object.rs @@ -36,8 +36,8 @@ macro_rules! any_object { /// Validate the object with a pre-defined validation configuration pub fn validate(&self, - config: &ValidationConfig, - errors: &mut Vec + config: &ValidationConfig, + errors: &mut Vec, ) { match self { $(