mirror of https://github.com/hannobraun/Fornjot
Simplify `UpdateShell::update_face`
This commit is contained in:
parent
f55069e875
commit
27fadd7d8c
|
@ -9,7 +9,7 @@ pub trait UpdateShell {
|
||||||
fn update_face(
|
fn update_face(
|
||||||
&self,
|
&self,
|
||||||
handle: &Handle<Face>,
|
handle: &Handle<Face>,
|
||||||
f: impl FnMut(&Handle<Face>) -> Handle<Face>,
|
replacement: Handle<Face>,
|
||||||
) -> Shell;
|
) -> Shell;
|
||||||
|
|
||||||
/// Remove a face from the shell
|
/// Remove a face from the shell
|
||||||
|
@ -20,11 +20,11 @@ impl UpdateShell for Shell {
|
||||||
fn update_face(
|
fn update_face(
|
||||||
&self,
|
&self,
|
||||||
handle: &Handle<Face>,
|
handle: &Handle<Face>,
|
||||||
mut f: impl FnMut(&Handle<Face>) -> Handle<Face>,
|
replacement: Handle<Face>,
|
||||||
) -> Shell {
|
) -> Shell {
|
||||||
let faces = self.faces().into_iter().map(|face| {
|
let faces = self.faces().into_iter().map(|face| {
|
||||||
if face.id() == handle.id() {
|
if face.id() == handle.id() {
|
||||||
f(face)
|
replacement.clone()
|
||||||
} else {
|
} else {
|
||||||
face.clone()
|
face.clone()
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,8 +210,12 @@ mod tests {
|
||||||
[[0., 0., 0.], [0., 1., 0.], [1., 0., 0.], [0., 0., 1.]],
|
[[0., 0., 0.], [0., 1., 0.], [1., 0., 0.], [0., 0., 1.]],
|
||||||
&mut services,
|
&mut services,
|
||||||
);
|
);
|
||||||
let invalid = valid.shell.update_face(&valid.abc.face, |face| {
|
let invalid = valid.shell.update_face(
|
||||||
face.update_exterior(|cycle| {
|
&valid.abc.face,
|
||||||
|
valid
|
||||||
|
.abc
|
||||||
|
.face
|
||||||
|
.update_exterior(|cycle| {
|
||||||
cycle
|
cycle
|
||||||
.update_nth_half_edge(0, |half_edge| {
|
.update_nth_half_edge(0, |half_edge| {
|
||||||
let global_form =
|
let global_form =
|
||||||
|
@ -222,8 +226,8 @@ mod tests {
|
||||||
})
|
})
|
||||||
.insert(&mut services)
|
.insert(&mut services)
|
||||||
})
|
})
|
||||||
.insert(&mut services)
|
.insert(&mut services),
|
||||||
});
|
);
|
||||||
|
|
||||||
valid.shell.validate_and_return_first_error()?;
|
valid.shell.validate_and_return_first_error()?;
|
||||||
assert_contains_err!(
|
assert_contains_err!(
|
||||||
|
|
Loading…
Reference in New Issue