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/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/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 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 313bdeaae..5cff834e4 100644 --- a/crates/fj-kernel/src/operations/mod.rs +++ b/crates/fj-kernel/src/operations/mod.rs @@ -7,12 +7,17 @@ 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, + 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; diff --git a/crates/fj-kernel/src/operations/update/shell.rs b/crates/fj-kernel/src/operations/update/shell.rs index f8717e666..3133b2d83 100644 --- a/crates/fj-kernel/src/operations/update/shell.rs +++ b/crates/fj-kernel/src/operations/update/shell.rs @@ -6,10 +6,10 @@ use crate::{ /// Update a [`Shell`] pub trait UpdateShell { /// Update a face of the shell - fn update_face( + fn replace_face( &self, - handle: &Handle, - f: impl FnMut(&Handle) -> Handle, + original: &Handle, + replacement: Handle, ) -> Shell; /// Remove a face from the shell @@ -17,14 +17,14 @@ pub trait UpdateShell { } impl UpdateShell for Shell { - fn update_face( + fn replace_face( &self, - handle: &Handle, - mut f: impl FnMut(&Handle) -> Handle, + original: &Handle, + replacement: Handle, ) -> Shell { let faces = self.faces().into_iter().map(|face| { - if face.id() == handle.id() { - f(face) + if face.id() == original.id() { + 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..f1a81b4e8 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.replace_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!(