From 27fadd7d8ccb23c3c63a13b16dad9ec069548925 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 4 May 2023 12:53:38 +0200 Subject: [PATCH] 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!(