From a3b6bd0b1dfa2d8465d12a7a4645a4f02af184d5 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 25 Mar 2024 13:36:14 +0100 Subject: [PATCH 1/6] Refactor to prepare for follow-on change --- crates/fj-core/src/algorithms/approx/curve.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/curve.rs b/crates/fj-core/src/algorithms/approx/curve.rs index 268388251..17b4bfcac 100644 --- a/crates/fj-core/src/algorithms/approx/curve.rs +++ b/crates/fj-core/src/algorithms/approx/curve.rs @@ -192,9 +192,9 @@ mod tests { fn approx_line_on_flat_surface() { let mut core = Core::new(); - let curve = Curve::new().insert(&mut core); let (path, boundary) = SurfacePath::line_from_points([[1., 1.], [2., 1.]]); + let curve = Curve::new().insert(&mut core); let boundary = CurveBoundary::from(boundary); let half_edge = HalfEdgeGeom { path, boundary }; let surface = core.layers.topology.surfaces.xz_plane(); @@ -210,9 +210,9 @@ mod tests { fn approx_line_on_curved_surface_but_not_along_curve() { let mut core = Core::new(); - let curve = Curve::new().insert(&mut core); let (path, boundary) = SurfacePath::line_from_points([[1., 1.], [2., 1.]]); + let curve = Curve::new().insert(&mut core); let boundary = CurveBoundary::from(boundary); let half_edge = HalfEdgeGeom { path, boundary }; let surface = Surface::from_uv( @@ -233,11 +233,11 @@ mod tests { let mut core = Core::new(); let global_path = GlobalPath::circle_from_radius(1.); - let curve = Curve::new().insert(&mut core); let path = SurfacePath::line_from_points_with_coords([ ([0.], [0., 1.]), ([TAU], [TAU, 1.]), ]); + let curve = Curve::new().insert(&mut core); let boundary = CurveBoundary::from([[0.], [TAU]]); let half_edge = HalfEdgeGeom { path, boundary }; let surface = Surface::from_uv(global_path, [0., 0., 1.], &mut core); @@ -266,8 +266,8 @@ mod tests { fn approx_circle_on_flat_surface() { let mut core = Core::new(); - let curve = Curve::new().insert(&mut core); let path = SurfacePath::circle_from_center_and_radius([0., 0.], 1.); + let curve = Curve::new().insert(&mut core); let boundary = CurveBoundary::from([[0.], [TAU]]); let half_edge = HalfEdgeGeom { path, boundary }; let surface = core.layers.topology.surfaces.xz_plane(); From 1c452196dc281d004463b3c9b0f5a3c50378b72e Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 25 Mar 2024 13:37:20 +0100 Subject: [PATCH 2/6] Refactor to prepare for follow-on change --- crates/fj-core/src/algorithms/approx/curve.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/curve.rs b/crates/fj-core/src/algorithms/approx/curve.rs index 17b4bfcac..d14ea7a5c 100644 --- a/crates/fj-core/src/algorithms/approx/curve.rs +++ b/crates/fj-core/src/algorithms/approx/curve.rs @@ -192,12 +192,12 @@ mod tests { fn approx_line_on_flat_surface() { let mut core = Core::new(); + let surface = core.layers.topology.surfaces.xz_plane(); let (path, boundary) = SurfacePath::line_from_points([[1., 1.], [2., 1.]]); let curve = Curve::new().insert(&mut core); let boundary = CurveBoundary::from(boundary); let half_edge = HalfEdgeGeom { path, boundary }; - let surface = core.layers.topology.surfaces.xz_plane(); let tolerance = 1.; let approx = (&curve, &half_edge, &surface) @@ -210,16 +210,16 @@ mod tests { fn approx_line_on_curved_surface_but_not_along_curve() { let mut core = Core::new(); - let (path, boundary) = - SurfacePath::line_from_points([[1., 1.], [2., 1.]]); - let curve = Curve::new().insert(&mut core); - let boundary = CurveBoundary::from(boundary); - let half_edge = HalfEdgeGeom { path, boundary }; let surface = Surface::from_uv( GlobalPath::circle_from_radius(1.), [0., 0., 1.], &mut core, ); + let (path, boundary) = + SurfacePath::line_from_points([[1., 1.], [2., 1.]]); + let curve = Curve::new().insert(&mut core); + let boundary = CurveBoundary::from(boundary); + let half_edge = HalfEdgeGeom { path, boundary }; let tolerance = 1.; let approx = (&curve, &half_edge, &surface) @@ -233,6 +233,7 @@ mod tests { let mut core = Core::new(); let global_path = GlobalPath::circle_from_radius(1.); + let surface = Surface::from_uv(global_path, [0., 0., 1.], &mut core); let path = SurfacePath::line_from_points_with_coords([ ([0.], [0., 1.]), ([TAU], [TAU, 1.]), @@ -240,7 +241,6 @@ mod tests { let curve = Curve::new().insert(&mut core); let boundary = CurveBoundary::from([[0.], [TAU]]); let half_edge = HalfEdgeGeom { path, boundary }; - let surface = Surface::from_uv(global_path, [0., 0., 1.], &mut core); let tolerance = 1.; let approx = (&curve, &half_edge, &surface) @@ -266,11 +266,11 @@ mod tests { fn approx_circle_on_flat_surface() { let mut core = Core::new(); + let surface = core.layers.topology.surfaces.xz_plane(); let path = SurfacePath::circle_from_center_and_radius([0., 0.], 1.); let curve = Curve::new().insert(&mut core); let boundary = CurveBoundary::from([[0.], [TAU]]); let half_edge = HalfEdgeGeom { path, boundary }; - let surface = core.layers.topology.surfaces.xz_plane(); let tolerance = 1.; let approx = (&curve, &half_edge, &surface) From 5e4594fa65a92b325c9a7c748ef199df5eaa806f Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 26 Mar 2024 11:34:38 +0100 Subject: [PATCH 3/6] Refactor to prepare for follow-on change --- crates/fj-core/src/operations/build/half_edge.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/operations/build/half_edge.rs b/crates/fj-core/src/operations/build/half_edge.rs index ab3bdde9f..144bba46f 100644 --- a/crates/fj-core/src/operations/build/half_edge.rs +++ b/crates/fj-core/src/operations/build/half_edge.rs @@ -106,13 +106,17 @@ pub trait BuildHalfEdge { boundary.zip_ext(points_surface), ); - HalfEdge::unjoined(core).insert(core).set_geometry( + let half_edge = HalfEdge::unjoined(core).insert(core); + + core.layers.geometry.define_half_edge( + half_edge.clone(), HalfEdgeGeom { path, boundary: boundary.into(), }, - &mut core.layers.geometry, - ) + ); + + half_edge } } From 8207077338cea0f6ad933dc375742ae86842714b Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 26 Mar 2024 12:37:28 +0100 Subject: [PATCH 4/6] Make variable name more specific --- crates/fj-core/src/operations/reverse/edge.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/fj-core/src/operations/reverse/edge.rs b/crates/fj-core/src/operations/reverse/edge.rs index d0ef5fab8..c32bfbf10 100644 --- a/crates/fj-core/src/operations/reverse/edge.rs +++ b/crates/fj-core/src/operations/reverse/edge.rs @@ -9,9 +9,9 @@ use super::ReverseCurveCoordinateSystems; impl ReverseCurveCoordinateSystems for Handle { fn reverse_curve_coordinate_systems(&self, core: &mut Core) -> Self { - let mut geometry = *core.layers.geometry.of_half_edge(self); - geometry.path = geometry.path.reverse(); - geometry.boundary = geometry.boundary.reverse(); + let mut half_edge_geom = *core.layers.geometry.of_half_edge(self); + half_edge_geom.path = half_edge_geom.path.reverse(); + half_edge_geom.boundary = half_edge_geom.boundary.reverse(); let half_edge = HalfEdge::new(self.curve().clone(), self.start_vertex().clone()) @@ -20,7 +20,7 @@ impl ReverseCurveCoordinateSystems for Handle { core.layers .geometry - .define_half_edge(half_edge.clone(), geometry); + .define_half_edge(half_edge.clone(), half_edge_geom); half_edge } From 9150edc328d032aa0c85a17f97a96d3ded27c06a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 27 Mar 2024 13:22:13 +0100 Subject: [PATCH 5/6] Make variable name more specific --- crates/fj-core/src/algorithms/bounding_volume/half_edge.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/algorithms/bounding_volume/half_edge.rs b/crates/fj-core/src/algorithms/bounding_volume/half_edge.rs index 76523409f..690cf6acc 100644 --- a/crates/fj-core/src/algorithms/bounding_volume/half_edge.rs +++ b/crates/fj-core/src/algorithms/bounding_volume/half_edge.rs @@ -10,8 +10,8 @@ impl super::BoundingVolume<2> for &Handle { fn aabb(self, geometry: &Geometry) -> Option> { let half_edge = self; - let half_edge = geometry.of_half_edge(half_edge); - let path = half_edge.path; + let half_edge_geom = geometry.of_half_edge(half_edge); + let path = half_edge_geom.path; match path { SurfacePath::Circle(circle) => { @@ -27,7 +27,7 @@ impl super::BoundingVolume<2> for &Handle { }) } SurfacePath::Line(_) => { - let points = half_edge.boundary.inner.map(|point_curve| { + let points = half_edge_geom.boundary.inner.map(|point_curve| { path.point_from_path_coords(point_curve) }); From cd046a380b3912988ce06698c3fec4f0d1efddcf Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 27 Mar 2024 13:32:46 +0100 Subject: [PATCH 6/6] Refactor to prepare for follow-on change --- crates/fj-core/src/validate/solid.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-core/src/validate/solid.rs b/crates/fj-core/src/validate/solid.rs index 8ba6a0569..e1de52522 100644 --- a/crates/fj-core/src/validate/solid.rs +++ b/crates/fj-core/src/validate/solid.rs @@ -88,11 +88,11 @@ impl SolidValidationError { face.region() .all_cycles() .flat_map(|cycle| cycle.half_edges().iter().cloned()) - .zip(repeat(geometry.of_surface(face.surface()))) + .zip(repeat(face.surface())) }) .map(|(h, s)| { ( - s.point_from_surface_coords( + geometry.of_surface(s).point_from_surface_coords( geometry.of_half_edge(&h).start_position(), ), h.start_vertex().clone(),