From 4740b3bdb6199ec6e44a95f174390704c3550009 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Sat, 23 Mar 2024 01:13:55 +0100 Subject: [PATCH] Remove curve boundary from `HalfEdge` --- crates/fj-core/src/objects/kinds/half_edge.rs | 16 +------- .../fj-core/src/operations/build/half_edge.rs | 14 +++---- .../fj-core/src/operations/reverse/cycle.rs | 1 - crates/fj-core/src/operations/reverse/edge.rs | 11 ++---- .../fj-core/src/operations/split/half_edge.rs | 37 ++++++++----------- .../fj-core/src/operations/transform/edge.rs | 4 +- .../src/operations/update/half_edge.rs | 2 - crates/fj-core/src/validate/shell.rs | 1 - 8 files changed, 26 insertions(+), 60 deletions(-) diff --git a/crates/fj-core/src/objects/kinds/half_edge.rs b/crates/fj-core/src/objects/kinds/half_edge.rs index 523def5dc..6608d40d3 100644 --- a/crates/fj-core/src/objects/kinds/half_edge.rs +++ b/crates/fj-core/src/objects/kinds/half_edge.rs @@ -1,7 +1,4 @@ -use fj_math::Point; - use crate::{ - geometry::CurveBoundary, objects::{Curve, Vertex}, storage::Handle, }; @@ -35,30 +32,19 @@ use crate::{ /// [`Shell`]: crate::objects::Shell #[derive(Clone, Debug)] pub struct HalfEdge { - boundary: CurveBoundary>, curve: Handle, start_vertex: Handle, } impl HalfEdge { /// Create an instance of `Edge` - pub fn new( - boundary: impl Into>>, - curve: Handle, - start_vertex: Handle, - ) -> Self { + pub fn new(curve: Handle, start_vertex: Handle) -> Self { Self { - boundary: boundary.into(), curve, start_vertex, } } - /// Access the boundary points of the edge on the curve - pub fn boundary(&self) -> CurveBoundary> { - self.boundary - } - /// Access the curve of the edge pub fn curve(&self) -> &Handle { &self.curve diff --git a/crates/fj-core/src/operations/build/half_edge.rs b/crates/fj-core/src/operations/build/half_edge.rs index 0d0a3ce5a..36004248b 100644 --- a/crates/fj-core/src/operations/build/half_edge.rs +++ b/crates/fj-core/src/operations/build/half_edge.rs @@ -17,13 +17,13 @@ use crate::{ pub trait BuildHalfEdge { /// Create a half-edge that is not joined to a sibling fn unjoined( - boundary: impl Into>>, + _: impl Into>>, core: &mut Core, ) -> HalfEdge { let curve = Curve::new().insert(core); let start_vertex = Vertex::new().insert(core); - HalfEdge::new(boundary, curve, start_vertex) + HalfEdge::new(curve, start_vertex) } /// Create a half-edge from its sibling @@ -35,13 +35,9 @@ pub trait BuildHalfEdge { let mut geometry = core.layers.geometry.of_half_edge(sibling); geometry.boundary = geometry.boundary.reverse(); - HalfEdge::new( - sibling.boundary().reverse(), - sibling.curve().clone(), - start_vertex, - ) - .insert(core) - .set_geometry(geometry, &mut core.layers.geometry) + HalfEdge::new(sibling.curve().clone(), start_vertex) + .insert(core) + .set_geometry(geometry, &mut core.layers.geometry) } /// Create an arc diff --git a/crates/fj-core/src/operations/reverse/cycle.rs b/crates/fj-core/src/operations/reverse/cycle.rs index a3dd7b3cb..f3d3f341d 100644 --- a/crates/fj-core/src/operations/reverse/cycle.rs +++ b/crates/fj-core/src/operations/reverse/cycle.rs @@ -18,7 +18,6 @@ impl Reverse for Cycle { geometry.boundary = geometry.boundary.reverse(); HalfEdge::new( - current.boundary().reverse(), current.curve().clone(), next.start_vertex().clone(), ) diff --git a/crates/fj-core/src/operations/reverse/edge.rs b/crates/fj-core/src/operations/reverse/edge.rs index 4508a25e7..e42ae6a98 100644 --- a/crates/fj-core/src/operations/reverse/edge.rs +++ b/crates/fj-core/src/operations/reverse/edge.rs @@ -13,13 +13,10 @@ impl ReverseCurveCoordinateSystems for Handle { geometry.path = geometry.path.reverse(); geometry.boundary = geometry.boundary.reverse(); - let half_edge = HalfEdge::new( - geometry.boundary, - self.curve().clone(), - self.start_vertex().clone(), - ) - .insert(core) - .derive_from(self, core); + let half_edge = + HalfEdge::new(self.curve().clone(), self.start_vertex().clone()) + .insert(core) + .derive_from(self, core); 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 ebe1ef0a1..92621b7fa 100644 --- a/crates/fj-core/src/operations/split/half_edge.rs +++ b/crates/fj-core/src/operations/split/half_edge.rs @@ -45,28 +45,21 @@ impl SplitHalfEdge for Handle { let geometry = core.layers.geometry.of_half_edge(self); let [start, end] = geometry.boundary.inner; - let a = HalfEdge::new( - [start, point], - self.curve().clone(), - self.start_vertex().clone(), - ) - .insert(core) - .derive_from(self, core) - .set_geometry( - geometry.with_boundary([start, point]), - &mut core.layers.geometry, - ); - let b = HalfEdge::new( - [point, end], - self.curve().clone(), - Vertex::new().insert(core), - ) - .insert(core) - .derive_from(self, core) - .set_geometry( - geometry.with_boundary([point, end]), - &mut core.layers.geometry, - ); + let a = + HalfEdge::new(self.curve().clone(), self.start_vertex().clone()) + .insert(core) + .derive_from(self, core) + .set_geometry( + geometry.with_boundary([start, point]), + &mut core.layers.geometry, + ); + let b = HalfEdge::new(self.curve().clone(), Vertex::new().insert(core)) + .insert(core) + .derive_from(self, core) + .set_geometry( + geometry.with_boundary([point, end]), + &mut core.layers.geometry, + ); [a, b] } diff --git a/crates/fj-core/src/operations/transform/edge.rs b/crates/fj-core/src/operations/transform/edge.rs index 9e1a708ad..6baf3fcc9 100644 --- a/crates/fj-core/src/operations/transform/edge.rs +++ b/crates/fj-core/src/operations/transform/edge.rs @@ -13,7 +13,6 @@ impl TransformObject for Handle { core: &mut Core, cache: &mut TransformCache, ) -> Self { - let boundary = self.boundary(); let curve = self .curve() .clone() @@ -23,8 +22,7 @@ impl TransformObject for Handle { .clone() .transform_with_cache(transform, core, cache); - let half_edge = - HalfEdge::new(boundary, curve, start_vertex).insert(core); + let half_edge = HalfEdge::new(curve, start_vertex).insert(core); core.layers.geometry.define_half_edge( half_edge.clone(), diff --git a/crates/fj-core/src/operations/update/half_edge.rs b/crates/fj-core/src/operations/update/half_edge.rs index 003a6a224..b1f782d1d 100644 --- a/crates/fj-core/src/operations/update/half_edge.rs +++ b/crates/fj-core/src/operations/update/half_edge.rs @@ -38,7 +38,6 @@ impl UpdateHalfEdge for HalfEdge { T: Insert>, { HalfEdge::new( - self.boundary(), update(self.curve(), core) .insert(core) .derive_from(self.curve(), core), @@ -55,7 +54,6 @@ impl UpdateHalfEdge for HalfEdge { T: Insert>, { HalfEdge::new( - self.boundary(), self.curve().clone(), update(self.start_vertex(), core) .insert(core) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index e687aa2dd..83d85a258 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -462,7 +462,6 @@ mod tests { geometry.boundary.reverse(); [HalfEdge::new( - half_edge.boundary().reverse(), half_edge.curve().clone(), half_edge.start_vertex().clone(), )