From f43e84558926fb86c757540c8915ca38fed2a0ee Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 May 2024 13:48:13 +0200 Subject: [PATCH 1/8] Make variable name more precise --- crates/fj-core/src/operations/sweep/cycle.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-core/src/operations/sweep/cycle.rs b/crates/fj-core/src/operations/sweep/cycle.rs index 0b7b1ffef..29edf7eb9 100644 --- a/crates/fj-core/src/operations/sweep/cycle.rs +++ b/crates/fj-core/src/operations/sweep/cycle.rs @@ -64,7 +64,7 @@ impl SweepCycle for Cycle { let (bottom_half_edge, bottom_half_edge_next) = bottom_half_edge_pair; - let (side_face, top_edge) = bottom_half_edge.sweep_half_edge( + let (side_face, top_half_edge) = bottom_half_edge.sweep_half_edge( bottom_half_edge_next.start_vertex().clone(), surface.clone(), color, @@ -76,7 +76,7 @@ impl SweepCycle for Cycle { faces.push(side_face); top_edges.push(( - top_edge, + top_half_edge, *core.layers.geometry.of_half_edge(bottom_half_edge), )); } From 9dc849b287ac7a065b8d1da8516b580ecb53f26d Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 May 2024 13:49:27 +0200 Subject: [PATCH 2/8] Improve documentation of `JoinCycle` method --- crates/fj-core/src/operations/join/cycle.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/fj-core/src/operations/join/cycle.rs b/crates/fj-core/src/operations/join/cycle.rs index 037b823c2..298a83c56 100644 --- a/crates/fj-core/src/operations/join/cycle.rs +++ b/crates/fj-core/src/operations/join/cycle.rs @@ -17,7 +17,13 @@ use crate::{ /// Join a [`Cycle`] to another pub trait JoinCycle { - /// Add half-edges to the cycle that are joined to the provided ones + /// Add new half-edges to the cycle that are joined to the provided ones + /// + /// This method creates a new half-edge for each half-edge that is provided, + /// joins the new half-edge to the provided one, and adds the new half-edge + /// to the cycle. + /// + /// The geometry for each new half-edge needs to be provided as well. #[must_use] fn add_joined_edges(&self, edges: Es, core: &mut Core) -> Self where From 833d91f15d71a5c803ef645a94359ff21d78aab2 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 May 2024 13:55:08 +0200 Subject: [PATCH 3/8] Refactor to prepare for follow-on change --- crates/fj-core/src/operations/sweep/region.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/fj-core/src/operations/sweep/region.rs b/crates/fj-core/src/operations/sweep/region.rs index 05af614b7..31839dc67 100644 --- a/crates/fj-core/src/operations/sweep/region.rs +++ b/crates/fj-core/src/operations/sweep/region.rs @@ -52,6 +52,8 @@ impl SweepRegion for Region { let mut faces = Vec::new(); + let top_surface = surface.translate(path, core).insert(core); + let top_exterior = sweep_cycle( self.exterior(), surface.clone(), @@ -79,7 +81,6 @@ impl SweepRegion for Region { .collect::>(); let top_face = { - let top_surface = surface.translate(path, core).insert(core); let top_region = Region::new(top_exterior, top_interiors).insert(core); From 537519737dfd5a61e1bcc38924243960b921a13b Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 May 2024 13:55:59 +0200 Subject: [PATCH 4/8] Provide top surface to private `sweep_cycle` fn --- crates/fj-core/src/operations/sweep/region.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/fj-core/src/operations/sweep/region.rs b/crates/fj-core/src/operations/sweep/region.rs index 31839dc67..0192368d2 100644 --- a/crates/fj-core/src/operations/sweep/region.rs +++ b/crates/fj-core/src/operations/sweep/region.rs @@ -57,6 +57,7 @@ impl SweepRegion for Region { let top_exterior = sweep_cycle( self.exterior(), surface.clone(), + top_surface.clone(), color, &mut faces, path, @@ -71,6 +72,7 @@ impl SweepRegion for Region { sweep_cycle( bottom_cycle, surface.clone(), + top_surface.clone(), color, &mut faces, path, @@ -94,9 +96,11 @@ impl SweepRegion for Region { } } +#[allow(clippy::too_many_arguments)] fn sweep_cycle( bottom_cycle: &Cycle, bottom_surface: Handle, + _top_surface: Handle, color: Option, faces: &mut Vec, path: Vector<3>, From ce326893a46a86cb40f7c74c5e87408b5a6e6026 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 May 2024 13:57:00 +0200 Subject: [PATCH 5/8] Provide top surface to `SweepCycle::sweep_cycle` --- crates/fj-core/src/operations/sweep/cycle.rs | 2 ++ crates/fj-core/src/operations/sweep/region.rs | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/fj-core/src/operations/sweep/cycle.rs b/crates/fj-core/src/operations/sweep/cycle.rs index 29edf7eb9..726ea5fee 100644 --- a/crates/fj-core/src/operations/sweep/cycle.rs +++ b/crates/fj-core/src/operations/sweep/cycle.rs @@ -39,6 +39,7 @@ pub trait SweepCycle { fn sweep_cycle( &self, surface: Handle, + top_surface: Handle, color: Option, path: impl Into>, cache: &mut SweepCache, @@ -50,6 +51,7 @@ impl SweepCycle for Cycle { fn sweep_cycle( &self, surface: Handle, + _top_surface: Handle, color: Option, path: impl Into>, cache: &mut SweepCache, diff --git a/crates/fj-core/src/operations/sweep/region.rs b/crates/fj-core/src/operations/sweep/region.rs index 0192368d2..b3be68d8b 100644 --- a/crates/fj-core/src/operations/sweep/region.rs +++ b/crates/fj-core/src/operations/sweep/region.rs @@ -100,7 +100,7 @@ impl SweepRegion for Region { fn sweep_cycle( bottom_cycle: &Cycle, bottom_surface: Handle, - _top_surface: Handle, + top_surface: Handle, color: Option, faces: &mut Vec, path: Vector<3>, @@ -109,6 +109,7 @@ fn sweep_cycle( ) -> Handle { let swept_cycle = bottom_cycle.reverse(core).sweep_cycle( bottom_surface, + top_surface, color, path, cache, From 9ad7934b22e2107f42322db9de9710907d229b41 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 May 2024 13:57:56 +0200 Subject: [PATCH 6/8] Provide surface to `JoinCycle::add_joined_edges` --- crates/fj-core/src/operations/holes.rs | 3 +++ crates/fj-core/src/operations/join/cycle.rs | 16 +++++++++++++--- crates/fj-core/src/operations/sweep/cycle.rs | 5 +++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/crates/fj-core/src/operations/holes.rs b/crates/fj-core/src/operations/holes.rs index 519305263..f46980348 100644 --- a/crates/fj-core/src/operations/holes.rs +++ b/crates/fj-core/src/operations/holes.rs @@ -75,6 +75,7 @@ impl AddHole for Shell { entry.clone(), *core.layers.geometry.of_half_edge(&entry), )], + location.face.surface().clone(), core, )], core, @@ -150,6 +151,7 @@ impl AddHole for Shell { entry.clone(), *core.layers.geometry.of_half_edge(&entry), )], + entry_location.face.surface().clone(), core, )], core, @@ -171,6 +173,7 @@ impl AddHole for Shell { exit.clone(), *core.layers.geometry.of_half_edge(exit), )], + exit_location.face.surface().clone(), core, )], core, diff --git a/crates/fj-core/src/operations/join/cycle.rs b/crates/fj-core/src/operations/join/cycle.rs index 298a83c56..b50b472ab 100644 --- a/crates/fj-core/src/operations/join/cycle.rs +++ b/crates/fj-core/src/operations/join/cycle.rs @@ -11,7 +11,7 @@ use crate::{ update::{UpdateCycle, UpdateHalfEdge}, }, storage::Handle, - topology::{Cycle, HalfEdge}, + topology::{Cycle, HalfEdge, Surface}, Core, }; @@ -25,7 +25,12 @@ pub trait JoinCycle { /// /// The geometry for each new half-edge needs to be provided as well. #[must_use] - fn add_joined_edges(&self, edges: Es, core: &mut Core) -> Self + fn add_joined_edges( + &self, + edges: Es, + surface: Handle, + core: &mut Core, + ) -> Self where Es: IntoIterator, HalfEdgeGeom)>, Es::IntoIter: Clone + ExactSizeIterator; @@ -82,7 +87,12 @@ pub trait JoinCycle { } impl JoinCycle for Cycle { - fn add_joined_edges(&self, edges: Es, core: &mut Core) -> Self + fn add_joined_edges( + &self, + edges: Es, + _: Handle, + core: &mut Core, + ) -> Self where Es: IntoIterator, HalfEdgeGeom)>, Es::IntoIter: Clone + ExactSizeIterator, diff --git a/crates/fj-core/src/operations/sweep/cycle.rs b/crates/fj-core/src/operations/sweep/cycle.rs index 726ea5fee..4d00d294a 100644 --- a/crates/fj-core/src/operations/sweep/cycle.rs +++ b/crates/fj-core/src/operations/sweep/cycle.rs @@ -51,7 +51,7 @@ impl SweepCycle for Cycle { fn sweep_cycle( &self, surface: Handle, - _top_surface: Handle, + top_surface: Handle, color: Option, path: impl Into>, cache: &mut SweepCache, @@ -83,7 +83,8 @@ impl SweepCycle for Cycle { )); } - let top_cycle = Cycle::empty().add_joined_edges(top_edges, core); + let top_cycle = + Cycle::empty().add_joined_edges(top_edges, top_surface, core); SweptCycle { faces, top_cycle } } From a6738fc9b65b6e4bfc670cb123605047294889d1 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 May 2024 13:58:52 +0200 Subject: [PATCH 7/8] Update doc comment --- crates/fj-core/src/operations/join/cycle.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/fj-core/src/operations/join/cycle.rs b/crates/fj-core/src/operations/join/cycle.rs index b50b472ab..f4e61b6ec 100644 --- a/crates/fj-core/src/operations/join/cycle.rs +++ b/crates/fj-core/src/operations/join/cycle.rs @@ -24,6 +24,8 @@ pub trait JoinCycle { /// to the cycle. /// /// The geometry for each new half-edge needs to be provided as well. + /// + /// Also requires the surface that the cycle is defined in. #[must_use] fn add_joined_edges( &self, From 36056ee995ffb2311e037ff8ff2eeaf9ce4e5b11 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 May 2024 13:59:50 +0200 Subject: [PATCH 8/8] Set curve geometry in `JoinCycle` method --- crates/fj-core/src/operations/join/cycle.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/crates/fj-core/src/operations/join/cycle.rs b/crates/fj-core/src/operations/join/cycle.rs index f4e61b6ec..45122513b 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, + geometry::{HalfEdgeGeom, LocalCurveGeom}, operations::{ build::BuildHalfEdge, geometry::UpdateHalfEdgeGeometry, @@ -92,7 +92,7 @@ impl JoinCycle for Cycle { fn add_joined_edges( &self, edges: Es, - _: Handle, + surface: Handle, core: &mut Core, ) -> Self where @@ -103,14 +103,24 @@ impl JoinCycle for Cycle { .into_iter() .circular_tuple_windows() .map(|((prev_half_edge, _), (half_edge, geometry))| { - HalfEdge::unjoined(core) + 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(geometry, &mut core.layers.geometry) + .set_geometry(geometry, &mut core.layers.geometry); + + core.layers.geometry.define_curve( + half_edge.curve().clone(), + surface.clone(), + LocalCurveGeom { + path: geometry.path, + }, + ); + + half_edge }) .collect::>(); self.add_half_edges(half_edges, core)