From f3aff3baa637b398bc4598fa307ccb5f2ff936bc Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 9 Jul 2024 20:22:05 +0200 Subject: [PATCH 01/10] Remove unused `HalfEdgeGeom::start_position` --- crates/fj-core/src/geometry/half_edge.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/crates/fj-core/src/geometry/half_edge.rs b/crates/fj-core/src/geometry/half_edge.rs index 6f8e2730b..da4189faa 100644 --- a/crates/fj-core/src/geometry/half_edge.rs +++ b/crates/fj-core/src/geometry/half_edge.rs @@ -1,6 +1,6 @@ use fj_math::Point; -use super::{CurveBoundary, SurfacePath}; +use super::CurveBoundary; /// The geometry of a half-edge #[derive(Copy, Clone, Debug)] @@ -18,14 +18,4 @@ impl HalfEdgeGeom { self.boundary = boundary.into(); self } - - /// Compute the surface position where the half-edge starts - pub fn start_position(&self, path: &SurfacePath) -> Point<2> { - // Computing the surface position from the curve position is fine. - // `HalfEdge` "owns" its start position. There is no competing code that - // could compute the surface position from slightly different data. - - let [start, _] = self.boundary.inner; - path.point_from_path_coords(start) - } } From fb9726c51e05c19e6e43f33a9e69eb9c82dc57d7 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 10 Jul 2024 21:52:23 +0200 Subject: [PATCH 02/10] Return `Option` from `Geometry::of_half_edge` This makes the method a bit more flexible, which is going to help in the transition away from half-edge geometry. --- crates/fj-core/src/geometry/geometry.rs | 9 +++++---- crates/fj-core/src/operations/build/half_edge.rs | 2 +- crates/fj-core/src/operations/join/cycle.rs | 6 ++++-- crates/fj-core/src/operations/reverse/cycle.rs | 2 +- crates/fj-core/src/operations/reverse/half_edge.rs | 3 ++- crates/fj-core/src/operations/split/edge.rs | 2 +- crates/fj-core/src/operations/split/face.rs | 2 +- crates/fj-core/src/operations/split/half_edge.rs | 2 +- crates/fj-core/src/operations/sweep/cycle.rs | 2 +- crates/fj-core/src/operations/transform/half_edge.rs | 2 +- .../checks/coincident_half_edges_are_not_siblings.rs | 3 ++- .../src/validation/checks/curve_geometry_mismatch.rs | 3 ++- 12 files changed, 22 insertions(+), 16 deletions(-) diff --git a/crates/fj-core/src/geometry/geometry.rs b/crates/fj-core/src/geometry/geometry.rs index bbd04de85..54eb345d1 100644 --- a/crates/fj-core/src/geometry/geometry.rs +++ b/crates/fj-core/src/geometry/geometry.rs @@ -131,10 +131,11 @@ impl Geometry { /// ## Panics /// /// Panics, if the geometry of the half-edge is not defined. - pub fn of_half_edge(&self, half_edge: &Handle) -> &HalfEdgeGeom { - self.half_edge - .get(half_edge) - .expect("Expected geometry of half-edge to be defined") + pub fn of_half_edge( + &self, + half_edge: &Handle, + ) -> Option<&HalfEdgeGeom> { + self.half_edge.get(half_edge) } /// # Access the geometry of the provided surface diff --git a/crates/fj-core/src/operations/build/half_edge.rs b/crates/fj-core/src/operations/build/half_edge.rs index 45202e88b..9f6a9f36e 100644 --- a/crates/fj-core/src/operations/build/half_edge.rs +++ b/crates/fj-core/src/operations/build/half_edge.rs @@ -31,7 +31,7 @@ pub trait BuildHalfEdge { start_vertex: Handle, core: &mut Core, ) -> Handle { - let mut geometry = *core.layers.geometry.of_half_edge(sibling); + let mut geometry = *core.layers.geometry.of_half_edge(sibling).unwrap(); geometry.boundary = geometry.boundary.reverse(); HalfEdge::new(sibling.curve().clone(), start_vertex) diff --git a/crates/fj-core/src/operations/join/cycle.rs b/crates/fj-core/src/operations/join/cycle.rs index 4e18a8412..66312758c 100644 --- a/crates/fj-core/src/operations/join/cycle.rs +++ b/crates/fj-core/src/operations/join/cycle.rs @@ -265,7 +265,8 @@ impl JoinCycle for Cycle { *core .layers .geometry - .of_half_edge(half_edge), + .of_half_edge(half_edge) + .unwrap(), &mut core.layers.geometry, )] }, @@ -304,7 +305,8 @@ impl JoinCycle for Cycle { *core .layers .geometry - .of_half_edge(half_edge), + .of_half_edge(half_edge) + .unwrap(), &mut core.layers.geometry, )] }, diff --git a/crates/fj-core/src/operations/reverse/cycle.rs b/crates/fj-core/src/operations/reverse/cycle.rs index 9bc657251..f01bd72e5 100644 --- a/crates/fj-core/src/operations/reverse/cycle.rs +++ b/crates/fj-core/src/operations/reverse/cycle.rs @@ -15,7 +15,7 @@ impl Reverse for Cycle { .pairs() .map(|(current, next)| { let mut half_edge_geom = - *core.layers.geometry.of_half_edge(current); + *core.layers.geometry.of_half_edge(current).unwrap(); half_edge_geom.boundary = half_edge_geom.boundary.reverse(); HalfEdge::new( diff --git a/crates/fj-core/src/operations/reverse/half_edge.rs b/crates/fj-core/src/operations/reverse/half_edge.rs index a93d5eb6c..f7087e8e4 100644 --- a/crates/fj-core/src/operations/reverse/half_edge.rs +++ b/crates/fj-core/src/operations/reverse/half_edge.rs @@ -35,7 +35,8 @@ impl ReverseCurveCoordinateSystems .unwrap() .clone(); - let mut half_edge_geom = *core.layers.geometry.of_half_edge(half_edge); + let mut half_edge_geom = + *core.layers.geometry.of_half_edge(half_edge).unwrap(); half_edge_geom.boundary = half_edge_geom.boundary.reverse(); let curve = diff --git a/crates/fj-core/src/operations/split/edge.rs b/crates/fj-core/src/operations/split/edge.rs index 8afe3cbd5..0903a2321 100644 --- a/crates/fj-core/src/operations/split/edge.rs +++ b/crates/fj-core/src/operations/split/edge.rs @@ -55,7 +55,7 @@ impl SplitEdge for Shell { ) .insert(core) .set_geometry( - *core.layers.geometry.of_half_edge(&sibling_b), + *core.layers.geometry.of_half_edge(&sibling_b).unwrap(), &mut core.layers.geometry, ); diff --git a/crates/fj-core/src/operations/split/face.rs b/crates/fj-core/src/operations/split/face.rs index c742ac478..17a5f5e01 100644 --- a/crates/fj-core/src/operations/split/face.rs +++ b/crates/fj-core/src/operations/split/face.rs @@ -164,7 +164,7 @@ impl SplitFace for Shell { .update_start_vertex(|_, _| b.start_vertex().clone(), core) .insert(core) .set_geometry( - *core.layers.geometry.of_half_edge(&half_edge), + *core.layers.geometry.of_half_edge(&half_edge).unwrap(), &mut core.layers.geometry, ) }; diff --git a/crates/fj-core/src/operations/split/half_edge.rs b/crates/fj-core/src/operations/split/half_edge.rs index ba9ee5d64..259721e0f 100644 --- a/crates/fj-core/src/operations/split/half_edge.rs +++ b/crates/fj-core/src/operations/split/half_edge.rs @@ -45,7 +45,7 @@ impl SplitHalfEdge for Cycle { ) -> [Handle; 2] { let point = point.into(); - let geometry = *core.layers.geometry.of_half_edge(half_edge); + let geometry = *core.layers.geometry.of_half_edge(half_edge).unwrap(); let [start, end] = [ core.layers .geometry diff --git a/crates/fj-core/src/operations/sweep/cycle.rs b/crates/fj-core/src/operations/sweep/cycle.rs index 28d6cc514..c054910a5 100644 --- a/crates/fj-core/src/operations/sweep/cycle.rs +++ b/crates/fj-core/src/operations/sweep/cycle.rs @@ -82,7 +82,7 @@ impl SweepCycle for Cycle { top_half_edges.push(( swept_half_edge.top_half_edge, swept_half_edge.top_boundary, - *core.layers.geometry.of_half_edge(bottom_half_edge), + *core.layers.geometry.of_half_edge(bottom_half_edge).unwrap(), core.layers .geometry .of_curve(bottom_half_edge.curve()) diff --git a/crates/fj-core/src/operations/transform/half_edge.rs b/crates/fj-core/src/operations/transform/half_edge.rs index 3f2eb6626..e91b1b093 100644 --- a/crates/fj-core/src/operations/transform/half_edge.rs +++ b/crates/fj-core/src/operations/transform/half_edge.rs @@ -32,7 +32,7 @@ impl TransformObject for (&Handle, &Handle) { core.layers.geometry.define_half_edge( transformed_half_edge.clone(), - *core.layers.geometry.of_half_edge(half_edge), + *core.layers.geometry.of_half_edge(half_edge).unwrap(), ); transformed_half_edge diff --git a/crates/fj-core/src/validation/checks/coincident_half_edges_are_not_siblings.rs b/crates/fj-core/src/validation/checks/coincident_half_edges_are_not_siblings.rs index ca13ffd2c..a3c80ff0a 100644 --- a/crates/fj-core/src/validation/checks/coincident_half_edges_are_not_siblings.rs +++ b/crates/fj-core/src/validation/checks/coincident_half_edges_are_not_siblings.rs @@ -318,7 +318,8 @@ mod tests { *core .layers .geometry - .of_half_edge(half_edge), + .of_half_edge(half_edge) + .unwrap(), &mut core.layers.geometry, )] }, diff --git a/crates/fj-core/src/validation/checks/curve_geometry_mismatch.rs b/crates/fj-core/src/validation/checks/curve_geometry_mismatch.rs index af6efb34e..1b0be3072 100644 --- a/crates/fj-core/src/validation/checks/curve_geometry_mismatch.rs +++ b/crates/fj-core/src/validation/checks/curve_geometry_mismatch.rs @@ -227,7 +227,8 @@ mod tests { let mut half_edge_geom = *core .layers .geometry - .of_half_edge(half_edge); + .of_half_edge(half_edge) + .unwrap(); half_edge_geom.boundary = half_edge_geom.boundary.reverse(); From 20f0a09a227f9d4bbcf37fdc763988f881f9e8dd Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 10 Jul 2024 21:55:00 +0200 Subject: [PATCH 03/10] Only transform already existing half-edge geometry This makes the transformation operation more flexible, easing the transition away from half-edge geometry. --- crates/fj-core/src/operations/transform/half_edge.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/fj-core/src/operations/transform/half_edge.rs b/crates/fj-core/src/operations/transform/half_edge.rs index e91b1b093..0647a86fd 100644 --- a/crates/fj-core/src/operations/transform/half_edge.rs +++ b/crates/fj-core/src/operations/transform/half_edge.rs @@ -30,10 +30,14 @@ impl TransformObject for (&Handle, &Handle) { let transformed_half_edge = HalfEdge::new(curve, start_vertex).insert(core); - core.layers.geometry.define_half_edge( - transformed_half_edge.clone(), - *core.layers.geometry.of_half_edge(half_edge).unwrap(), - ); + if let Some(half_edge_geom) = + core.layers.geometry.of_half_edge(half_edge) + { + core.layers.geometry.define_half_edge( + transformed_half_edge.clone(), + *half_edge_geom, + ); + } transformed_half_edge } From d033c9a585a5742bb5168db2c420c593eaf45356 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 10 Jul 2024 21:56:26 +0200 Subject: [PATCH 04/10] Don't set half-edge geometry in `add_joined_edge` --- crates/fj-core/src/operations/join/cycle.rs | 49 +++++++------------- crates/fj-core/src/operations/sweep/cycle.rs | 4 +- 2 files changed, 20 insertions(+), 33 deletions(-) diff --git a/crates/fj-core/src/operations/join/cycle.rs b/crates/fj-core/src/operations/join/cycle.rs index 66312758c..d6d3f70dd 100644 --- a/crates/fj-core/src/operations/join/cycle.rs +++ b/crates/fj-core/src/operations/join/cycle.rs @@ -3,7 +3,7 @@ use std::ops::RangeInclusive; use itertools::Itertools; use crate::{ - geometry::{HalfEdgeGeom, LocalCurveGeom}, + geometry::LocalCurveGeom, operations::{ build::BuildHalfEdge, geometry::UpdateHalfEdgeGeometry, @@ -34,9 +34,7 @@ pub trait JoinCycle { core: &mut Core, ) -> Self where - Es: IntoIterator< - Item = (Handle, HalfEdgeGeom, LocalCurveGeom), - >, + Es: IntoIterator, LocalCurveGeom)>, Es::IntoIter: Clone + ExactSizeIterator; /// Join the cycle to another @@ -99,40 +97,29 @@ impl JoinCycle for Cycle { core: &mut Core, ) -> Self where - Es: IntoIterator< - Item = (Handle, HalfEdgeGeom, LocalCurveGeom), - >, + Es: IntoIterator, LocalCurveGeom)>, Es::IntoIter: Clone + ExactSizeIterator, { let half_edges = edges .into_iter() .circular_tuple_windows() - .map( - |( - (prev_half_edge, _, _), - (half_edge, half_edge_geom, curve_geom), - )| { - let half_edge = HalfEdge::unjoined(core) - .update_curve(|_, _| half_edge.curve().clone(), core) - .update_start_vertex( - |_, _| prev_half_edge.start_vertex().clone(), - core, - ) - .insert(core) - .set_geometry( - half_edge_geom, - &mut core.layers.geometry, - ); + .map(|((prev_half_edge, _), (half_edge, curve_geom))| { + let half_edge = HalfEdge::unjoined(core) + .update_curve(|_, _| half_edge.curve().clone(), core) + .update_start_vertex( + |_, _| prev_half_edge.start_vertex().clone(), + core, + ) + .insert(core); - core.layers.geometry.define_curve( - half_edge.curve().clone(), - surface.clone(), - curve_geom, - ); + core.layers.geometry.define_curve( + half_edge.curve().clone(), + surface.clone(), + curve_geom, + ); - half_edge - }, - ) + half_edge + }) .collect::>(); self.add_half_edges(half_edges, core) } diff --git a/crates/fj-core/src/operations/sweep/cycle.rs b/crates/fj-core/src/operations/sweep/cycle.rs index c054910a5..979b25473 100644 --- a/crates/fj-core/src/operations/sweep/cycle.rs +++ b/crates/fj-core/src/operations/sweep/cycle.rs @@ -98,7 +98,7 @@ impl SweepCycle for Cycle { .circular_tuple_windows() .map( |( - (half_edge, boundary, half_edge_geom, curve_geom), + (half_edge, boundary, _, curve_geom), (next_half_edge, _, _, _), )| { let [start, end] = boundary.inner; @@ -114,7 +114,7 @@ impl SweepCycle for Cycle { ); } - (half_edge, half_edge_geom, curve_geom) + (half_edge, curve_geom) }, ) .collect::>(); From 1b7776e4f59cce74e944d736d313edd901ded91b Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 10 Jul 2024 21:58:57 +0200 Subject: [PATCH 05/10] Remove redundant code --- crates/fj-core/src/operations/sweep/cycle.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/operations/sweep/cycle.rs b/crates/fj-core/src/operations/sweep/cycle.rs index 979b25473..bca9d69e8 100644 --- a/crates/fj-core/src/operations/sweep/cycle.rs +++ b/crates/fj-core/src/operations/sweep/cycle.rs @@ -82,7 +82,6 @@ impl SweepCycle for Cycle { top_half_edges.push(( swept_half_edge.top_half_edge, swept_half_edge.top_boundary, - *core.layers.geometry.of_half_edge(bottom_half_edge).unwrap(), core.layers .geometry .of_curve(bottom_half_edge.curve()) @@ -98,8 +97,8 @@ impl SweepCycle for Cycle { .circular_tuple_windows() .map( |( - (half_edge, boundary, _, curve_geom), - (next_half_edge, _, _, _), + (half_edge, boundary, curve_geom), + (next_half_edge, _, _), )| { let [start, end] = boundary.inner; From 2abd1dda5440f3a7b90a6cb864239a5a38571815 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 10 Jul 2024 21:39:33 +0200 Subject: [PATCH 06/10] Remove code that defines half-edge geometry --- .../fj-core/src/operations/build/half_edge.rs | 21 ++-------- crates/fj-core/src/operations/build/shell.rs | 8 +--- crates/fj-core/src/operations/join/cycle.rs | 21 +--------- .../fj-core/src/operations/reverse/cycle.rs | 9 +---- .../src/operations/reverse/half_edge.rs | 8 ---- crates/fj-core/src/operations/split/edge.rs | 10 ++--- crates/fj-core/src/operations/split/face.rs | 5 --- .../fj-core/src/operations/split/half_edge.rs | 39 ++----------------- .../fj-core/src/operations/sweep/half_edge.rs | 10 ++--- .../src/operations/transform/half_edge.rs | 14 +------ .../coincident_half_edges_are_not_siblings.rs | 12 +----- .../checks/curve_geometry_mismatch.rs | 15 +------ 12 files changed, 21 insertions(+), 151 deletions(-) diff --git a/crates/fj-core/src/operations/build/half_edge.rs b/crates/fj-core/src/operations/build/half_edge.rs index 9f6a9f36e..c338cb108 100644 --- a/crates/fj-core/src/operations/build/half_edge.rs +++ b/crates/fj-core/src/operations/build/half_edge.rs @@ -1,11 +1,8 @@ use fj_math::{Arc, Point, Scalar}; use crate::{ - geometry::{CurveBoundary, HalfEdgeGeom, LocalCurveGeom, SurfacePath}, - operations::{ - geometry::{UpdateCurveGeometry, UpdateHalfEdgeGeometry}, - insert::Insert, - }, + geometry::{CurveBoundary, LocalCurveGeom, SurfacePath}, + operations::{geometry::UpdateCurveGeometry, insert::Insert}, storage::Handle, topology::{Curve, HalfEdge, Surface, Vertex}, Core, @@ -31,12 +28,7 @@ pub trait BuildHalfEdge { start_vertex: Handle, core: &mut Core, ) -> Handle { - let mut geometry = *core.layers.geometry.of_half_edge(sibling).unwrap(); - geometry.boundary = geometry.boundary.reverse(); - - HalfEdge::new(sibling.curve().clone(), start_vertex) - .insert(core) - .set_geometry(geometry, &mut core.layers.geometry) + HalfEdge::new(sibling.curve().clone(), start_vertex).insert(core) } /// Create an arc @@ -72,9 +64,6 @@ pub trait BuildHalfEdge { surface, LocalCurveGeom { path }, ); - core.layers - .geometry - .define_half_edge(half_edge.clone(), HalfEdgeGeom { boundary }); (half_edge, boundary) } @@ -96,10 +85,6 @@ pub trait BuildHalfEdge { &mut core.layers.geometry, ); - core.layers - .geometry - .define_half_edge(half_edge.clone(), HalfEdgeGeom { boundary }); - (half_edge, boundary) } } diff --git a/crates/fj-core/src/operations/build/shell.rs b/crates/fj-core/src/operations/build/shell.rs index 5b3200981..fda9a7a8d 100644 --- a/crates/fj-core/src/operations/build/shell.rs +++ b/crates/fj-core/src/operations/build/shell.rs @@ -4,10 +4,10 @@ use fj_interop::ext::ArrayExt; use fj_math::Point; use crate::{ - geometry::{CurveBoundary, HalfEdgeGeom, LocalVertexGeom}, + geometry::{CurveBoundary, LocalVertexGeom}, operations::{ build::{BuildFace, BuildHalfEdge, BuildSurface, Polygon}, - geometry::{UpdateCurveGeometry, UpdateHalfEdgeGeometry}, + geometry::UpdateCurveGeometry, insert::{Insert, IsInserted, IsInsertedNo, IsInsertedYes}, join::JoinCycle, reverse::ReverseCurveCoordinateSystems, @@ -123,10 +123,6 @@ pub trait BuildShell { ) .update_curve(|_, _| curve.clone(), core) .insert(core) - .set_geometry( - HalfEdgeGeom { boundary }, - &mut core.layers.geometry, - ) }, ) }; diff --git a/crates/fj-core/src/operations/join/cycle.rs b/crates/fj-core/src/operations/join/cycle.rs index d6d3f70dd..a6d232c72 100644 --- a/crates/fj-core/src/operations/join/cycle.rs +++ b/crates/fj-core/src/operations/join/cycle.rs @@ -6,7 +6,6 @@ use crate::{ geometry::LocalCurveGeom, operations::{ build::BuildHalfEdge, - geometry::UpdateHalfEdgeGeometry, insert::Insert, update::{UpdateCycle, UpdateHalfEdge}, }, @@ -247,15 +246,7 @@ impl JoinCycle for Cycle { }, core, ) - .insert(core) - .set_geometry( - *core - .layers - .geometry - .of_half_edge(half_edge) - .unwrap(), - &mut core.layers.geometry, - )] + .insert(core)] }, core, ) @@ -287,15 +278,7 @@ impl JoinCycle for Cycle { }, core, ) - .insert(core) - .set_geometry( - *core - .layers - .geometry - .of_half_edge(half_edge) - .unwrap(), - &mut core.layers.geometry, - )] + .insert(core)] }, core, ) diff --git a/crates/fj-core/src/operations/reverse/cycle.rs b/crates/fj-core/src/operations/reverse/cycle.rs index f01bd72e5..e19cf7c0f 100644 --- a/crates/fj-core/src/operations/reverse/cycle.rs +++ b/crates/fj-core/src/operations/reverse/cycle.rs @@ -1,7 +1,5 @@ use crate::{ - operations::{ - derive::DeriveFrom, geometry::UpdateHalfEdgeGeometry, insert::Insert, - }, + operations::{derive::DeriveFrom, insert::Insert}, topology::{Cycle, HalfEdge}, Core, }; @@ -14,17 +12,12 @@ impl Reverse for Cycle { .half_edges() .pairs() .map(|(current, next)| { - let mut half_edge_geom = - *core.layers.geometry.of_half_edge(current).unwrap(); - half_edge_geom.boundary = half_edge_geom.boundary.reverse(); - HalfEdge::new( current.curve().clone(), next.start_vertex().clone(), ) .insert(core) .derive_from(current, core) - .set_geometry(half_edge_geom, &mut core.layers.geometry) }) .collect::>(); diff --git a/crates/fj-core/src/operations/reverse/half_edge.rs b/crates/fj-core/src/operations/reverse/half_edge.rs index f7087e8e4..77e0f1f37 100644 --- a/crates/fj-core/src/operations/reverse/half_edge.rs +++ b/crates/fj-core/src/operations/reverse/half_edge.rs @@ -35,10 +35,6 @@ impl ReverseCurveCoordinateSystems .unwrap() .clone(); - let mut half_edge_geom = - *core.layers.geometry.of_half_edge(half_edge).unwrap(); - half_edge_geom.boundary = half_edge_geom.boundary.reverse(); - let curve = (half_edge.curve(), surface).reverse_curve_coordinate_systems(core); @@ -57,10 +53,6 @@ impl ReverseCurveCoordinateSystems vertex_geom_start, ); - core.layers - .geometry - .define_half_edge(half_edge.clone(), half_edge_geom); - half_edge } } diff --git a/crates/fj-core/src/operations/split/edge.rs b/crates/fj-core/src/operations/split/edge.rs index 0903a2321..9fedb538a 100644 --- a/crates/fj-core/src/operations/split/edge.rs +++ b/crates/fj-core/src/operations/split/edge.rs @@ -2,8 +2,8 @@ use fj_math::Point; use crate::{ operations::{ - geometry::UpdateHalfEdgeGeometry, insert::Insert, - replace::ReplaceHalfEdge, split::SplitHalfEdge, update::UpdateHalfEdge, + insert::Insert, replace::ReplaceHalfEdge, split::SplitHalfEdge, + update::UpdateHalfEdge, }, queries::{CycleOfHalfEdge, SiblingOfHalfEdge}, storage::Handle, @@ -53,11 +53,7 @@ impl SplitEdge for Shell { |_, _| half_edge_b.start_vertex().clone(), core, ) - .insert(core) - .set_geometry( - *core.layers.geometry.of_half_edge(&sibling_b).unwrap(), - &mut core.layers.geometry, - ); + .insert(core); [sibling_a, sibling_b] }; diff --git a/crates/fj-core/src/operations/split/face.rs b/crates/fj-core/src/operations/split/face.rs index 17a5f5e01..c58ff3660 100644 --- a/crates/fj-core/src/operations/split/face.rs +++ b/crates/fj-core/src/operations/split/face.rs @@ -7,7 +7,6 @@ use crate::{ operations::{ build::{BuildCycle, BuildHalfEdge}, derive::DeriveFrom, - geometry::UpdateHalfEdgeGeometry, insert::Insert, split::SplitEdge, update::{ @@ -163,10 +162,6 @@ impl SplitFace for Shell { half_edge .update_start_vertex(|_, _| b.start_vertex().clone(), core) .insert(core) - .set_geometry( - *core.layers.geometry.of_half_edge(&half_edge).unwrap(), - &mut core.layers.geometry, - ) }; let dividing_half_edge_c_to_b = HalfEdge::from_sibling( &dividing_half_edge_a_to_d, diff --git a/crates/fj-core/src/operations/split/half_edge.rs b/crates/fj-core/src/operations/split/half_edge.rs index 259721e0f..79bd1ab01 100644 --- a/crates/fj-core/src/operations/split/half_edge.rs +++ b/crates/fj-core/src/operations/split/half_edge.rs @@ -2,9 +2,7 @@ use fj_math::Point; use crate::{ geometry::LocalVertexGeom, - operations::{ - derive::DeriveFrom, geometry::UpdateHalfEdgeGeometry, insert::Insert, - }, + operations::{derive::DeriveFrom, insert::Insert}, storage::Handle, topology::{Cycle, HalfEdge, Vertex}, Core, @@ -45,49 +43,18 @@ impl SplitHalfEdge for Cycle { ) -> [Handle; 2] { let point = point.into(); - let geometry = *core.layers.geometry.of_half_edge(half_edge).unwrap(); - let [start, end] = [ - core.layers - .geometry - .of_vertex(half_edge.start_vertex()) - .unwrap() - .local_on(half_edge.curve()) - .unwrap() - .position, - core.layers - .geometry - .of_vertex( - self.half_edges() - .after(half_edge) - .expect("Expected half-edge to be in cycle") - .start_vertex(), - ) - .unwrap() - .local_on(half_edge.curve()) - .unwrap() - .position, - ]; - let a = HalfEdge::new( half_edge.curve().clone(), half_edge.start_vertex().clone(), ) .insert(core) - .derive_from(half_edge, core) - .set_geometry( - geometry.with_boundary([start, point]), - &mut core.layers.geometry, - ); + .derive_from(half_edge, core); let b = HalfEdge::new( half_edge.curve().clone(), Vertex::new().insert(core), ) .insert(core) - .derive_from(half_edge, core) - .set_geometry( - geometry.with_boundary([point, end]), - &mut core.layers.geometry, - ); + .derive_from(half_edge, core); core.layers.geometry.define_vertex( b.start_vertex().clone(), diff --git a/crates/fj-core/src/operations/sweep/half_edge.rs b/crates/fj-core/src/operations/sweep/half_edge.rs index 522a33e23..e4e014263 100644 --- a/crates/fj-core/src/operations/sweep/half_edge.rs +++ b/crates/fj-core/src/operations/sweep/half_edge.rs @@ -2,10 +2,10 @@ use fj_interop::{ext::ArrayExt, Color}; use fj_math::{Point, Scalar, Vector}; use crate::{ - geometry::{CurveBoundary, HalfEdgeGeom, LocalVertexGeom}, + geometry::{CurveBoundary, LocalVertexGeom}, operations::{ build::{BuildCycle, BuildHalfEdge}, - geometry::{UpdateCurveGeometry, UpdateHalfEdgeGeometry}, + geometry::UpdateCurveGeometry, insert::Insert, presentation::SetColor, update::{UpdateCycle, UpdateHalfEdge}, @@ -184,11 +184,7 @@ impl SweepHalfEdge for Handle { let half_edge = HalfEdge::unjoined(core) .update_start_vertex(|_, _| start_vertex, core) .update_curve(|_, _| curve.clone(), core) - .insert(core) - .set_geometry( - HalfEdgeGeom { boundary }, - &mut core.layers.geometry, - ); + .insert(core); exterior = exterior.add_half_edges([half_edge.clone()], core); diff --git a/crates/fj-core/src/operations/transform/half_edge.rs b/crates/fj-core/src/operations/transform/half_edge.rs index 0647a86fd..78dc91acc 100644 --- a/crates/fj-core/src/operations/transform/half_edge.rs +++ b/crates/fj-core/src/operations/transform/half_edge.rs @@ -27,18 +27,6 @@ impl TransformObject for (&Handle, &Handle) { .clone() .transform_with_cache(transform, core, cache); - let transformed_half_edge = - HalfEdge::new(curve, start_vertex).insert(core); - - if let Some(half_edge_geom) = - core.layers.geometry.of_half_edge(half_edge) - { - core.layers.geometry.define_half_edge( - transformed_half_edge.clone(), - *half_edge_geom, - ); - } - - transformed_half_edge + HalfEdge::new(curve, start_vertex).insert(core) } } diff --git a/crates/fj-core/src/validation/checks/coincident_half_edges_are_not_siblings.rs b/crates/fj-core/src/validation/checks/coincident_half_edges_are_not_siblings.rs index a3c80ff0a..778c8de6a 100644 --- a/crates/fj-core/src/validation/checks/coincident_half_edges_are_not_siblings.rs +++ b/crates/fj-core/src/validation/checks/coincident_half_edges_are_not_siblings.rs @@ -236,7 +236,7 @@ mod tests { use crate::{ operations::{ build::BuildShell, - geometry::{UpdateCurveGeometry, UpdateHalfEdgeGeometry}, + geometry::UpdateCurveGeometry, insert::Insert, update::{ UpdateCycle, UpdateFace, UpdateHalfEdge, UpdateRegion, @@ -313,15 +313,7 @@ mod tests { [half_edge .update_curve(|_, _| curve, core) - .insert(core) - .set_geometry( - *core - .layers - .geometry - .of_half_edge(half_edge) - .unwrap(), - &mut core.layers.geometry, - )] + .insert(core)] }, core, ) diff --git a/crates/fj-core/src/validation/checks/curve_geometry_mismatch.rs b/crates/fj-core/src/validation/checks/curve_geometry_mismatch.rs index 1b0be3072..f8f16ec8d 100644 --- a/crates/fj-core/src/validation/checks/curve_geometry_mismatch.rs +++ b/crates/fj-core/src/validation/checks/curve_geometry_mismatch.rs @@ -192,7 +192,6 @@ mod tests { use crate::{ operations::{ build::BuildShell, - geometry::UpdateHalfEdgeGeometry, insert::Insert, update::{UpdateCycle, UpdateFace, UpdateRegion, UpdateShell}, }, @@ -224,14 +223,6 @@ mod tests { cycle.update_half_edge( cycle.half_edges().nth_circular(0), |half_edge, core| { - let mut half_edge_geom = *core - .layers - .geometry - .of_half_edge(half_edge) - .unwrap(); - half_edge_geom.boundary = - half_edge_geom.boundary.reverse(); - let mut curve_geom = core .layers .geometry @@ -247,11 +238,7 @@ mod tests { half_edge.curve().clone(), half_edge.start_vertex().clone(), ) - .insert(core) - .set_geometry( - half_edge_geom, - &mut core.layers.geometry, - ); + .insert(core); core.layers.geometry.define_curve( half_edge.curve().clone(), From 5170181c7290730e5828b76960841ca3317a19e8 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 10 Jul 2024 21:40:40 +0200 Subject: [PATCH 07/10] Remove `UpdateHalfEdgeGeometry` --- .../src/operations/geometry/half_edge.rs | 27 ------------------- crates/fj-core/src/operations/geometry/mod.rs | 3 +-- 2 files changed, 1 insertion(+), 29 deletions(-) delete mode 100644 crates/fj-core/src/operations/geometry/half_edge.rs diff --git a/crates/fj-core/src/operations/geometry/half_edge.rs b/crates/fj-core/src/operations/geometry/half_edge.rs deleted file mode 100644 index 301cefc6f..000000000 --- a/crates/fj-core/src/operations/geometry/half_edge.rs +++ /dev/null @@ -1,27 +0,0 @@ -use crate::{ - geometry::{Geometry, HalfEdgeGeom}, - layers::Layer, - storage::Handle, - topology::HalfEdge, -}; - -/// Update the geometry of a [`HalfEdge`] -pub trait UpdateHalfEdgeGeometry { - /// Set the path of the half-edge - fn set_geometry( - self, - geometry: HalfEdgeGeom, - layer: &mut Layer, - ) -> Self; -} - -impl UpdateHalfEdgeGeometry for Handle { - fn set_geometry( - self, - geometry: HalfEdgeGeom, - layer: &mut Layer, - ) -> Self { - layer.define_half_edge(self.clone(), geometry); - self - } -} diff --git a/crates/fj-core/src/operations/geometry/mod.rs b/crates/fj-core/src/operations/geometry/mod.rs index bfd2309a3..ea7df90df 100644 --- a/crates/fj-core/src/operations/geometry/mod.rs +++ b/crates/fj-core/src/operations/geometry/mod.rs @@ -1,6 +1,5 @@ //! Operations to update the geometry of objects mod curve; -mod half_edge; -pub use self::{curve::UpdateCurveGeometry, half_edge::UpdateHalfEdgeGeometry}; +pub use self::curve::UpdateCurveGeometry; From 29fc2d5fa20fd55fb8ff92260fd2dec64d4cb0f1 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 10 Jul 2024 21:41:50 +0200 Subject: [PATCH 08/10] Remove infrastructure for defining half-edge geom --- crates/fj-core/src/geometry/geometry.rs | 8 ----- crates/fj-core/src/layers/geometry.rs | 47 ++----------------------- 2 files changed, 2 insertions(+), 53 deletions(-) diff --git a/crates/fj-core/src/geometry/geometry.rs b/crates/fj-core/src/geometry/geometry.rs index 54eb345d1..089aa2f4a 100644 --- a/crates/fj-core/src/geometry/geometry.rs +++ b/crates/fj-core/src/geometry/geometry.rs @@ -80,14 +80,6 @@ impl Geometry { .insert(surface, geometry); } - pub(crate) fn define_half_edge_inner( - &mut self, - half_edge: Handle, - geometry: HalfEdgeGeom, - ) { - self.half_edge.insert(half_edge, geometry); - } - pub(crate) fn define_surface_inner( &mut self, surface: Handle, diff --git a/crates/fj-core/src/layers/geometry.rs b/crates/fj-core/src/layers/geometry.rs index dedb9e472..0631abd2d 100644 --- a/crates/fj-core/src/layers/geometry.rs +++ b/crates/fj-core/src/layers/geometry.rs @@ -1,11 +1,9 @@ //! Layer infrastructure for [`Geometry`] use crate::{ - geometry::{ - Geometry, HalfEdgeGeom, LocalCurveGeom, LocalVertexGeom, SurfaceGeom, - }, + geometry::{Geometry, LocalCurveGeom, LocalVertexGeom, SurfaceGeom}, storage::Handle, - topology::{Curve, HalfEdge, Surface, Vertex}, + topology::{Curve, Surface, Vertex}, }; use super::{Command, Event, Layer}; @@ -29,22 +27,6 @@ impl Layer { ); } - /// Define the geometry of the provided half-edge - pub fn define_half_edge( - &mut self, - half_edge: Handle, - geometry: HalfEdgeGeom, - ) { - let mut events = Vec::new(); - self.process( - DefineHalfEdge { - half_edge, - geometry, - }, - &mut events, - ); - } - /// # Define the geometry of the provided surface /// /// ## Panics @@ -109,31 +91,6 @@ impl Event for DefineCurve { } } -/// Define the geometry of a half-edge -pub struct DefineHalfEdge { - half_edge: Handle, - geometry: HalfEdgeGeom, -} - -impl Command for DefineHalfEdge { - type Result = (); - type Event = Self; - - fn decide( - self, - _: &Geometry, - events: &mut Vec, - ) -> Self::Result { - events.push(self); - } -} - -impl Event for DefineHalfEdge { - fn evolve(&self, state: &mut Geometry) { - state.define_half_edge_inner(self.half_edge.clone(), self.geometry); - } -} - /// Define the geometry of a surface pub struct DefineSurface { surface: Handle, From cb81b30dccefa9bf1d24c29121b35d4d82974920 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 10 Jul 2024 22:07:47 +0200 Subject: [PATCH 09/10] Remove remaining traces of half-edge geometry --- crates/fj-core/src/geometry/geometry.rs | 20 +++----------------- crates/fj-core/src/geometry/half_edge.rs | 21 --------------------- crates/fj-core/src/geometry/mod.rs | 2 -- 3 files changed, 3 insertions(+), 40 deletions(-) delete mode 100644 crates/fj-core/src/geometry/half_edge.rs diff --git a/crates/fj-core/src/geometry/geometry.rs b/crates/fj-core/src/geometry/geometry.rs index 089aa2f4a..511734ce8 100644 --- a/crates/fj-core/src/geometry/geometry.rs +++ b/crates/fj-core/src/geometry/geometry.rs @@ -4,18 +4,17 @@ use fj_math::Vector; use crate::{ storage::Handle, - topology::{Curve, HalfEdge, Surface, Topology, Vertex}, + topology::{Curve, Surface, Topology, Vertex}, }; use super::{ - vertex::LocalVertexGeom, CurveGeom, GlobalPath, HalfEdgeGeom, - LocalCurveGeom, SurfaceGeom, VertexGeom, + vertex::LocalVertexGeom, CurveGeom, GlobalPath, LocalCurveGeom, + SurfaceGeom, VertexGeom, }; /// Geometric data that is associated with topological objects pub struct Geometry { curve: BTreeMap, CurveGeom>, - half_edge: BTreeMap, HalfEdgeGeom>, surface: BTreeMap, SurfaceGeom>, vertex: BTreeMap, VertexGeom>, @@ -31,7 +30,6 @@ impl Geometry { pub fn new(topology: &Topology) -> Self { let mut self_ = Self { curve: BTreeMap::new(), - half_edge: BTreeMap::new(), surface: BTreeMap::new(), vertex: BTreeMap::new(), @@ -118,18 +116,6 @@ impl Geometry { self.curve.get(curve) } - /// # Access the geometry of the provided half-edge - /// - /// ## Panics - /// - /// Panics, if the geometry of the half-edge is not defined. - pub fn of_half_edge( - &self, - half_edge: &Handle, - ) -> Option<&HalfEdgeGeom> { - self.half_edge.get(half_edge) - } - /// # Access the geometry of the provided surface /// /// ## Panics diff --git a/crates/fj-core/src/geometry/half_edge.rs b/crates/fj-core/src/geometry/half_edge.rs deleted file mode 100644 index da4189faa..000000000 --- a/crates/fj-core/src/geometry/half_edge.rs +++ /dev/null @@ -1,21 +0,0 @@ -use fj_math::Point; - -use super::CurveBoundary; - -/// The geometry of a half-edge -#[derive(Copy, Clone, Debug)] -pub struct HalfEdgeGeom { - /// # The boundary of the half-edge on its curve - pub boundary: CurveBoundary>, -} - -impl HalfEdgeGeom { - /// Update the boundary - pub fn with_boundary( - mut self, - boundary: impl Into>>, - ) -> Self { - self.boundary = boundary.into(); - self - } -} diff --git a/crates/fj-core/src/geometry/mod.rs b/crates/fj-core/src/geometry/mod.rs index b3daaf856..52bfaddde 100644 --- a/crates/fj-core/src/geometry/mod.rs +++ b/crates/fj-core/src/geometry/mod.rs @@ -3,7 +3,6 @@ mod boundary; mod curve; mod geometry; -mod half_edge; mod path; mod surface; mod vertex; @@ -12,7 +11,6 @@ pub use self::{ boundary::{CurveBoundary, CurveBoundaryElement}, curve::{CurveGeom, LocalCurveGeom}, geometry::Geometry, - half_edge::HalfEdgeGeom, path::{GlobalPath, SurfacePath}, surface::SurfaceGeom, vertex::{LocalVertexGeom, VertexGeom}, From 346e2027cdf90f96bd22691e387c8353a95bd951 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 10 Jul 2024 22:17:19 +0200 Subject: [PATCH 10/10] Update doc comment --- crates/fj-core/src/geometry/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-core/src/geometry/mod.rs b/crates/fj-core/src/geometry/mod.rs index 52bfaddde..39dc822fb 100644 --- a/crates/fj-core/src/geometry/mod.rs +++ b/crates/fj-core/src/geometry/mod.rs @@ -1,4 +1,4 @@ -//! Types that are tied to objects, but aren't objects themselves +//! Geometry that is applied to the topological object graph mod boundary; mod curve;