From e89c38baec783b08df6ea6e9bd8599d73122d501 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 14 Mar 2023 17:43:42 +0100 Subject: [PATCH 01/10] Expect cycle in `FaceBuilder::add_interior` --- crates/fj-kernel/src/algorithms/intersect/curve_face.rs | 9 ++++----- crates/fj-kernel/src/algorithms/sweep/face.rs | 3 +-- crates/fj-kernel/src/algorithms/triangulate/mod.rs | 9 ++++----- crates/fj-kernel/src/builder/face.rs | 8 +++++--- crates/fj-kernel/src/validate/face.rs | 9 ++++----- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index a27eb150c..205fa59be 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -153,7 +153,7 @@ mod tests { builder::{CycleBuilder, FaceBuilder}, geometry::curve::Curve, insert::Insert, - partial::{PartialFace, PartialObject}, + partial::{PartialCycle, PartialFace, PartialObject}, services::Services, }; @@ -193,13 +193,12 @@ mod tests { face.exterior = exterior.insert(&mut services.objects); } { - let mut interior = face.add_interior(&mut services.objects); - let (updated, _) = - interior.read().clone().update_as_polygon_from_points( + let (interior, _) = PartialCycle::new(&mut services.objects) + .update_as_polygon_from_points( interior_points, &mut services.objects, ); - *interior.write() = updated; + face.add_interior(interior, &mut services.objects); } face.build(&mut services.objects) diff --git a/crates/fj-kernel/src/algorithms/sweep/face.rs b/crates/fj-kernel/src/algorithms/sweep/face.rs index 77dd034c7..10f533515 100644 --- a/crates/fj-kernel/src/algorithms/sweep/face.rs +++ b/crates/fj-kernel/src/algorithms/sweep/face.rs @@ -92,8 +92,7 @@ impl Sweep for Handle { if i == 0 { top_face.exterior = top_cycle.build(objects).insert(objects); } else { - let mut interior = top_face.add_interior(objects); - *interior.write() = top_cycle; + top_face.add_interior(top_cycle, objects); }; } diff --git a/crates/fj-kernel/src/algorithms/triangulate/mod.rs b/crates/fj-kernel/src/algorithms/triangulate/mod.rs index fadbb4b6c..a52773085 100644 --- a/crates/fj-kernel/src/algorithms/triangulate/mod.rs +++ b/crates/fj-kernel/src/algorithms/triangulate/mod.rs @@ -80,7 +80,7 @@ mod tests { builder::{CycleBuilder, FaceBuilder}, insert::Insert, objects::Face, - partial::{PartialFace, PartialObject}, + partial::{PartialCycle, PartialFace, PartialObject}, services::Services, storage::Handle, }; @@ -152,13 +152,12 @@ mod tests { face.exterior = exterior.insert(&mut services.objects); } { - let mut interior = face.add_interior(&mut services.objects); - let (updated, _) = - interior.read().clone().update_as_polygon_from_points( + let (interior, _) = PartialCycle::new(&mut services.objects) + .update_as_polygon_from_points( [e, f, g, h], &mut services.objects, ); - *interior.write() = updated; + face.add_interior(interior, &mut services.objects); } let face = face .build(&mut services.objects) diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index 2ee8339d3..aed0c6f9d 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -1,6 +1,6 @@ use crate::{ objects::{Cycle, Objects}, - partial::{Partial, PartialFace}, + partial::{Partial, PartialCycle, PartialFace}, services::Service, }; @@ -9,6 +9,7 @@ pub trait FaceBuilder { /// Add an interior cycle fn add_interior( &mut self, + cycle: PartialCycle, objects: &mut Service, ) -> Partial; } @@ -16,9 +17,10 @@ pub trait FaceBuilder { impl FaceBuilder for PartialFace { fn add_interior( &mut self, - objects: &mut Service, + cycle: PartialCycle, + _: &mut Service, ) -> Partial { - let cycle = Partial::new(objects); + let cycle = Partial::from_partial(cycle); self.interiors.push(cycle.clone()); cycle } diff --git a/crates/fj-kernel/src/validate/face.rs b/crates/fj-kernel/src/validate/face.rs index 52e15d454..cfbcb50bb 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -75,7 +75,7 @@ mod tests { builder::{CycleBuilder, FaceBuilder}, insert::Insert, objects::Face, - partial::{PartialFace, PartialObject}, + partial::{PartialCycle, PartialFace, PartialObject}, services::Services, validate::{FaceValidationError, Validate, ValidationError}, }; @@ -97,13 +97,12 @@ mod tests { face.exterior = exterior.insert(&mut services.objects); } { - let mut interior = face.add_interior(&mut services.objects); - let (updated, _) = - interior.read().clone().update_as_polygon_from_points( + let (interior, _) = PartialCycle::new(&mut services.objects) + .update_as_polygon_from_points( [[1., 1.], [1., 2.], [2., 1.]], &mut services.objects, ); - *interior.write() = updated; + face.add_interior(interior, &mut services.objects); } face.build(&mut services.objects) }; From b03e13577f88f75749982c9088a279e81ba92050 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 15 Mar 2023 11:28:05 +0100 Subject: [PATCH 02/10] Return `Handle` from `add_interior` --- crates/fj-kernel/src/builder/face.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index aed0c6f9d..35c117f26 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -2,6 +2,7 @@ use crate::{ objects::{Cycle, Objects}, partial::{Partial, PartialCycle, PartialFace}, services::Service, + storage::Handle, }; /// Builder API for [`PartialFace`] @@ -11,17 +12,17 @@ pub trait FaceBuilder { &mut self, cycle: PartialCycle, objects: &mut Service, - ) -> Partial; + ) -> Handle; } impl FaceBuilder for PartialFace { fn add_interior( &mut self, cycle: PartialCycle, - _: &mut Service, - ) -> Partial { + objects: &mut Service, + ) -> Handle { let cycle = Partial::from_partial(cycle); self.interiors.push(cycle.clone()); - cycle + cycle.build(objects) } } From f6020c614863495b8716ede1afb1aad73313370c Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 15 Mar 2023 11:31:44 +0100 Subject: [PATCH 03/10] Use `Handle` for `PartialFace` interiors --- crates/fj-kernel/src/builder/face.rs | 7 ++++--- crates/fj-kernel/src/partial/objects/face.rs | 16 ++++++---------- crates/fj-operations/src/difference_2d.rs | 7 ++----- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index 35c117f26..fb61caacd 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -1,6 +1,7 @@ use crate::{ + insert::Insert, objects::{Cycle, Objects}, - partial::{Partial, PartialCycle, PartialFace}, + partial::{PartialCycle, PartialFace, PartialObject}, services::Service, storage::Handle, }; @@ -21,8 +22,8 @@ impl FaceBuilder for PartialFace { cycle: PartialCycle, objects: &mut Service, ) -> Handle { - let cycle = Partial::from_partial(cycle); + let cycle = cycle.build(objects).insert(objects); self.interiors.push(cycle.clone()); - cycle.build(objects) + cycle } } diff --git a/crates/fj-kernel/src/partial/objects/face.rs b/crates/fj-kernel/src/partial/objects/face.rs index ac009c8a7..60440b646 100644 --- a/crates/fj-kernel/src/partial/objects/face.rs +++ b/crates/fj-kernel/src/partial/objects/face.rs @@ -3,7 +3,7 @@ use fj_interop::mesh::Color; use crate::{ insert::Insert, objects::{Cycle, Face, Objects, Surface}, - partial::{FullToPartialCache, Partial, PartialObject}, + partial::{FullToPartialCache, PartialObject}, services::Service, storage::Handle, }; @@ -20,7 +20,7 @@ pub struct PartialFace { /// The cycles that bound the face on the inside /// /// Each of these cycles defines a hole in the face. - pub interiors: Vec>, + pub interiors: Vec>, /// The color of the face pub color: Option, @@ -38,23 +38,19 @@ impl PartialObject for PartialFace { } } - fn from_full(face: &Self::Full, cache: &mut FullToPartialCache) -> Self { + fn from_full(face: &Self::Full, _: &mut FullToPartialCache) -> Self { Self { surface: Some(face.surface().clone()), exterior: face.exterior().clone(), - interiors: face - .interiors() - .map(|cycle| Partial::from_full(cycle.clone(), cache)) - .collect(), + interiors: face.interiors().cloned().collect(), color: Some(face.color()), } } - fn build(self, objects: &mut Service) -> Self::Full { + fn build(self, _: &mut Service) -> Self::Full { let surface = self.surface.expect("Need `Surface` to build `Face`"); - let interiors = - self.interiors.into_iter().map(|cycle| cycle.build(objects)); + let interiors = self.interiors; let color = self.color.unwrap_or_default(); Face::new(surface, self.exterior, interiors, color) diff --git a/crates/fj-operations/src/difference_2d.rs b/crates/fj-operations/src/difference_2d.rs index c55b73ef5..8e228bd5f 100644 --- a/crates/fj-operations/src/difference_2d.rs +++ b/crates/fj-operations/src/difference_2d.rs @@ -47,8 +47,7 @@ impl Shape for fj::Difference2d { exteriors.push(face.exterior().clone()); for cycle in face.interiors() { - interiors - .push(Partial::from(cycle.clone().reverse(objects))); + interiors.push(cycle.clone().reverse(objects)); } } @@ -59,9 +58,7 @@ impl Shape for fj::Difference2d { "Trying to subtract faces with different surfaces.", ); - interiors.push(Partial::from( - face.exterior().clone().reverse(objects), - )); + interiors.push(face.exterior().clone().reverse(objects)); } // Faces only support one exterior, while the code here comes from From 9aee43a20173dcafc373364b0e8a6c00cb65974b Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 15 Mar 2023 11:32:29 +0100 Subject: [PATCH 04/10] Inline redundant variable --- crates/fj-kernel/src/partial/objects/face.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/fj-kernel/src/partial/objects/face.rs b/crates/fj-kernel/src/partial/objects/face.rs index 60440b646..4c072b616 100644 --- a/crates/fj-kernel/src/partial/objects/face.rs +++ b/crates/fj-kernel/src/partial/objects/face.rs @@ -49,10 +49,8 @@ impl PartialObject for PartialFace { fn build(self, _: &mut Service) -> Self::Full { let surface = self.surface.expect("Need `Surface` to build `Face`"); - - let interiors = self.interiors; let color = self.color.unwrap_or_default(); - Face::new(surface, self.exterior, interiors, color) + Face::new(surface, self.exterior, self.interiors, color) } } From a65f0a3c2aa0356003ff31030e0e5738f9593824 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 15 Mar 2023 11:40:20 +0100 Subject: [PATCH 05/10] Take `Cycle` in `FaceBuilder::add_interior` --- crates/fj-kernel/src/algorithms/intersect/curve_face.rs | 1 + crates/fj-kernel/src/algorithms/sweep/face.rs | 3 ++- crates/fj-kernel/src/algorithms/triangulate/mod.rs | 1 + crates/fj-kernel/src/builder/face.rs | 8 ++++---- crates/fj-kernel/src/validate/face.rs | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index 205fa59be..4e075b4de 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -198,6 +198,7 @@ mod tests { interior_points, &mut services.objects, ); + let interior = interior.build(&mut services.objects); face.add_interior(interior, &mut services.objects); } diff --git a/crates/fj-kernel/src/algorithms/sweep/face.rs b/crates/fj-kernel/src/algorithms/sweep/face.rs index 10f533515..cd4d095c8 100644 --- a/crates/fj-kernel/src/algorithms/sweep/face.rs +++ b/crates/fj-kernel/src/algorithms/sweep/face.rs @@ -88,9 +88,10 @@ impl Sweep for Handle { let (top_cycle, _) = PartialCycle::new(objects).connect_to_edges(top_edges, objects); + let top_cycle = top_cycle.build(objects); if i == 0 { - top_face.exterior = top_cycle.build(objects).insert(objects); + top_face.exterior = top_cycle.insert(objects); } else { top_face.add_interior(top_cycle, objects); }; diff --git a/crates/fj-kernel/src/algorithms/triangulate/mod.rs b/crates/fj-kernel/src/algorithms/triangulate/mod.rs index a52773085..b3d1bdf58 100644 --- a/crates/fj-kernel/src/algorithms/triangulate/mod.rs +++ b/crates/fj-kernel/src/algorithms/triangulate/mod.rs @@ -157,6 +157,7 @@ mod tests { [e, f, g, h], &mut services.objects, ); + let interior = interior.build(&mut services.objects); face.add_interior(interior, &mut services.objects); } let face = face diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index fb61caacd..bcaf053a9 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -1,7 +1,7 @@ use crate::{ insert::Insert, objects::{Cycle, Objects}, - partial::{PartialCycle, PartialFace, PartialObject}, + partial::PartialFace, services::Service, storage::Handle, }; @@ -11,7 +11,7 @@ pub trait FaceBuilder { /// Add an interior cycle fn add_interior( &mut self, - cycle: PartialCycle, + cycle: Cycle, objects: &mut Service, ) -> Handle; } @@ -19,10 +19,10 @@ pub trait FaceBuilder { impl FaceBuilder for PartialFace { fn add_interior( &mut self, - cycle: PartialCycle, + cycle: Cycle, objects: &mut Service, ) -> Handle { - let cycle = cycle.build(objects).insert(objects); + let cycle = cycle.insert(objects); self.interiors.push(cycle.clone()); cycle } diff --git a/crates/fj-kernel/src/validate/face.rs b/crates/fj-kernel/src/validate/face.rs index cfbcb50bb..a1071d888 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -102,6 +102,7 @@ mod tests { [[1., 1.], [1., 2.], [2., 1.]], &mut services.objects, ); + let interior = interior.build(&mut services.objects); face.add_interior(interior, &mut services.objects); } face.build(&mut services.objects) From 8208e4eccaec11d7b6db24ad10ad2e321a3fc1a8 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 15 Mar 2023 11:43:12 +0100 Subject: [PATCH 06/10] Avoid using `PartialCycle` in tests --- .../src/algorithms/intersect/curve_face.rs | 6 +++--- crates/fj-kernel/src/algorithms/triangulate/mod.rs | 14 ++++++-------- crates/fj-kernel/src/validate/face.rs | 7 +++---- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index 4e075b4de..524124d4c 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -153,7 +153,8 @@ mod tests { builder::{CycleBuilder, FaceBuilder}, geometry::curve::Curve, insert::Insert, - partial::{PartialCycle, PartialFace, PartialObject}, + objects::Cycle, + partial::{PartialFace, PartialObject}, services::Services, }; @@ -193,12 +194,11 @@ mod tests { face.exterior = exterior.insert(&mut services.objects); } { - let (interior, _) = PartialCycle::new(&mut services.objects) + let (interior, _) = Cycle::new([]) .update_as_polygon_from_points( interior_points, &mut services.objects, ); - let interior = interior.build(&mut services.objects); face.add_interior(interior, &mut services.objects); } diff --git a/crates/fj-kernel/src/algorithms/triangulate/mod.rs b/crates/fj-kernel/src/algorithms/triangulate/mod.rs index b3d1bdf58..a65acf51e 100644 --- a/crates/fj-kernel/src/algorithms/triangulate/mod.rs +++ b/crates/fj-kernel/src/algorithms/triangulate/mod.rs @@ -79,8 +79,8 @@ mod tests { algorithms::approx::{Approx, Tolerance}, builder::{CycleBuilder, FaceBuilder}, insert::Insert, - objects::Face, - partial::{PartialCycle, PartialFace, PartialObject}, + objects::{Cycle, Face}, + partial::{PartialFace, PartialObject}, services::Services, storage::Handle, }; @@ -152,12 +152,10 @@ mod tests { face.exterior = exterior.insert(&mut services.objects); } { - let (interior, _) = PartialCycle::new(&mut services.objects) - .update_as_polygon_from_points( - [e, f, g, h], - &mut services.objects, - ); - let interior = interior.build(&mut services.objects); + let (interior, _) = Cycle::new([]).update_as_polygon_from_points( + [e, f, g, h], + &mut services.objects, + ); face.add_interior(interior, &mut services.objects); } let face = face diff --git a/crates/fj-kernel/src/validate/face.rs b/crates/fj-kernel/src/validate/face.rs index a1071d888..903dfa0fc 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -74,8 +74,8 @@ mod tests { algorithms::reverse::Reverse, builder::{CycleBuilder, FaceBuilder}, insert::Insert, - objects::Face, - partial::{PartialCycle, PartialFace, PartialObject}, + objects::{Cycle, Face}, + partial::{PartialFace, PartialObject}, services::Services, validate::{FaceValidationError, Validate, ValidationError}, }; @@ -97,12 +97,11 @@ mod tests { face.exterior = exterior.insert(&mut services.objects); } { - let (interior, _) = PartialCycle::new(&mut services.objects) + let (interior, _) = Cycle::new([]) .update_as_polygon_from_points( [[1., 1.], [1., 2.], [2., 1.]], &mut services.objects, ); - let interior = interior.build(&mut services.objects); face.add_interior(interior, &mut services.objects); } face.build(&mut services.objects) From 9a248a0b0a7cd8cebd20fad18f4f03972c7dd9ae Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 15 Mar 2023 11:44:20 +0100 Subject: [PATCH 07/10] Avoid using `PartialCycle` in sweep code --- crates/fj-kernel/src/algorithms/sweep/face.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/face.rs b/crates/fj-kernel/src/algorithms/sweep/face.rs index cd4d095c8..ff289f5d7 100644 --- a/crates/fj-kernel/src/algorithms/sweep/face.rs +++ b/crates/fj-kernel/src/algorithms/sweep/face.rs @@ -8,10 +8,8 @@ use crate::{ builder::{CycleBuilder, FaceBuilder}, geometry::curve::GlobalPath, insert::Insert, - objects::{Face, Objects, Shell}, - partial::{ - Partial, PartialCycle, PartialFace, PartialObject, PartialShell, - }, + objects::{Cycle, Face, Objects, Shell}, + partial::{Partial, PartialFace, PartialObject, PartialShell}, services::Service, storage::Handle, }; @@ -87,8 +85,7 @@ impl Sweep for Handle { } let (top_cycle, _) = - PartialCycle::new(objects).connect_to_edges(top_edges, objects); - let top_cycle = top_cycle.build(objects); + Cycle::new([]).connect_to_edges(top_edges, objects); if i == 0 { top_face.exterior = top_cycle.insert(objects); From 0642dce450abe1229b1e56f31a71c130a2769ac6 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 15 Mar 2023 11:50:56 +0100 Subject: [PATCH 08/10] Update doc comment --- crates/fj-kernel/src/builder/cycle.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/builder/cycle.rs b/crates/fj-kernel/src/builder/cycle.rs index b3dab17f8..28122d5e0 100644 --- a/crates/fj-kernel/src/builder/cycle.rs +++ b/crates/fj-kernel/src/builder/cycle.rs @@ -11,7 +11,7 @@ use crate::{ use super::{HalfEdgeBuilder, ObjectArgument}; -/// Builder API for [`PartialCycle`] +/// Builder API for [`Cycle`] pub trait CycleBuilder: Sized { /// Add a new half-edge to the cycle /// From 215153215d6da435eaa3247e865202c97ea95bb6 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 15 Mar 2023 11:47:39 +0100 Subject: [PATCH 09/10] Remove unused `CycleBuilder` implementation --- crates/fj-kernel/src/builder/cycle.rs | 60 --------------------------- 1 file changed, 60 deletions(-) diff --git a/crates/fj-kernel/src/builder/cycle.rs b/crates/fj-kernel/src/builder/cycle.rs index 28122d5e0..f4ce6ba82 100644 --- a/crates/fj-kernel/src/builder/cycle.rs +++ b/crates/fj-kernel/src/builder/cycle.rs @@ -4,7 +4,6 @@ use crate::{ geometry::curve::Curve, insert::Insert, objects::{Cycle, HalfEdge, Objects}, - partial::PartialCycle, services::Service, storage::Handle, }; @@ -112,62 +111,3 @@ impl CycleBuilder for Cycle { (self, edges) } } - -impl CycleBuilder for PartialCycle { - fn add_half_edge( - mut self, - half_edge: HalfEdge, - objects: &mut Service, - ) -> (Self, Handle) { - let half_edge = half_edge.insert(objects); - self.half_edges.push(half_edge.clone()); - (self, half_edge) - } - - fn update_as_polygon_from_points( - mut self, - points: O, - objects: &mut Service, - ) -> (Self, O::SameSize>) - where - O: ObjectArgument

, - P: Clone + Into>, - { - let half_edges = points.map_with_next(|start, end| { - let half_edge = HalfEdgeBuilder::line_segment([start, end], None) - .build(objects); - - let (cycle, half_edge) = - self.clone().add_half_edge(half_edge, objects); - self = cycle; - - half_edge - }); - - (self, half_edges) - } - - fn connect_to_edges( - mut self, - edges: O, - objects: &mut Service, - ) -> (Self, O::SameSize>) - where - O: ObjectArgument<(Handle, Curve, [Point<1>; 2])>, - { - let edges = - edges.map_with_prev(|(_, curve, boundary), (prev, _, _)| { - let half_edge = HalfEdgeBuilder::new(curve, boundary) - .with_start_vertex(prev.start_vertex().clone()) - .build(objects); - - let (cycle, half_edge) = - self.clone().add_half_edge(half_edge, objects); - self = cycle; - - half_edge - }); - - (self, edges) - } -} From f98f6e492b0a7d37b77e8656e7eb8b862665da4b Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 15 Mar 2023 11:48:35 +0100 Subject: [PATCH 10/10] Remove `PartialCycle` --- crates/fj-kernel/src/partial/mod.rs | 4 +-- crates/fj-kernel/src/partial/objects/cycle.rs | 33 ------------------- crates/fj-kernel/src/partial/objects/mod.rs | 1 - crates/fj-kernel/src/partial/traits.rs | 1 - 4 files changed, 2 insertions(+), 37 deletions(-) delete mode 100644 crates/fj-kernel/src/partial/objects/cycle.rs diff --git a/crates/fj-kernel/src/partial/mod.rs b/crates/fj-kernel/src/partial/mod.rs index ef084f360..461c07594 100644 --- a/crates/fj-kernel/src/partial/mod.rs +++ b/crates/fj-kernel/src/partial/mod.rs @@ -16,8 +16,8 @@ mod wrapper; pub use self::{ objects::{ - cycle::PartialCycle, face::PartialFace, shell::PartialShell, - sketch::PartialSketch, solid::PartialSolid, + face::PartialFace, shell::PartialShell, sketch::PartialSketch, + solid::PartialSolid, }, traits::{HasPartial, PartialObject}, wrapper::{FullToPartialCache, Partial}, diff --git a/crates/fj-kernel/src/partial/objects/cycle.rs b/crates/fj-kernel/src/partial/objects/cycle.rs deleted file mode 100644 index c81c0665e..000000000 --- a/crates/fj-kernel/src/partial/objects/cycle.rs +++ /dev/null @@ -1,33 +0,0 @@ -use crate::{ - objects::{Cycle, HalfEdge, Objects}, - partial::{FullToPartialCache, PartialObject}, - services::Service, - storage::Handle, -}; - -/// A partial [`Cycle`] -#[derive(Clone, Debug)] -pub struct PartialCycle { - /// The half-edges that make up the cycle - pub half_edges: Vec>, -} - -impl PartialObject for PartialCycle { - type Full = Cycle; - - fn new(_: &mut Service) -> Self { - Self { - half_edges: Vec::new(), - } - } - - fn from_full(cycle: &Self::Full, _: &mut FullToPartialCache) -> Self { - Self { - half_edges: cycle.half_edges().cloned().collect(), - } - } - - fn build(self, _: &mut Service) -> Self::Full { - Cycle::new(self.half_edges) - } -} diff --git a/crates/fj-kernel/src/partial/objects/mod.rs b/crates/fj-kernel/src/partial/objects/mod.rs index f693681df..2136df99c 100644 --- a/crates/fj-kernel/src/partial/objects/mod.rs +++ b/crates/fj-kernel/src/partial/objects/mod.rs @@ -1,4 +1,3 @@ -pub mod cycle; pub mod face; pub mod shell; pub mod sketch; diff --git a/crates/fj-kernel/src/partial/traits.rs b/crates/fj-kernel/src/partial/traits.rs index 9cb526b68..0b824b48b 100644 --- a/crates/fj-kernel/src/partial/traits.rs +++ b/crates/fj-kernel/src/partial/traits.rs @@ -36,7 +36,6 @@ macro_rules! impl_trait { } impl_trait!( - Cycle, PartialCycle; Face, PartialFace; Shell, PartialShell; Sketch, PartialSketch;