From 07f6701935b2ca711a5fd27f430781ce76bbe6d3 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 26 Jun 2024 19:19:42 +0200 Subject: [PATCH 1/3] Add `SweptHalfEdge` --- crates/fj-core/src/operations/sweep/cycle.rs | 7 +++++-- .../fj-core/src/operations/sweep/half_edge.rs | 20 ++++++++++++++++--- crates/fj-core/src/operations/sweep/mod.rs | 2 +- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/crates/fj-core/src/operations/sweep/cycle.rs b/crates/fj-core/src/operations/sweep/cycle.rs index 4ef505f30..974770fc1 100644 --- a/crates/fj-core/src/operations/sweep/cycle.rs +++ b/crates/fj-core/src/operations/sweep/cycle.rs @@ -10,7 +10,7 @@ use crate::{ Core, }; -use super::SweepCache; +use super::{half_edge::SweptHalfEdge, SweepCache}; /// # Sweep a [`Cycle`] /// @@ -66,7 +66,10 @@ impl SweepCycle for Cycle { let (bottom_half_edge, bottom_half_edge_next) = bottom_half_edge_pair; - let (side_face, top_half_edge) = bottom_half_edge.sweep_half_edge( + let SweptHalfEdge { + face: side_face, + top_half_edge, + } = bottom_half_edge.sweep_half_edge( bottom_half_edge_next.start_vertex().clone(), bottom_surface.clone(), color, diff --git a/crates/fj-core/src/operations/sweep/half_edge.rs b/crates/fj-core/src/operations/sweep/half_edge.rs index d87ac7f3d..f5c4ec1e5 100644 --- a/crates/fj-core/src/operations/sweep/half_edge.rs +++ b/crates/fj-core/src/operations/sweep/half_edge.rs @@ -44,7 +44,7 @@ pub trait SweepHalfEdge { path: impl Into>, cache: &mut SweepCache, core: &mut Core, - ) -> (Face, Handle); + ) -> SweptHalfEdge; } impl SweepHalfEdge for Handle { @@ -56,7 +56,7 @@ impl SweepHalfEdge for Handle { path: impl Into>, cache: &mut SweepCache, core: &mut Core, - ) -> (Face, Handle) { + ) -> SweptHalfEdge { let path = path.into(); let half_edge_geom = *core.layers.geometry.of_half_edge(self); @@ -161,6 +161,20 @@ impl SweepHalfEdge for Handle { let face = Face::new(surface, region); - (face, edge_top) + SweptHalfEdge { + face, + top_half_edge: edge_top, + } } } + +/// The result of sweeping a [`HalfEdge`] +/// +/// See [`SweepHalfEdge`]. +pub struct SweptHalfEdge { + /// The face created by sweeping the half-edge + pub face: Face, + + /// The top half-edge of the created face + pub top_half_edge: Handle, +} diff --git a/crates/fj-core/src/operations/sweep/mod.rs b/crates/fj-core/src/operations/sweep/mod.rs index f93efbe93..df9c6df37 100644 --- a/crates/fj-core/src/operations/sweep/mod.rs +++ b/crates/fj-core/src/operations/sweep/mod.rs @@ -15,7 +15,7 @@ mod vertex; pub use self::{ cycle::{SweepCycle, SweptCycle}, face::SweepFace, - half_edge::SweepHalfEdge, + half_edge::{SweepHalfEdge, SweptHalfEdge}, path::SweepSurfacePath, region::{SweepRegion, SweptRegion}, shell_face::{ShellExtendedBySweep, SweepFaceOfShell}, From 2a38d70d4656b403042d07c41274618a9018c844 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 26 Jun 2024 19:22:00 +0200 Subject: [PATCH 2/3] Simplify --- crates/fj-core/src/operations/sweep/cycle.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/crates/fj-core/src/operations/sweep/cycle.rs b/crates/fj-core/src/operations/sweep/cycle.rs index 974770fc1..8700d02bb 100644 --- a/crates/fj-core/src/operations/sweep/cycle.rs +++ b/crates/fj-core/src/operations/sweep/cycle.rs @@ -10,7 +10,7 @@ use crate::{ Core, }; -use super::{half_edge::SweptHalfEdge, SweepCache}; +use super::SweepCache; /// # Sweep a [`Cycle`] /// @@ -66,10 +66,7 @@ impl SweepCycle for Cycle { let (bottom_half_edge, bottom_half_edge_next) = bottom_half_edge_pair; - let SweptHalfEdge { - face: side_face, - top_half_edge, - } = bottom_half_edge.sweep_half_edge( + let swept_half_edge = bottom_half_edge.sweep_half_edge( bottom_half_edge_next.start_vertex().clone(), bottom_surface.clone(), color, @@ -78,10 +75,10 @@ impl SweepCycle for Cycle { core, ); - faces.push(side_face); + faces.push(swept_half_edge.face); top_edges.push(( - top_half_edge, + swept_half_edge.top_half_edge, *core.layers.geometry.of_half_edge(bottom_half_edge), core.layers .geometry From f5e31019d4913c2e346d97d907a2ce3833f8d8bc Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 26 Jun 2024 19:27:37 +0200 Subject: [PATCH 3/3] Update variable name --- crates/fj-core/src/operations/sweep/cycle.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/operations/sweep/cycle.rs b/crates/fj-core/src/operations/sweep/cycle.rs index 8700d02bb..0f631b9b3 100644 --- a/crates/fj-core/src/operations/sweep/cycle.rs +++ b/crates/fj-core/src/operations/sweep/cycle.rs @@ -60,7 +60,7 @@ impl SweepCycle for Cycle { let path = path.into(); let mut faces = Vec::new(); - let mut top_edges = Vec::new(); + let mut top_half_edges = Vec::new(); for bottom_half_edge_pair in self.half_edges().pairs() { let (bottom_half_edge, bottom_half_edge_next) = @@ -77,7 +77,7 @@ impl SweepCycle for Cycle { faces.push(swept_half_edge.face); - top_edges.push(( + top_half_edges.push(( swept_half_edge.top_half_edge, *core.layers.geometry.of_half_edge(bottom_half_edge), core.layers @@ -91,7 +91,7 @@ impl SweepCycle for Cycle { } let top_cycle = - Cycle::empty().add_joined_edges(top_edges, top_surface, core); + Cycle::empty().add_joined_edges(top_half_edges, top_surface, core); SweptCycle { faces, top_cycle } }