Simplify `UpdateShell::update_face`

This commit is contained in:
Hanno Braun 2023-05-04 12:53:38 +02:00
parent f55069e875
commit 27fadd7d8c
2 changed files with 21 additions and 17 deletions

View File

@ -9,7 +9,7 @@ pub trait UpdateShell {
fn update_face(
&self,
handle: &Handle<Face>,
f: impl FnMut(&Handle<Face>) -> Handle<Face>,
replacement: Handle<Face>,
) -> Shell;
/// Remove a face from the shell
@ -20,11 +20,11 @@ impl UpdateShell for Shell {
fn update_face(
&self,
handle: &Handle<Face>,
mut f: impl FnMut(&Handle<Face>) -> Handle<Face>,
replacement: Handle<Face>,
) -> Shell {
let faces = self.faces().into_iter().map(|face| {
if face.id() == handle.id() {
f(face)
replacement.clone()
} else {
face.clone()
}

View File

@ -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!(