From c47df2e547dcf47ad3b67c3917a5b4c1fb83f329 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 19 Feb 2024 15:03:58 +0100 Subject: [PATCH 01/10] Update presentation layer in `SweepHalfEdge` --- crates/fj-core/src/operations/sweep/half_edge.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/fj-core/src/operations/sweep/half_edge.rs b/crates/fj-core/src/operations/sweep/half_edge.rs index f88efdd1c..2fbae8fc3 100644 --- a/crates/fj-core/src/operations/sweep/half_edge.rs +++ b/crates/fj-core/src/operations/sweep/half_edge.rs @@ -6,6 +6,7 @@ use crate::{ operations::{ build::{BuildCycle, BuildHalfEdge}, insert::Insert, + presentation::SetColor, update::{UpdateCycle, UpdateHalfEdge}, }, storage::Handle, @@ -136,6 +137,11 @@ impl SweepHalfEdge for HalfEdge { let exterior = exterior.insert(core); let region = Region::new(exterior, [], color).insert(core); + + if let Some(color) = color { + region.set_color(color, core); + } + let face = Face::new(surface, region); (face, edge_top) From 78e795e92ec0fdfb76c37fe15884a8cc147efad6 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 16 Feb 2024 13:54:09 +0100 Subject: [PATCH 02/10] Expect color in `SweepRegion::sweep_region` This avoids a call to `Region::color`, which I'm preparing to remove. --- crates/fj-core/src/operations/holes.rs | 2 ++ crates/fj-core/src/operations/sweep/face.rs | 8 +++++++- crates/fj-core/src/operations/sweep/region.rs | 9 +++++---- crates/fj-core/src/operations/sweep/shell_face.rs | 8 +++++++- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/crates/fj-core/src/operations/holes.rs b/crates/fj-core/src/operations/holes.rs index 350254bb8..fafe7203e 100644 --- a/crates/fj-core/src/operations/holes.rs +++ b/crates/fj-core/src/operations/holes.rs @@ -53,6 +53,7 @@ impl AddHole for Shell { ) .sweep_region( location.face.surface(), + None, path, &mut SweepCache::default(), core, @@ -118,6 +119,7 @@ impl AddHole for Shell { ) .sweep_region( entry_location.face.surface(), + None, path, &mut SweepCache::default(), core, diff --git a/crates/fj-core/src/operations/sweep/face.rs b/crates/fj-core/src/operations/sweep/face.rs index 439b8b0cd..844736ef6 100644 --- a/crates/fj-core/src/operations/sweep/face.rs +++ b/crates/fj-core/src/operations/sweep/face.rs @@ -49,7 +49,13 @@ impl SweepFace for Handle { let bottom_face = self; let other_faces = bottom_face .region() - .sweep_region(bottom_face.surface(), path, cache, core) + .sweep_region( + bottom_face.surface(), + bottom_face.region().color(), + path, + cache, + core, + ) .all_faces() .map(|side_face| side_face.insert(core)); diff --git a/crates/fj-core/src/operations/sweep/region.rs b/crates/fj-core/src/operations/sweep/region.rs index 608e8d097..1fcf44f72 100644 --- a/crates/fj-core/src/operations/sweep/region.rs +++ b/crates/fj-core/src/operations/sweep/region.rs @@ -32,6 +32,7 @@ pub trait SweepRegion { fn sweep_region( &self, surface: &Surface, + color: Option, path: impl Into>, cache: &mut SweepCache, core: &mut Core, @@ -42,6 +43,7 @@ impl SweepRegion for Region { fn sweep_region( &self, surface: &Surface, + color: Option, path: impl Into>, cache: &mut SweepCache, core: &mut Core, @@ -53,7 +55,7 @@ impl SweepRegion for Region { let top_exterior = sweep_cycle( self.exterior(), surface, - self.color(), + color, &mut faces, path, cache, @@ -67,7 +69,7 @@ impl SweepRegion for Region { sweep_cycle( bottom_cycle, surface, - self.color(), + color, &mut faces, path, cache, @@ -79,8 +81,7 @@ impl SweepRegion for Region { let top_face = { let top_surface = surface.translate(path, core).insert(core); let top_region = - Region::new(top_exterior, top_interiors, self.color()) - .insert(core); + Region::new(top_exterior, top_interiors, color).insert(core); Face::new(top_surface, top_region) }; diff --git a/crates/fj-core/src/operations/sweep/shell_face.rs b/crates/fj-core/src/operations/sweep/shell_face.rs index 6cace2c42..cfc9f9c8d 100644 --- a/crates/fj-core/src/operations/sweep/shell_face.rs +++ b/crates/fj-core/src/operations/sweep/shell_face.rs @@ -65,7 +65,13 @@ impl SweepFaceOfShell for Shell { .derive_from(face.region().exterior(), core); let region = Region::new(exterior, [], face.region().color()); let faces = region - .sweep_region(face.surface(), path, &mut cache, core) + .sweep_region( + face.surface(), + region.color(), + path, + &mut cache, + core, + ) .all_faces() .collect::>(); From 73bcf6634204ef49b975e78c75b9f213d430f9e0 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 19 Feb 2024 14:53:25 +0100 Subject: [PATCH 03/10] Refactor to prepare for follow-on change --- crates/fj-core/src/operations/sweep/shell_face.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-core/src/operations/sweep/shell_face.rs b/crates/fj-core/src/operations/sweep/shell_face.rs index cfc9f9c8d..e244dd8a9 100644 --- a/crates/fj-core/src/operations/sweep/shell_face.rs +++ b/crates/fj-core/src/operations/sweep/shell_face.rs @@ -67,7 +67,7 @@ impl SweepFaceOfShell for Shell { let faces = region .sweep_region( face.surface(), - region.color(), + face.region().color(), path, &mut cache, core, From 0ed2548d6943cca2d0737dd8cbdfe1e0f3bec351 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 19 Feb 2024 15:03:13 +0100 Subject: [PATCH 04/10] Replace uses of `Region::color` with `GetColor` --- crates/fj-core/src/operations/sweep/face.rs | 4 ++-- crates/fj-core/src/operations/sweep/shell_face.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/operations/sweep/face.rs b/crates/fj-core/src/operations/sweep/face.rs index 844736ef6..12ef13b65 100644 --- a/crates/fj-core/src/operations/sweep/face.rs +++ b/crates/fj-core/src/operations/sweep/face.rs @@ -2,7 +2,7 @@ use fj_math::Vector; use crate::{ objects::{Face, Shell}, - operations::insert::Insert, + operations::{insert::Insert, presentation::GetColor}, storage::Handle, Core, }; @@ -51,7 +51,7 @@ impl SweepFace for Handle { .region() .sweep_region( bottom_face.surface(), - bottom_face.region().color(), + bottom_face.region().get_color(core), path, cache, core, diff --git a/crates/fj-core/src/operations/sweep/shell_face.rs b/crates/fj-core/src/operations/sweep/shell_face.rs index e244dd8a9..3437c1b16 100644 --- a/crates/fj-core/src/operations/sweep/shell_face.rs +++ b/crates/fj-core/src/operations/sweep/shell_face.rs @@ -5,6 +5,7 @@ use crate::{ operations::{ derive::DeriveFrom, insert::Insert, + presentation::GetColor, reverse::Reverse, sweep::{SweepCache, SweepRegion}, update::UpdateShell, @@ -67,7 +68,7 @@ impl SweepFaceOfShell for Shell { let faces = region .sweep_region( face.surface(), - face.region().color(), + face.region().get_color(core), path, &mut cache, core, From 9b9a20de5be5aaec15e4dafbd05b8053ab6aab84 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 19 Feb 2024 15:06:34 +0100 Subject: [PATCH 05/10] Remove `color` attribute from `Region` --- crates/fj-core/src/objects/kinds/region.rs | 10 ---------- crates/fj-core/src/operations/build/face.rs | 2 +- crates/fj-core/src/operations/build/region.rs | 7 +++---- crates/fj-core/src/operations/presentation.rs | 1 - crates/fj-core/src/operations/replace/curve.rs | 1 - .../src/operations/replace/half_edge.rs | 1 - .../fj-core/src/operations/replace/vertex.rs | 1 - .../fj-core/src/operations/reverse/region.rs | 4 ++-- .../fj-core/src/operations/sweep/half_edge.rs | 2 +- crates/fj-core/src/operations/sweep/region.rs | 2 +- .../fj-core/src/operations/sweep/shell_face.rs | 2 +- .../fj-core/src/operations/transform/region.rs | 5 +---- crates/fj-core/src/operations/update/region.rs | 6 +++--- crates/fj-core/src/validate/face.rs | 9 +++------ crates/fj-core/src/validate/sketch.rs | 18 ++++++------------ crates/fj-core/src/validate/solid.rs | 8 ++------ 16 files changed, 24 insertions(+), 55 deletions(-) diff --git a/crates/fj-core/src/objects/kinds/region.rs b/crates/fj-core/src/objects/kinds/region.rs index b106c928f..ebec1ff3e 100644 --- a/crates/fj-core/src/objects/kinds/region.rs +++ b/crates/fj-core/src/objects/kinds/region.rs @@ -1,7 +1,5 @@ //! A single, continues 2d region -use fj_interop::Color; - use crate::{ objects::{Cycle, ObjectSet}, storage::Handle, @@ -19,7 +17,6 @@ use crate::{ pub struct Region { exterior: Handle, interiors: ObjectSet, - color: Option, } impl Region { @@ -27,12 +24,10 @@ impl Region { pub fn new( exterior: Handle, interiors: impl IntoIterator>, - color: Option, ) -> Self { Self { exterior, interiors: interiors.into_iter().collect(), - color, } } @@ -54,9 +49,4 @@ impl Region { // for doing that here *and* in `interiors`. [self.exterior()].into_iter().chain(self.interiors()) } - - /// Access the color of the region - pub fn color(&self) -> Option { - self.color - } } diff --git a/crates/fj-core/src/operations/build/face.rs b/crates/fj-core/src/operations/build/face.rs index 910a8ce73..0013950ca 100644 --- a/crates/fj-core/src/operations/build/face.rs +++ b/crates/fj-core/src/operations/build/face.rs @@ -22,7 +22,7 @@ pub trait BuildFace { /// Build a face with an empty exterior, no interiors, and no color fn unbound(surface: Handle, core: &mut Core) -> Face { let exterior = Cycle::empty().insert(core); - let region = Region::new(exterior, [], None).insert(core); + let region = Region::new(exterior, []).insert(core); Face::new(surface, region) } diff --git a/crates/fj-core/src/operations/build/region.rs b/crates/fj-core/src/operations/build/region.rs index cb96c61dc..4f5b9b719 100644 --- a/crates/fj-core/src/operations/build/region.rs +++ b/crates/fj-core/src/operations/build/region.rs @@ -16,9 +16,8 @@ pub trait BuildRegion { fn empty(core: &mut Core) -> Region { let exterior = Cycle::empty().insert(core); let interiors = []; - let color = None; - Region::new(exterior, interiors, color) + Region::new(exterior, interiors) } /// Build a circle @@ -28,7 +27,7 @@ pub trait BuildRegion { core: &mut Core, ) -> Region { let exterior = Cycle::circle(center, radius, core).insert(core); - Region::new(exterior, [], None) + Region::new(exterior, []) } /// Build a polygon @@ -39,7 +38,7 @@ pub trait BuildRegion { Ps::IntoIter: Clone + ExactSizeIterator, { let exterior = Cycle::polygon(points, core).insert(core); - Region::new(exterior, [], None) + Region::new(exterior, []) } } diff --git a/crates/fj-core/src/operations/presentation.rs b/crates/fj-core/src/operations/presentation.rs index ff6232f18..3b531c404 100644 --- a/crates/fj-core/src/operations/presentation.rs +++ b/crates/fj-core/src/operations/presentation.rs @@ -43,7 +43,6 @@ impl SetColor for Handle { Region::new( self.exterior().clone(), self.interiors().into_iter().cloned(), - Some(color), ) } } diff --git a/crates/fj-core/src/operations/replace/curve.rs b/crates/fj-core/src/operations/replace/curve.rs index fe6454ec6..5ad536411 100644 --- a/crates/fj-core/src/operations/replace/curve.rs +++ b/crates/fj-core/src/operations/replace/curve.rs @@ -117,7 +117,6 @@ impl ReplaceCurve for Region { }) .into_inner(), interiors, - self.color(), )) } else { ReplaceOutput::Original(self.clone()) diff --git a/crates/fj-core/src/operations/replace/half_edge.rs b/crates/fj-core/src/operations/replace/half_edge.rs index 4142287e5..e7c040ac5 100644 --- a/crates/fj-core/src/operations/replace/half_edge.rs +++ b/crates/fj-core/src/operations/replace/half_edge.rs @@ -83,7 +83,6 @@ impl ReplaceHalfEdge for Region { }) .into_inner(), interiors, - self.color(), )) } else { ReplaceOutput::Original(self.clone()) diff --git a/crates/fj-core/src/operations/replace/vertex.rs b/crates/fj-core/src/operations/replace/vertex.rs index 48dd82952..ab30bffcf 100644 --- a/crates/fj-core/src/operations/replace/vertex.rs +++ b/crates/fj-core/src/operations/replace/vertex.rs @@ -119,7 +119,6 @@ impl ReplaceVertex for Region { }) .into_inner(), interiors, - self.color(), )) } else { ReplaceOutput::Original(self.clone()) diff --git a/crates/fj-core/src/operations/reverse/region.rs b/crates/fj-core/src/operations/reverse/region.rs index e90b8b799..f3f91320a 100644 --- a/crates/fj-core/src/operations/reverse/region.rs +++ b/crates/fj-core/src/operations/reverse/region.rs @@ -17,7 +17,7 @@ impl Reverse for Region { cycle.reverse(core).insert(core).derive_from(cycle, core) }); - Region::new(exterior, interiors, self.color()) + Region::new(exterior, interiors) } } @@ -35,6 +35,6 @@ impl ReverseCurveCoordinateSystems for Region { .derive_from(cycle, core) }); - Region::new(exterior, interiors, self.color()) + Region::new(exterior, interiors) } } diff --git a/crates/fj-core/src/operations/sweep/half_edge.rs b/crates/fj-core/src/operations/sweep/half_edge.rs index 2fbae8fc3..6b1e6d3d1 100644 --- a/crates/fj-core/src/operations/sweep/half_edge.rs +++ b/crates/fj-core/src/operations/sweep/half_edge.rs @@ -136,7 +136,7 @@ impl SweepHalfEdge for HalfEdge { }); let exterior = exterior.insert(core); - let region = Region::new(exterior, [], color).insert(core); + let region = Region::new(exterior, []).insert(core); if let Some(color) = color { region.set_color(color, core); diff --git a/crates/fj-core/src/operations/sweep/region.rs b/crates/fj-core/src/operations/sweep/region.rs index 1fcf44f72..88600bd57 100644 --- a/crates/fj-core/src/operations/sweep/region.rs +++ b/crates/fj-core/src/operations/sweep/region.rs @@ -81,7 +81,7 @@ impl SweepRegion for Region { let top_face = { let top_surface = surface.translate(path, core).insert(core); let top_region = - Region::new(top_exterior, top_interiors, color).insert(core); + Region::new(top_exterior, top_interiors).insert(core); Face::new(top_surface, top_region) }; diff --git a/crates/fj-core/src/operations/sweep/shell_face.rs b/crates/fj-core/src/operations/sweep/shell_face.rs index 3437c1b16..4a54bbbde 100644 --- a/crates/fj-core/src/operations/sweep/shell_face.rs +++ b/crates/fj-core/src/operations/sweep/shell_face.rs @@ -64,7 +64,7 @@ impl SweepFaceOfShell for Shell { .reverse(core) .insert(core) .derive_from(face.region().exterior(), core); - let region = Region::new(exterior, [], face.region().color()); + let region = Region::new(exterior, []); let faces = region .sweep_region( face.surface(), diff --git a/crates/fj-core/src/operations/transform/region.rs b/crates/fj-core/src/operations/transform/region.rs index f1fb393e7..76fd6490f 100644 --- a/crates/fj-core/src/operations/transform/region.rs +++ b/crates/fj-core/src/operations/transform/region.rs @@ -9,9 +9,6 @@ impl TransformObject for Region { core: &mut Core, cache: &mut super::TransformCache, ) -> Self { - // Color does not need to be transformed. - let color = self.color(); - let exterior = self .exterior() .clone() @@ -20,6 +17,6 @@ impl TransformObject for Region { interior.transform_with_cache(transform, core, cache) }); - Region::new(exterior, interiors, color) + Region::new(exterior, interiors) } } diff --git a/crates/fj-core/src/operations/update/region.rs b/crates/fj-core/src/operations/update/region.rs index cca4cd08b..cc83b6daa 100644 --- a/crates/fj-core/src/operations/update/region.rs +++ b/crates/fj-core/src/operations/update/region.rs @@ -57,7 +57,7 @@ impl UpdateRegion for Region { let exterior = update(self.exterior(), core) .insert(core) .derive_from(self.exterior(), core); - Region::new(exterior, self.interiors().iter().cloned(), self.color()) + Region::new(exterior, self.interiors().iter().cloned()) } fn add_interiors( @@ -70,7 +70,7 @@ impl UpdateRegion for Region { { let interiors = interiors.into_iter().map(|cycle| cycle.insert(core)); let interiors = self.interiors().iter().cloned().chain(interiors); - Region::new(self.exterior().clone(), interiors, self.color()) + Region::new(self.exterior().clone(), interiors) } fn update_interior( @@ -91,6 +91,6 @@ impl UpdateRegion for Region { }), ) .expect("Cycle not found"); - Region::new(self.exterior().clone(), interiors, self.color()) + Region::new(self.exterior().clone(), interiors) } } diff --git a/crates/fj-core/src/validate/face.rs b/crates/fj-core/src/validate/face.rs index 94ded4be0..0ebe7044e 100644 --- a/crates/fj-core/src/validate/face.rs +++ b/crates/fj-core/src/validate/face.rs @@ -174,12 +174,9 @@ mod tests { }) .collect::>(); - let region = Region::new( - valid.region().exterior().clone(), - interiors, - valid.region().color(), - ) - .insert(&mut core); + let region = + Region::new(valid.region().exterior().clone(), interiors) + .insert(&mut core); Face::new(valid.surface().clone(), region) }; diff --git a/crates/fj-core/src/validate/sketch.rs b/crates/fj-core/src/validate/sketch.rs index 425e6812c..7495eb9f5 100644 --- a/crates/fj-core/src/validate/sketch.rs +++ b/crates/fj-core/src/validate/sketch.rs @@ -72,10 +72,9 @@ mod tests { Region::new( Cycle::new(vec![]).insert(&mut core), vec![shared_cycle.clone()], - None, ) .insert(&mut core), - Region::new(shared_cycle, vec![], None).insert(&mut core), + Region::new(shared_cycle, vec![]).insert(&mut core), ]); assert_contains_err!( invalid_sketch, @@ -87,7 +86,6 @@ mod tests { let valid_sketch = Sketch::new(vec![Region::new( Cycle::new(vec![]).insert(&mut core), vec![], - None, ) .insert(&mut core)]); valid_sketch.validate_and_return_first_error()?; @@ -114,12 +112,10 @@ mod tests { Cycle::new(vec![half_edge.clone(), sibling_edge.clone()]) .insert(&mut core); - let invalid_sketch = Sketch::new(vec![Region::new( - exterior.clone(), - vec![interior], - None, - ) - .insert(&mut core)]); + let invalid_sketch = + Sketch::new(vec![ + Region::new(exterior.clone(), vec![interior]).insert(&mut core) + ]); assert_contains_err!( invalid_sketch, ValidationError::Sketch(SketchValidationError::MultipleReferences( @@ -128,9 +124,7 @@ mod tests { ); let valid_sketch = - Sketch::new(vec![ - Region::new(exterior, vec![], None).insert(&mut core) - ]); + Sketch::new(vec![Region::new(exterior, vec![]).insert(&mut core)]); valid_sketch.validate_and_return_first_error()?; Ok(()) diff --git a/crates/fj-core/src/validate/solid.rs b/crates/fj-core/src/validate/solid.rs index b0bf01d85..c07832064 100644 --- a/crates/fj-core/src/validate/solid.rs +++ b/crates/fj-core/src/validate/solid.rs @@ -204,7 +204,6 @@ mod tests { ]) .insert(&mut core), vec![], - None, ) .insert(&mut core), ) @@ -251,7 +250,6 @@ mod tests { ]) .insert(&mut core), vec![], - None, ) .insert(&mut core); @@ -311,8 +309,7 @@ mod tests { v: [0., 1., 1.].into(), }) .insert(&mut core), - Region::new(shared_cycle.clone(), vec![], None) - .insert(&mut core), + Region::new(shared_cycle.clone(), vec![]).insert(&mut core), ) .insert(&mut core), Face::new( @@ -321,7 +318,7 @@ mod tests { v: [0., 0., 1.].into(), }) .insert(&mut core), - Region::new(shared_cycle, vec![], None).insert(&mut core), + Region::new(shared_cycle, vec![]).insert(&mut core), ) .insert(&mut core), ]) @@ -360,7 +357,6 @@ mod tests { Region::new( Cycle::new(vec![shared_edge.clone()]).insert(&mut core), vec![Cycle::new(vec![shared_edge.clone()]).insert(&mut core)], - None, ) .insert(&mut core), ) From f4c78923a84066ece0b869408013e61ed7e28d98 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 19 Feb 2024 15:08:09 +0100 Subject: [PATCH 06/10] Refactor to prepare for follow-on change --- models/color/src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/models/color/src/lib.rs b/models/color/src/lib.rs index 5071e486b..133966d57 100644 --- a/models/color/src/lib.rs +++ b/models/color/src/lib.rs @@ -18,7 +18,10 @@ pub fn model(core: &mut fj::core::Core) -> Solid { shell.faces().first(), |face, core| { [face.update_region( - |region, core| region.set_color([0., 1., 0.], core), + |region, core| { + region.set_color([0., 1., 0.], core); + region.clone() + }, core, )] }, From 36d8c022af9e952c6c3a513ea289e8fb92a92244 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 19 Feb 2024 15:08:37 +0100 Subject: [PATCH 07/10] Simplify `SetColor::set_color` --- crates/fj-core/src/operations/presentation.rs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/crates/fj-core/src/operations/presentation.rs b/crates/fj-core/src/operations/presentation.rs index 3b531c404..048ffdeef 100644 --- a/crates/fj-core/src/operations/presentation.rs +++ b/crates/fj-core/src/operations/presentation.rs @@ -23,26 +23,13 @@ impl GetColor for Handle { /// Set the color of an object pub trait SetColor: IsObject { /// Set the color of the object - fn set_color( - &self, - color: impl Into, - core: &mut Core, - ) -> Self::BareObject; + fn set_color(&self, color: impl Into, core: &mut Core); } impl SetColor for Handle { - fn set_color( - &self, - color: impl Into, - core: &mut Core, - ) -> Self::BareObject { + fn set_color(&self, color: impl Into, core: &mut Core) { let color = color.into(); core.layers.presentation.set_color(self.clone(), color); - - Region::new( - self.exterior().clone(), - self.interiors().into_iter().cloned(), - ) } } From ef15516c437722794d0ea4b2ab0d0af2185f9e13 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 19 Feb 2024 15:09:11 +0100 Subject: [PATCH 08/10] Remove unused trait bound --- crates/fj-core/src/operations/presentation.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/crates/fj-core/src/operations/presentation.rs b/crates/fj-core/src/operations/presentation.rs index 048ffdeef..8e8859297 100644 --- a/crates/fj-core/src/operations/presentation.rs +++ b/crates/fj-core/src/operations/presentation.rs @@ -2,11 +2,7 @@ use fj_interop::Color; -use crate::{ - objects::{IsObject, Region}, - storage::Handle, - Core, -}; +use crate::{objects::Region, storage::Handle, Core}; /// Get the color of an object pub trait GetColor { @@ -21,7 +17,7 @@ impl GetColor for Handle { } /// Set the color of an object -pub trait SetColor: IsObject { +pub trait SetColor { /// Set the color of the object fn set_color(&self, color: impl Into, core: &mut Core); } From 9cd24175c8997bf12fedd3122610ca67bc398c8e Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 19 Feb 2024 15:09:30 +0100 Subject: [PATCH 09/10] Inline redundant variable --- crates/fj-core/src/operations/presentation.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/operations/presentation.rs b/crates/fj-core/src/operations/presentation.rs index 8e8859297..64c5bc156 100644 --- a/crates/fj-core/src/operations/presentation.rs +++ b/crates/fj-core/src/operations/presentation.rs @@ -24,8 +24,8 @@ pub trait SetColor { impl SetColor for Handle { fn set_color(&self, color: impl Into, core: &mut Core) { - let color = color.into(); - - core.layers.presentation.set_color(self.clone(), color); + core.layers + .presentation + .set_color(self.clone(), color.into()); } } From 761b6d15192aab5fbdebd1a819a7228c15daa90c Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Feb 2024 15:17:12 +0100 Subject: [PATCH 10/10] Simplify `color` model --- models/color/src/lib.rs | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/models/color/src/lib.rs b/models/color/src/lib.rs index 133966d57..513d7a0c9 100644 --- a/models/color/src/lib.rs +++ b/models/color/src/lib.rs @@ -1,9 +1,7 @@ use fj::core::{ objects::Solid, operations::{ - presentation::SetColor, - split::SplitFace, - update::{UpdateFace, UpdateShell, UpdateSolid}, + presentation::SetColor, split::SplitFace, update::UpdateSolid, }, }; @@ -14,19 +12,7 @@ pub fn model(core: &mut fj::core::Core) -> Solid { cuboid.update_shell( cuboid.shells().only(), |shell, core| { - let shell = shell.update_face( - shell.faces().first(), - |face, core| { - [face.update_region( - |region, core| { - region.set_color([0., 1., 0.], core); - region.clone() - }, - core, - )] - }, - core, - ); + shell.faces().first().region().set_color([0., 1., 0.], core); // Split colored face, to make sure the same color is applied to the // two derived faces.