From fcfff0a7f50d682734d4c70efce7ad5f498de044 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 4 May 2023 12:41:41 +0200 Subject: [PATCH 1/7] Update imports --- crates/fj-kernel/src/operations/build/cycle.rs | 4 +--- crates/fj-kernel/src/operations/build/face.rs | 7 ++++--- crates/fj-kernel/src/operations/build/shell.rs | 5 ++--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/crates/fj-kernel/src/operations/build/cycle.rs b/crates/fj-kernel/src/operations/build/cycle.rs index ffb76f516..2e97cf50d 100644 --- a/crates/fj-kernel/src/operations/build/cycle.rs +++ b/crates/fj-kernel/src/operations/build/cycle.rs @@ -3,12 +3,10 @@ use itertools::Itertools; use crate::{ objects::{Cycle, HalfEdge}, - operations::Insert, + operations::{BuildHalfEdge, Insert}, services::Services, }; -use super::BuildHalfEdge; - /// Build a [`Cycle`] pub trait BuildCycle { /// Build an empty cycle diff --git a/crates/fj-kernel/src/operations/build/face.rs b/crates/fj-kernel/src/operations/build/face.rs index 76e12f18d..4146367a2 100644 --- a/crates/fj-kernel/src/operations/build/face.rs +++ b/crates/fj-kernel/src/operations/build/face.rs @@ -3,13 +3,14 @@ use fj_math::Point; use crate::{ objects::{Cycle, Face, HalfEdge, Surface, Vertex}, - operations::{Insert, IsInserted, IsInsertedNo}, + operations::{ + BuildCycle, BuildHalfEdge, BuildSurface, Insert, IsInserted, + IsInsertedNo, + }, services::Services, storage::Handle, }; -use super::{BuildCycle, BuildHalfEdge, BuildSurface}; - /// Build a [`Face`] pub trait BuildFace { /// Build a face with an empty exterior, no interiors, and no color diff --git a/crates/fj-kernel/src/operations/build/shell.rs b/crates/fj-kernel/src/operations/build/shell.rs index 41ed095af..83aeed52e 100644 --- a/crates/fj-kernel/src/operations/build/shell.rs +++ b/crates/fj-kernel/src/operations/build/shell.rs @@ -3,13 +3,12 @@ use fj_math::Point; use crate::{ objects::{Face, Shell}, operations::{ - Insert, IsInserted, IsInsertedNo, IsInsertedYes, JoinCycle, UpdateFace, + BuildFace, Insert, IsInserted, IsInsertedNo, IsInsertedYes, JoinCycle, + Polygon, UpdateFace, }, services::Services, }; -use super::{BuildFace, Polygon}; - /// Build a [`Shell`] pub trait BuildShell { /// Build a tetrahedron from the provided points From 1ddaea98f0561f81fc5387c7746bed1a9ad3074a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 4 May 2023 12:41:51 +0200 Subject: [PATCH 2/7] Consolidate redundant re-exports --- crates/fj-kernel/src/operations/build/mod.rs | 21 ++++++-------------- crates/fj-kernel/src/operations/mod.rs | 8 ++++++-- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/crates/fj-kernel/src/operations/build/mod.rs b/crates/fj-kernel/src/operations/build/mod.rs index fe6010c3b..273ea0fee 100644 --- a/crates/fj-kernel/src/operations/build/mod.rs +++ b/crates/fj-kernel/src/operations/build/mod.rs @@ -1,15 +1,6 @@ -mod cycle; -mod edge; -mod face; -mod shell; -mod solid; -mod surface; - -pub use self::{ - cycle::BuildCycle, - edge::BuildHalfEdge, - face::{BuildFace, Polygon}, - shell::{BuildShell, TetrahedronShell}, - solid::{BuildSolid, Tetrahedron}, - surface::BuildSurface, -}; +pub mod cycle; +pub mod edge; +pub mod face; +pub mod shell; +pub mod solid; +pub mod surface; diff --git a/crates/fj-kernel/src/operations/mod.rs b/crates/fj-kernel/src/operations/mod.rs index 313bdeaae..f52c82179 100644 --- a/crates/fj-kernel/src/operations/mod.rs +++ b/crates/fj-kernel/src/operations/mod.rs @@ -7,8 +7,12 @@ mod update; pub use self::{ build::{ - BuildCycle, BuildFace, BuildHalfEdge, BuildShell, BuildSolid, - BuildSurface, Polygon, Tetrahedron, TetrahedronShell, + cycle::BuildCycle, + edge::BuildHalfEdge, + face::{BuildFace, Polygon}, + shell::{BuildShell, TetrahedronShell}, + solid::{BuildSolid, Tetrahedron}, + surface::BuildSurface, }, insert::{Insert, IsInserted, IsInsertedNo, IsInsertedYes}, join::JoinCycle, From dff88af85b1eeefdd95def4a840997be45bdaa6e Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 4 May 2023 12:42:41 +0200 Subject: [PATCH 3/7] Consolidate redundant re-exports --- crates/fj-kernel/src/operations/join/mod.rs | 4 +--- crates/fj-kernel/src/operations/mod.rs | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/fj-kernel/src/operations/join/mod.rs b/crates/fj-kernel/src/operations/join/mod.rs index 9594ced45..a7b6b03b5 100644 --- a/crates/fj-kernel/src/operations/join/mod.rs +++ b/crates/fj-kernel/src/operations/join/mod.rs @@ -1,3 +1 @@ -mod cycle; - -pub use self::cycle::JoinCycle; +pub mod cycle; diff --git a/crates/fj-kernel/src/operations/mod.rs b/crates/fj-kernel/src/operations/mod.rs index f52c82179..9e7b5ac43 100644 --- a/crates/fj-kernel/src/operations/mod.rs +++ b/crates/fj-kernel/src/operations/mod.rs @@ -15,7 +15,7 @@ pub use self::{ surface::BuildSurface, }, insert::{Insert, IsInserted, IsInsertedNo, IsInsertedYes}, - join::JoinCycle, + join::cycle::JoinCycle, update::{ UpdateCycle, UpdateFace, UpdateHalfEdge, UpdateShell, UpdateSolid, }, From f55069e875b9ea27e3944b9491fdd21fc4305d72 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 4 May 2023 12:43:56 +0200 Subject: [PATCH 4/7] Consolidate redundant re-exports --- crates/fj-kernel/src/operations/mod.rs | 3 ++- crates/fj-kernel/src/operations/update/mod.rs | 15 +++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/crates/fj-kernel/src/operations/mod.rs b/crates/fj-kernel/src/operations/mod.rs index 9e7b5ac43..5cff834e4 100644 --- a/crates/fj-kernel/src/operations/mod.rs +++ b/crates/fj-kernel/src/operations/mod.rs @@ -17,6 +17,7 @@ pub use self::{ insert::{Insert, IsInserted, IsInsertedNo, IsInsertedYes}, join::cycle::JoinCycle, update::{ - UpdateCycle, UpdateFace, UpdateHalfEdge, UpdateShell, UpdateSolid, + cycle::UpdateCycle, edge::UpdateHalfEdge, face::UpdateFace, + shell::UpdateShell, solid::UpdateSolid, }, }; diff --git a/crates/fj-kernel/src/operations/update/mod.rs b/crates/fj-kernel/src/operations/update/mod.rs index 431b97368..85f65f886 100644 --- a/crates/fj-kernel/src/operations/update/mod.rs +++ b/crates/fj-kernel/src/operations/update/mod.rs @@ -1,10 +1,5 @@ -mod cycle; -mod edge; -mod face; -mod shell; -mod solid; - -pub use self::{ - cycle::UpdateCycle, edge::UpdateHalfEdge, face::UpdateFace, - shell::UpdateShell, solid::UpdateSolid, -}; +pub mod cycle; +pub mod edge; +pub mod face; +pub mod shell; +pub mod solid; From 27fadd7d8ccb23c3c63a13b16dad9ec069548925 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 4 May 2023 12:53:38 +0200 Subject: [PATCH 5/7] Simplify `UpdateShell::update_face` --- .../fj-kernel/src/operations/update/shell.rs | 6 ++-- crates/fj-kernel/src/validate/shell.rs | 32 +++++++++++-------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/crates/fj-kernel/src/operations/update/shell.rs b/crates/fj-kernel/src/operations/update/shell.rs index f8717e666..00dcf6370 100644 --- a/crates/fj-kernel/src/operations/update/shell.rs +++ b/crates/fj-kernel/src/operations/update/shell.rs @@ -9,7 +9,7 @@ pub trait UpdateShell { fn update_face( &self, handle: &Handle, - f: impl FnMut(&Handle) -> Handle, + replacement: Handle, ) -> Shell; /// Remove a face from the shell @@ -20,11 +20,11 @@ impl UpdateShell for Shell { fn update_face( &self, handle: &Handle, - mut f: impl FnMut(&Handle) -> Handle, + replacement: Handle, ) -> Shell { let faces = self.faces().into_iter().map(|face| { if face.id() == handle.id() { - f(face) + replacement.clone() } else { face.clone() } diff --git a/crates/fj-kernel/src/validate/shell.rs b/crates/fj-kernel/src/validate/shell.rs index 91915bc3e..3c1e98127 100644 --- a/crates/fj-kernel/src/validate/shell.rs +++ b/crates/fj-kernel/src/validate/shell.rs @@ -210,20 +210,24 @@ mod tests { [[0., 0., 0.], [0., 1., 0.], [1., 0., 0.], [0., 0., 1.]], &mut services, ); - let invalid = valid.shell.update_face(&valid.abc.face, |face| { - face.update_exterior(|cycle| { - cycle - .update_nth_half_edge(0, |half_edge| { - let global_form = - GlobalEdge::new().insert(&mut services); - half_edge - .replace_global_form(global_form) - .insert(&mut services) - }) - .insert(&mut services) - }) - .insert(&mut services) - }); + let invalid = valid.shell.update_face( + &valid.abc.face, + valid + .abc + .face + .update_exterior(|cycle| { + cycle + .update_nth_half_edge(0, |half_edge| { + let global_form = + GlobalEdge::new().insert(&mut services); + half_edge + .replace_global_form(global_form) + .insert(&mut services) + }) + .insert(&mut services) + }) + .insert(&mut services), + ); valid.shell.validate_and_return_first_error()?; assert_contains_err!( From c93745443994cd3203656960d532f9cc2aa0fd20 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 4 May 2023 12:54:10 +0200 Subject: [PATCH 6/7] Update trait method name --- crates/fj-kernel/src/operations/update/shell.rs | 4 ++-- crates/fj-kernel/src/validate/shell.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-kernel/src/operations/update/shell.rs b/crates/fj-kernel/src/operations/update/shell.rs index 00dcf6370..ee5d16cba 100644 --- a/crates/fj-kernel/src/operations/update/shell.rs +++ b/crates/fj-kernel/src/operations/update/shell.rs @@ -6,7 +6,7 @@ use crate::{ /// Update a [`Shell`] pub trait UpdateShell { /// Update a face of the shell - fn update_face( + fn replace_face( &self, handle: &Handle, replacement: Handle, @@ -17,7 +17,7 @@ pub trait UpdateShell { } impl UpdateShell for Shell { - fn update_face( + fn replace_face( &self, handle: &Handle, replacement: Handle, diff --git a/crates/fj-kernel/src/validate/shell.rs b/crates/fj-kernel/src/validate/shell.rs index 3c1e98127..f1a81b4e8 100644 --- a/crates/fj-kernel/src/validate/shell.rs +++ b/crates/fj-kernel/src/validate/shell.rs @@ -210,7 +210,7 @@ mod tests { [[0., 0., 0.], [0., 1., 0.], [1., 0., 0.], [0., 0., 1.]], &mut services, ); - let invalid = valid.shell.update_face( + let invalid = valid.shell.replace_face( &valid.abc.face, valid .abc From 2e196adf82dec6f671d79589719cd4903a975ec7 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 4 May 2023 12:54:35 +0200 Subject: [PATCH 7/7] Update argument name --- crates/fj-kernel/src/operations/update/shell.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-kernel/src/operations/update/shell.rs b/crates/fj-kernel/src/operations/update/shell.rs index ee5d16cba..3133b2d83 100644 --- a/crates/fj-kernel/src/operations/update/shell.rs +++ b/crates/fj-kernel/src/operations/update/shell.rs @@ -8,7 +8,7 @@ pub trait UpdateShell { /// Update a face of the shell fn replace_face( &self, - handle: &Handle, + original: &Handle, replacement: Handle, ) -> Shell; @@ -19,11 +19,11 @@ pub trait UpdateShell { impl UpdateShell for Shell { fn replace_face( &self, - handle: &Handle, + original: &Handle, replacement: Handle, ) -> Shell { let faces = self.faces().into_iter().map(|face| { - if face.id() == handle.id() { + if face.id() == original.id() { replacement.clone() } else { face.clone()