From fe78f7286a416bd01ba6b7fe8d7d72ddff9ec694 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 12:40:07 +0100 Subject: [PATCH 01/37] Add `PartialObject::new` This is preparation for removing the `Default` bound from `PartialObject`, which is getting in the way of my current work. --- crates/fj-kernel/src/partial/objects/cycle.rs | 4 ++++ crates/fj-kernel/src/partial/objects/edge.rs | 8 ++++++++ crates/fj-kernel/src/partial/objects/face.rs | 4 ++++ crates/fj-kernel/src/partial/objects/shell.rs | 4 ++++ crates/fj-kernel/src/partial/objects/sketch.rs | 4 ++++ crates/fj-kernel/src/partial/objects/solid.rs | 4 ++++ crates/fj-kernel/src/partial/objects/surface.rs | 4 ++++ crates/fj-kernel/src/partial/objects/vertex.rs | 4 ++++ crates/fj-kernel/src/partial/traits.rs | 3 +++ 9 files changed, 39 insertions(+) diff --git a/crates/fj-kernel/src/partial/objects/cycle.rs b/crates/fj-kernel/src/partial/objects/cycle.rs index 7718f52ad..dcdf62b5a 100644 --- a/crates/fj-kernel/src/partial/objects/cycle.rs +++ b/crates/fj-kernel/src/partial/objects/cycle.rs @@ -14,6 +14,10 @@ pub struct PartialCycle { impl PartialObject for PartialCycle { type Full = Cycle; + fn new() -> Self { + Self::default() + } + fn from_full(cycle: &Self::Full, cache: &mut FullToPartialCache) -> Self { Self { half_edges: cycle diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index 4b49eb84d..8622fabdc 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -45,6 +45,10 @@ impl PartialHalfEdge { impl PartialObject for PartialHalfEdge { type Full = HalfEdge; + fn new() -> Self { + Self::default() + } + fn from_full( half_edge: &Self::Full, cache: &mut FullToPartialCache, @@ -104,6 +108,10 @@ pub struct PartialGlobalEdge {} impl PartialObject for PartialGlobalEdge { type Full = GlobalEdge; + fn new() -> Self { + Self::default() + } + fn from_full(_: &Self::Full, _: &mut FullToPartialCache) -> Self { Self {} } diff --git a/crates/fj-kernel/src/partial/objects/face.rs b/crates/fj-kernel/src/partial/objects/face.rs index 86b03bf0f..d708afbfc 100644 --- a/crates/fj-kernel/src/partial/objects/face.rs +++ b/crates/fj-kernel/src/partial/objects/face.rs @@ -28,6 +28,10 @@ pub struct PartialFace { impl PartialObject for PartialFace { type Full = Face; + fn new() -> Self { + Self::default() + } + fn from_full(face: &Self::Full, cache: &mut FullToPartialCache) -> Self { Self { surface: Partial::from_full(face.surface().clone(), cache), diff --git a/crates/fj-kernel/src/partial/objects/shell.rs b/crates/fj-kernel/src/partial/objects/shell.rs index 6802310a3..c661bbcb8 100644 --- a/crates/fj-kernel/src/partial/objects/shell.rs +++ b/crates/fj-kernel/src/partial/objects/shell.rs @@ -14,6 +14,10 @@ pub struct PartialShell { impl PartialObject for PartialShell { type Full = Shell; + fn new() -> Self { + Self::default() + } + fn from_full(shell: &Self::Full, cache: &mut FullToPartialCache) -> Self { Self { faces: shell diff --git a/crates/fj-kernel/src/partial/objects/sketch.rs b/crates/fj-kernel/src/partial/objects/sketch.rs index 2481543fb..66fd75cdc 100644 --- a/crates/fj-kernel/src/partial/objects/sketch.rs +++ b/crates/fj-kernel/src/partial/objects/sketch.rs @@ -14,6 +14,10 @@ pub struct PartialSketch { impl PartialObject for PartialSketch { type Full = Sketch; + fn new() -> Self { + Self::default() + } + fn from_full(sketch: &Self::Full, cache: &mut FullToPartialCache) -> Self { Self { faces: sketch diff --git a/crates/fj-kernel/src/partial/objects/solid.rs b/crates/fj-kernel/src/partial/objects/solid.rs index 6384d8bc9..33c9017d5 100644 --- a/crates/fj-kernel/src/partial/objects/solid.rs +++ b/crates/fj-kernel/src/partial/objects/solid.rs @@ -14,6 +14,10 @@ pub struct PartialSolid { impl PartialObject for PartialSolid { type Full = Solid; + fn new() -> Self { + Self::default() + } + fn from_full(solid: &Self::Full, cache: &mut FullToPartialCache) -> Self { Self { shells: solid diff --git a/crates/fj-kernel/src/partial/objects/surface.rs b/crates/fj-kernel/src/partial/objects/surface.rs index 0c85241e2..d5f05fcfc 100644 --- a/crates/fj-kernel/src/partial/objects/surface.rs +++ b/crates/fj-kernel/src/partial/objects/surface.rs @@ -15,6 +15,10 @@ pub struct PartialSurface { impl PartialObject for PartialSurface { type Full = Surface; + fn new() -> Self { + Self::default() + } + fn from_full(surface: &Self::Full, _: &mut FullToPartialCache) -> Self { Self { geometry: Some(surface.geometry()), diff --git a/crates/fj-kernel/src/partial/objects/vertex.rs b/crates/fj-kernel/src/partial/objects/vertex.rs index fc6be85ec..2ecb8a0a9 100644 --- a/crates/fj-kernel/src/partial/objects/vertex.rs +++ b/crates/fj-kernel/src/partial/objects/vertex.rs @@ -16,6 +16,10 @@ pub struct PartialVertex { impl PartialObject for PartialVertex { type Full = Vertex; + fn new() -> Self { + Self::default() + } + fn from_full( global_vertex: &Self::Full, _: &mut FullToPartialCache, diff --git a/crates/fj-kernel/src/partial/traits.rs b/crates/fj-kernel/src/partial/traits.rs index 089b2eb82..d5972a46b 100644 --- a/crates/fj-kernel/src/partial/traits.rs +++ b/crates/fj-kernel/src/partial/traits.rs @@ -15,6 +15,9 @@ pub trait PartialObject: Clone + Debug + Default { /// The type representing the full object type Full: HasPartial; + /// Construct a default partial object + fn new() -> Self; + /// Construct a partial object from a full one fn from_full(full: &Self::Full, cache: &mut FullToPartialCache) -> Self; From 33c1b5212795a2e3e6253fa0184357776262a968 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 12:42:00 +0100 Subject: [PATCH 02/37] Make use `PartialObject::new` --- crates/fj-kernel/src/partial/wrapper.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/partial/wrapper.rs b/crates/fj-kernel/src/partial/wrapper.rs index 5effa6bb3..857665b0c 100644 --- a/crates/fj-kernel/src/partial/wrapper.rs +++ b/crates/fj-kernel/src/partial/wrapper.rs @@ -30,7 +30,7 @@ pub struct Partial { impl Partial { /// Construct a `Partial` with a default inner partial object pub fn new() -> Self { - Self::from_partial(T::Partial::default()) + Self::from_partial(T::Partial::new()) } /// Construct a `Partial` from a partial object From 7a6a5ee04a68d98e495f410696c78b109a193b66 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 12:42:53 +0100 Subject: [PATCH 03/37] Remove unused trait bound --- crates/fj-kernel/src/partial/traits.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/partial/traits.rs b/crates/fj-kernel/src/partial/traits.rs index d5972a46b..02ed12a48 100644 --- a/crates/fj-kernel/src/partial/traits.rs +++ b/crates/fj-kernel/src/partial/traits.rs @@ -11,7 +11,7 @@ pub trait HasPartial { } /// Implemented for partial objects -pub trait PartialObject: Clone + Debug + Default { +pub trait PartialObject: Clone + Debug { /// The type representing the full object type Full: HasPartial; From 613f64dd8edc66b48dd5c107fd6ece215cec05dd Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 12:54:32 +0100 Subject: [PATCH 04/37] Replace uses of `PartialCycle::default` --- crates/fj-kernel/src/algorithms/approx/edge.rs | 6 +++--- .../fj-kernel/src/algorithms/intersect/curve_edge.rs | 10 +++++----- crates/fj-kernel/src/partial/objects/cycle.rs | 4 +++- crates/fj-kernel/src/validate/edge.rs | 4 ++-- crates/fj-operations/src/sketch.rs | 4 ++-- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/approx/edge.rs b/crates/fj-kernel/src/algorithms/approx/edge.rs index 53ec893dc..529fc9cf1 100644 --- a/crates/fj-kernel/src/algorithms/approx/edge.rs +++ b/crates/fj-kernel/src/algorithms/approx/edge.rs @@ -246,7 +246,7 @@ mod tests { let surface = services.objects.surfaces.xz_plane(); let half_edge = { - let mut cycle = PartialCycle::default(); + let mut cycle = PartialCycle::new(); let [mut half_edge, next_half_edge, _] = cycle .update_as_polygon_from_points([[1., 1.], [2., 1.], [1., 2.]]); @@ -278,7 +278,7 @@ mod tests { .build(&mut services.objects) .insert(&mut services.objects); let half_edge = { - let mut cycle = PartialCycle::default(); + let mut cycle = PartialCycle::new(); let [mut half_edge, next_half_edge, _] = cycle .update_as_polygon_from_points([[1., 1.], [2., 1.], [1., 2.]]); @@ -310,7 +310,7 @@ mod tests { .build(&mut services.objects) .insert(&mut services.objects); let half_edge = { - let mut cycle = PartialCycle::default(); + let mut cycle = PartialCycle::new(); let [mut half_edge, next_half_edge, _] = cycle .update_as_polygon_from_points([[0., 1.], [1., 1.], [1., 2.]]); diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs index ae5b67fd4..ca3dd628f 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs @@ -74,7 +74,7 @@ mod tests { use crate::{ builder::{CycleBuilder, HalfEdgeBuilder}, geometry::curve::Curve, - partial::PartialCycle, + partial::{PartialCycle, PartialObject}, services::Services, }; @@ -87,7 +87,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let curve = Curve::u_axis(); let half_edge = { - let mut cycle = PartialCycle::default(); + let mut cycle = PartialCycle::new(); let [mut half_edge, next_half_edge, _] = cycle .update_as_polygon_from_points([[1., -1.], [1., 1.], [0., 1.]]); @@ -116,7 +116,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let curve = Curve::u_axis(); let half_edge = { - let mut cycle = PartialCycle::default(); + let mut cycle = PartialCycle::new(); let [mut half_edge, next_half_edge, _] = cycle .update_as_polygon_from_points([ @@ -149,7 +149,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let curve = Curve::u_axis(); let half_edge = { - let mut cycle = PartialCycle::default(); + let mut cycle = PartialCycle::new(); let [mut half_edge, next_half_edge, _] = cycle .update_as_polygon_from_points([ @@ -177,7 +177,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let curve = Curve::u_axis(); let half_edge = { - let mut cycle = PartialCycle::default(); + let mut cycle = PartialCycle::new(); let [mut half_edge, next_half_edge, _] = cycle .update_as_polygon_from_points([[-1., 0.], [1., 0.], [1., 1.]]); diff --git a/crates/fj-kernel/src/partial/objects/cycle.rs b/crates/fj-kernel/src/partial/objects/cycle.rs index dcdf62b5a..d67d27d19 100644 --- a/crates/fj-kernel/src/partial/objects/cycle.rs +++ b/crates/fj-kernel/src/partial/objects/cycle.rs @@ -15,7 +15,9 @@ impl PartialObject for PartialCycle { type Full = Cycle; fn new() -> Self { - Self::default() + Self { + half_edges: Vec::new(), + } } fn from_full(cycle: &Self::Full, cache: &mut FullToPartialCache) -> Self { diff --git a/crates/fj-kernel/src/validate/edge.rs b/crates/fj-kernel/src/validate/edge.rs index bacc0fd61..4b93a0420 100644 --- a/crates/fj-kernel/src/validate/edge.rs +++ b/crates/fj-kernel/src/validate/edge.rs @@ -78,7 +78,7 @@ mod tests { use crate::{ builder::{CycleBuilder, HalfEdgeBuilder}, objects::HalfEdge, - partial::PartialCycle, + partial::{PartialCycle, PartialObject}, services::Services, validate::{HalfEdgeValidationError, Validate, ValidationError}, }; @@ -90,7 +90,7 @@ mod tests { let valid = { let surface = services.objects.surfaces.xy_plane(); - let mut cycle = PartialCycle::default(); + let mut cycle = PartialCycle::new(); let [mut half_edge, next_half_edge, _] = cycle .update_as_polygon_from_points([[0., 0.], [1., 0.], [1., 1.]]); diff --git a/crates/fj-operations/src/sketch.rs b/crates/fj-operations/src/sketch.rs index 667cda4e1..46fd6d79e 100644 --- a/crates/fj-operations/src/sketch.rs +++ b/crates/fj-operations/src/sketch.rs @@ -37,7 +37,7 @@ impl Shape for fj::Sketch { Partial::from_partial(half_edge) }; let exterior = { - let mut cycle = PartialCycle::default(); + let mut cycle = PartialCycle::new(); cycle.half_edges.push(half_edge); Partial::from_partial(cycle) }; @@ -57,7 +57,7 @@ impl Shape for fj::Sketch { ); let exterior = { - let mut cycle = PartialCycle::default(); + let mut cycle = PartialCycle::new(); let half_edges = poly_chain .to_segments() From e2725c68e98f9c2ff1924e8ee1fe2e2a49faa7a6 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 12:55:22 +0100 Subject: [PATCH 05/37] Un-derive `Default` from `PartialCycle` --- crates/fj-kernel/src/partial/objects/cycle.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/partial/objects/cycle.rs b/crates/fj-kernel/src/partial/objects/cycle.rs index d67d27d19..5218c3148 100644 --- a/crates/fj-kernel/src/partial/objects/cycle.rs +++ b/crates/fj-kernel/src/partial/objects/cycle.rs @@ -5,7 +5,7 @@ use crate::{ }; /// A partial [`Cycle`] -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug)] pub struct PartialCycle { /// The half-edges that make up the cycle pub half_edges: Vec>, From ad6561d0b8ad481715cec75a4ddcfe13f927e9b3 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 12:56:12 +0100 Subject: [PATCH 06/37] Move `PartialHalfEdge` construction code to `new` --- crates/fj-kernel/src/partial/objects/edge.rs | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index 8622fabdc..be6e32040 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -46,7 +46,16 @@ impl PartialObject for PartialHalfEdge { type Full = HalfEdge; fn new() -> Self { - Self::default() + let curve = None; + let start_vertex = Partial::default(); + let global_form = Partial::default(); + + Self { + curve, + boundary: [None; 2], + start_vertex, + global_form, + } } fn from_full( @@ -88,16 +97,7 @@ impl PartialObject for PartialHalfEdge { impl Default for PartialHalfEdge { fn default() -> Self { - let curve = None; - let start_vertex = Partial::default(); - let global_form = Partial::default(); - - Self { - curve, - boundary: [None; 2], - start_vertex, - global_form, - } + Self::new() } } From f8e8f80d0bda32f4dd6e6cc67e687defb867e355 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 12:57:22 +0100 Subject: [PATCH 07/37] Replace uses of `PartialHalfEdge::default` --- crates/fj-kernel/src/algorithms/approx/edge.rs | 2 +- crates/fj-operations/src/sketch.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/approx/edge.rs b/crates/fj-kernel/src/algorithms/approx/edge.rs index 529fc9cf1..de4cede6a 100644 --- a/crates/fj-kernel/src/algorithms/approx/edge.rs +++ b/crates/fj-kernel/src/algorithms/approx/edge.rs @@ -352,7 +352,7 @@ mod tests { let surface = services.objects.surfaces.xz_plane(); let half_edge = { - let mut half_edge = PartialHalfEdge::default(); + let mut half_edge = PartialHalfEdge::new(); half_edge.update_as_circle_from_radius(1.); let next_vertex = half_edge.start_vertex.clone(); diff --git a/crates/fj-operations/src/sketch.rs b/crates/fj-operations/src/sketch.rs index 46fd6d79e..406745245 100644 --- a/crates/fj-operations/src/sketch.rs +++ b/crates/fj-operations/src/sketch.rs @@ -31,7 +31,7 @@ impl Shape for fj::Sketch { let surface = Partial::from(surface); let half_edge = { - let mut half_edge = PartialHalfEdge::default(); + let mut half_edge = PartialHalfEdge::new(); half_edge.update_as_circle_from_radius(circle.radius()); Partial::from_partial(half_edge) From 8e18d59cd17329a7bff0540bdc0b426cff5278f8 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 12:58:09 +0100 Subject: [PATCH 08/37] Remove `Default` impl of `PartialHalfEdge` --- crates/fj-kernel/src/partial/objects/edge.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index be6e32040..4b743f6fe 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -95,12 +95,6 @@ impl PartialObject for PartialHalfEdge { } } -impl Default for PartialHalfEdge { - fn default() -> Self { - Self::new() - } -} - /// A partial [`GlobalEdge`] #[derive(Clone, Debug, Default)] pub struct PartialGlobalEdge {} From 01a2b60d78ee25ae9b88149782cc625a582fdc71 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 12:59:30 +0100 Subject: [PATCH 09/37] Simplify `PartialGlobalEdge` constructor --- crates/fj-kernel/src/partial/objects/edge.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index 4b743f6fe..d7546871a 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -103,7 +103,7 @@ impl PartialObject for PartialGlobalEdge { type Full = GlobalEdge; fn new() -> Self { - Self::default() + Self {} } fn from_full(_: &Self::Full, _: &mut FullToPartialCache) -> Self { From 13a36c181c1de1500ea9e0e0c67b7adceb41291f Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 13:00:01 +0100 Subject: [PATCH 10/37] Un-derive `Default` from `PartialGlobalEdge` --- crates/fj-kernel/src/partial/objects/edge.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index d7546871a..09ab3319d 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -96,7 +96,7 @@ impl PartialObject for PartialHalfEdge { } /// A partial [`GlobalEdge`] -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug)] pub struct PartialGlobalEdge {} impl PartialObject for PartialGlobalEdge { From 591c1a6801f48e45da35f4c285f733b582254fea Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 13:03:27 +0100 Subject: [PATCH 11/37] Avoid using `Default` impl of `PartialFace` --- .../src/algorithms/intersect/curve_face.rs | 2 +- .../src/algorithms/intersect/face_face.rs | 4 ++-- .../src/algorithms/intersect/face_point.rs | 16 ++++++++-------- .../src/algorithms/intersect/ray_face.rs | 14 +++++++------- crates/fj-kernel/src/algorithms/sweep/edge.rs | 2 +- crates/fj-kernel/src/algorithms/sweep/face.rs | 2 +- .../fj-kernel/src/algorithms/triangulate/mod.rs | 6 +++--- crates/fj-kernel/src/partial/objects/face.rs | 7 ++++++- crates/fj-kernel/src/validate/face.rs | 4 ++-- crates/fj-operations/src/sketch.rs | 4 ++-- 10 files changed, 33 insertions(+), 28 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index 61020a75a..42622f711 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -182,7 +182,7 @@ mod tests { let face = { let mut face = PartialFace { surface: Partial::from(services.objects.surfaces.xy_plane()), - ..Default::default() + ..PartialFace::new() }; face.exterior .write() diff --git a/crates/fj-kernel/src/algorithms/intersect/face_face.rs b/crates/fj-kernel/src/algorithms/intersect/face_face.rs index 8ef66f4c5..e2c9b2ade 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_face.rs @@ -88,7 +88,7 @@ mod tests { .map(|surface| { let mut face = PartialFace { surface: Partial::from(surface), - ..Default::default() + ..PartialFace::new() }; face.exterior.write().update_as_polygon_from_points(points); @@ -118,7 +118,7 @@ mod tests { let [a, b] = surfaces.clone().map(|surface| { let mut face = PartialFace { surface: Partial::from(surface), - ..Default::default() + ..PartialFace::new() }; face.exterior.write().update_as_polygon_from_points(points); diff --git a/crates/fj-kernel/src/algorithms/intersect/face_point.rs b/crates/fj-kernel/src/algorithms/intersect/face_point.rs index fe3df1800..0042c74d9 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_point.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_point.rs @@ -150,7 +150,7 @@ mod tests { let mut face = PartialFace { surface: Partial::from(services.objects.surfaces.xy_plane()), - ..Default::default() + ..PartialFace::new() }; face.exterior.write().update_as_polygon_from_points([ [0., 0.], @@ -172,7 +172,7 @@ mod tests { let mut face = PartialFace { surface: Partial::from(services.objects.surfaces.xy_plane()), - ..Default::default() + ..PartialFace::new() }; face.exterior.write().update_as_polygon_from_points([ [0., 0.], @@ -197,7 +197,7 @@ mod tests { let mut face = PartialFace { surface: Partial::from(services.objects.surfaces.xy_plane()), - ..Default::default() + ..PartialFace::new() }; face.exterior.write().update_as_polygon_from_points([ [4., 2.], @@ -222,7 +222,7 @@ mod tests { let mut face = PartialFace { surface: Partial::from(services.objects.surfaces.xy_plane()), - ..Default::default() + ..PartialFace::new() }; face.exterior.write().update_as_polygon_from_points([ [0., 0.], @@ -248,7 +248,7 @@ mod tests { let mut face = PartialFace { surface: Partial::from(services.objects.surfaces.xy_plane()), - ..Default::default() + ..PartialFace::new() }; face.exterior.write().update_as_polygon_from_points([ [0., 0.], @@ -274,7 +274,7 @@ mod tests { let mut face = PartialFace { surface: Partial::from(services.objects.surfaces.xy_plane()), - ..Default::default() + ..PartialFace::new() }; face.exterior.write().update_as_polygon_from_points([ [0., 0.], @@ -301,7 +301,7 @@ mod tests { let mut face = PartialFace { surface: Partial::from(services.objects.surfaces.xy_plane()), - ..Default::default() + ..PartialFace::new() }; face.exterior.write().update_as_polygon_from_points([ [0., 0.], @@ -332,7 +332,7 @@ mod tests { let mut face = PartialFace { surface: Partial::from(services.objects.surfaces.xy_plane()), - ..Default::default() + ..PartialFace::new() }; face.exterior.write().update_as_polygon_from_points([ [0., 0.], diff --git a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs index d0d9caa0c..0cf0881fd 100644 --- a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs @@ -165,7 +165,7 @@ mod tests { let mut face = PartialFace { surface: Partial::from(services.objects.surfaces.yz_plane()), - ..Default::default() + ..PartialFace::new() }; face.exterior.write().update_as_polygon_from_points([ [-1., -1.], @@ -189,7 +189,7 @@ mod tests { let mut face = PartialFace { surface: Partial::from(services.objects.surfaces.yz_plane()), - ..Default::default() + ..PartialFace::new() }; face.exterior.write().update_as_polygon_from_points([ [-1., -1.], @@ -216,7 +216,7 @@ mod tests { let mut face = PartialFace { surface: Partial::from(services.objects.surfaces.yz_plane()), - ..Default::default() + ..PartialFace::new() }; face.exterior.write().update_as_polygon_from_points([ [-1., -1.], @@ -240,7 +240,7 @@ mod tests { let mut face = PartialFace { surface: Partial::from(services.objects.surfaces.yz_plane()), - ..Default::default() + ..PartialFace::new() }; face.exterior.write().update_as_polygon_from_points([ [-1., -1.], @@ -272,7 +272,7 @@ mod tests { let mut face = PartialFace { surface: Partial::from(services.objects.surfaces.yz_plane()), - ..Default::default() + ..PartialFace::new() }; face.exterior.write().update_as_polygon_from_points([ [-1., -1.], @@ -307,7 +307,7 @@ mod tests { let mut face = PartialFace { surface: Partial::from(services.objects.surfaces.xy_plane()), - ..Default::default() + ..PartialFace::new() }; face.exterior.write().update_as_polygon_from_points([ [-1., -1.], @@ -333,7 +333,7 @@ mod tests { let mut face = PartialFace { surface: Partial::from(services.objects.surfaces.xy_plane()), - ..Default::default() + ..PartialFace::new() }; face.exterior.write().update_as_polygon_from_points([ [-1., -1.], diff --git a/crates/fj-kernel/src/algorithms/sweep/edge.rs b/crates/fj-kernel/src/algorithms/sweep/edge.rs index 944e8544b..0feb2ebb0 100644 --- a/crates/fj-kernel/src/algorithms/sweep/edge.rs +++ b/crates/fj-kernel/src/algorithms/sweep/edge.rs @@ -28,7 +28,7 @@ impl Sweep for (Handle, &Handle, &Surface, Color) { // The result of sweeping an edge is a face. Let's create that. let mut face = PartialFace { color: Some(color), - ..Default::default() + ..PartialFace::new() }; // A face (and everything in it) is defined on a surface. A surface can diff --git a/crates/fj-kernel/src/algorithms/sweep/face.rs b/crates/fj-kernel/src/algorithms/sweep/face.rs index c0373826a..368b409b5 100644 --- a/crates/fj-kernel/src/algorithms/sweep/face.rs +++ b/crates/fj-kernel/src/algorithms/sweep/face.rs @@ -59,7 +59,7 @@ impl Sweep for Handle { let mut top_face = PartialFace { surface: Partial::from(top_surface.clone()), color: Some(self.color()), - ..PartialFace::default() + ..PartialFace::new() }; for (i, cycle) in bottom_face.all_cycles().cloned().enumerate() { diff --git a/crates/fj-kernel/src/algorithms/triangulate/mod.rs b/crates/fj-kernel/src/algorithms/triangulate/mod.rs index c57d73be9..aaf472ec8 100644 --- a/crates/fj-kernel/src/algorithms/triangulate/mod.rs +++ b/crates/fj-kernel/src/algorithms/triangulate/mod.rs @@ -98,7 +98,7 @@ mod tests { let mut face = PartialFace { surface: Partial::from(services.objects.surfaces.xy_plane()), - ..Default::default() + ..PartialFace::new() }; face.exterior .write() @@ -139,7 +139,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace { surface: Partial::from(surface.clone()), - ..Default::default() + ..PartialFace::new() }; face.exterior .write() @@ -205,7 +205,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace { surface: Partial::from(surface.clone()), - ..Default::default() + ..PartialFace::new() }; face.exterior .write() diff --git a/crates/fj-kernel/src/partial/objects/face.rs b/crates/fj-kernel/src/partial/objects/face.rs index d708afbfc..b7530daff 100644 --- a/crates/fj-kernel/src/partial/objects/face.rs +++ b/crates/fj-kernel/src/partial/objects/face.rs @@ -29,7 +29,12 @@ impl PartialObject for PartialFace { type Full = Face; fn new() -> Self { - Self::default() + Self { + surface: Partial::new(), + exterior: Partial::new(), + interiors: Vec::new(), + color: None, + } } fn from_full(face: &Self::Full, cache: &mut FullToPartialCache) -> Self { diff --git a/crates/fj-kernel/src/validate/face.rs b/crates/fj-kernel/src/validate/face.rs index 41766b656..126c8a142 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -153,7 +153,7 @@ mod tests { let valid = { let mut face = PartialFace { surface: Partial::from(services.objects.surfaces.xy_plane()), - ..Default::default() + ..PartialFace::new() }; face.exterior.write().update_as_polygon_from_points([ [0., 0.], @@ -202,7 +202,7 @@ mod tests { let mut face = PartialFace { surface: Partial::from(surface.clone()), - ..Default::default() + ..PartialFace::new() }; let mut half_edge = face.exterior.write().add_half_edge(); diff --git a/crates/fj-operations/src/sketch.rs b/crates/fj-operations/src/sketch.rs index 406745245..6d6abca20 100644 --- a/crates/fj-operations/src/sketch.rs +++ b/crates/fj-operations/src/sketch.rs @@ -46,7 +46,7 @@ impl Shape for fj::Sketch { surface, exterior, color: Some(Color(self.color())), - ..Default::default() + ..PartialFace::new() } } fj::Chain::PolyChain(poly_chain) => { @@ -95,7 +95,7 @@ impl Shape for fj::Sketch { surface: Partial::from(surface), exterior, color: Some(Color(self.color())), - ..Default::default() + ..PartialFace::new() } } }; From 969a3966b3413f66e169d9a4d56e110d0301f6de Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 13:04:12 +0100 Subject: [PATCH 12/37] Un-derive `Default` from `PartialFace` --- crates/fj-kernel/src/partial/objects/face.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/partial/objects/face.rs b/crates/fj-kernel/src/partial/objects/face.rs index b7530daff..61810f8b1 100644 --- a/crates/fj-kernel/src/partial/objects/face.rs +++ b/crates/fj-kernel/src/partial/objects/face.rs @@ -8,7 +8,7 @@ use crate::{ }; /// A partial [`Face`] -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug)] pub struct PartialFace { /// The surface that the face is defined in pub surface: Partial, From 2792bddeec536ec5f936bac91cc43e6e387e563f Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 13:05:08 +0100 Subject: [PATCH 13/37] Avoid using `Default` impl of `PartialShell` --- crates/fj-kernel/src/partial/objects/shell.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/partial/objects/shell.rs b/crates/fj-kernel/src/partial/objects/shell.rs index c661bbcb8..d8269d4ea 100644 --- a/crates/fj-kernel/src/partial/objects/shell.rs +++ b/crates/fj-kernel/src/partial/objects/shell.rs @@ -15,7 +15,7 @@ impl PartialObject for PartialShell { type Full = Shell; fn new() -> Self { - Self::default() + Self { faces: Vec::new() } } fn from_full(shell: &Self::Full, cache: &mut FullToPartialCache) -> Self { From 933f55927fc569777f2116fca413580ca3517955 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 13:06:30 +0100 Subject: [PATCH 14/37] Un-derive `Default` from `PartialShell` --- crates/fj-kernel/src/partial/objects/shell.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/partial/objects/shell.rs b/crates/fj-kernel/src/partial/objects/shell.rs index d8269d4ea..d19e75651 100644 --- a/crates/fj-kernel/src/partial/objects/shell.rs +++ b/crates/fj-kernel/src/partial/objects/shell.rs @@ -5,7 +5,7 @@ use crate::{ }; /// A partial [`Shell`] -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug)] pub struct PartialShell { /// The faces that make up the shell pub faces: Vec>, From d433261b90cc22e1d4cfd0727bd4388ece3abcf4 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 13:07:39 +0100 Subject: [PATCH 15/37] Avoid using `Default` impl of `PartialSketch` --- crates/fj-kernel/src/partial/objects/sketch.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/partial/objects/sketch.rs b/crates/fj-kernel/src/partial/objects/sketch.rs index 66fd75cdc..5adce5547 100644 --- a/crates/fj-kernel/src/partial/objects/sketch.rs +++ b/crates/fj-kernel/src/partial/objects/sketch.rs @@ -15,7 +15,7 @@ impl PartialObject for PartialSketch { type Full = Sketch; fn new() -> Self { - Self::default() + Self { faces: Vec::new() } } fn from_full(sketch: &Self::Full, cache: &mut FullToPartialCache) -> Self { From 1e349d60c0cfef6fcb4cf4854ca752fe76a37c73 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 13:08:11 +0100 Subject: [PATCH 16/37] Un-derive `Default` from `PartialSketch` --- crates/fj-kernel/src/partial/objects/sketch.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/partial/objects/sketch.rs b/crates/fj-kernel/src/partial/objects/sketch.rs index 5adce5547..78324a68d 100644 --- a/crates/fj-kernel/src/partial/objects/sketch.rs +++ b/crates/fj-kernel/src/partial/objects/sketch.rs @@ -5,7 +5,7 @@ use crate::{ }; /// A partial [`Sketch`] -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug)] pub struct PartialSketch { /// The faces that make up the sketch pub faces: Vec>, From 78d8b3c0e1212c9634704b04c46af6defa1940a8 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 13:09:12 +0100 Subject: [PATCH 17/37] Avoid using `Default` impl of `PartialSolid` --- crates/fj-kernel/src/partial/objects/solid.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/partial/objects/solid.rs b/crates/fj-kernel/src/partial/objects/solid.rs index 33c9017d5..e3cfb3f56 100644 --- a/crates/fj-kernel/src/partial/objects/solid.rs +++ b/crates/fj-kernel/src/partial/objects/solid.rs @@ -15,7 +15,7 @@ impl PartialObject for PartialSolid { type Full = Solid; fn new() -> Self { - Self::default() + Self { shells: Vec::new() } } fn from_full(solid: &Self::Full, cache: &mut FullToPartialCache) -> Self { From 793af9c70c33e41c619da641624cd34eeaef9b62 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 13:09:49 +0100 Subject: [PATCH 18/37] Un-derive `Default` from `PartialSolid` --- crates/fj-kernel/src/partial/objects/solid.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/partial/objects/solid.rs b/crates/fj-kernel/src/partial/objects/solid.rs index e3cfb3f56..a3e71c8d2 100644 --- a/crates/fj-kernel/src/partial/objects/solid.rs +++ b/crates/fj-kernel/src/partial/objects/solid.rs @@ -5,7 +5,7 @@ use crate::{ }; /// A partial [`Solid`] -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug)] pub struct PartialSolid { /// The shells that make up the solid pub shells: Vec>, From 7253b6cc06ec9c1cece3a86f76e198c42f64e492 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 13:10:51 +0100 Subject: [PATCH 19/37] Avoid using `Default` impl of `PartialSurface` --- crates/fj-kernel/src/partial/objects/surface.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/partial/objects/surface.rs b/crates/fj-kernel/src/partial/objects/surface.rs index d5f05fcfc..42db9904c 100644 --- a/crates/fj-kernel/src/partial/objects/surface.rs +++ b/crates/fj-kernel/src/partial/objects/surface.rs @@ -16,7 +16,7 @@ impl PartialObject for PartialSurface { type Full = Surface; fn new() -> Self { - Self::default() + Self { geometry: None } } fn from_full(surface: &Self::Full, _: &mut FullToPartialCache) -> Self { From 25bac883f388bbd0503790c646cfc51c5a6e6d4c Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 13:11:27 +0100 Subject: [PATCH 20/37] Un-derive `Default` from `PartialSurface` --- crates/fj-kernel/src/partial/objects/surface.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/partial/objects/surface.rs b/crates/fj-kernel/src/partial/objects/surface.rs index 42db9904c..4784034c9 100644 --- a/crates/fj-kernel/src/partial/objects/surface.rs +++ b/crates/fj-kernel/src/partial/objects/surface.rs @@ -6,7 +6,7 @@ use crate::{ }; /// A partial [`Surface`] -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug)] pub struct PartialSurface { /// The surface's geometry pub geometry: Option, From 8a386d368e231353e3d4e305d947ed5dfbfff89c Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 13:12:34 +0100 Subject: [PATCH 21/37] Avoid using `Default` impl of `PartialVertex` --- crates/fj-kernel/src/partial/objects/vertex.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/partial/objects/vertex.rs b/crates/fj-kernel/src/partial/objects/vertex.rs index 2ecb8a0a9..9bbeee1c5 100644 --- a/crates/fj-kernel/src/partial/objects/vertex.rs +++ b/crates/fj-kernel/src/partial/objects/vertex.rs @@ -17,7 +17,7 @@ impl PartialObject for PartialVertex { type Full = Vertex; fn new() -> Self { - Self::default() + Self { position: None } } fn from_full( From 7651a63b9d6ba47467fd7b4b7616ec65f9e47bd6 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 13:13:43 +0100 Subject: [PATCH 22/37] Un-derive `Default` from `PartialVertex` --- crates/fj-kernel/src/partial/objects/vertex.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/partial/objects/vertex.rs b/crates/fj-kernel/src/partial/objects/vertex.rs index 9bbeee1c5..8263b9396 100644 --- a/crates/fj-kernel/src/partial/objects/vertex.rs +++ b/crates/fj-kernel/src/partial/objects/vertex.rs @@ -7,7 +7,7 @@ use crate::{ }; /// A partial [`Vertex`] -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug)] pub struct PartialVertex { /// The position of the vertex pub position: Option>, From 6c0c49166ca6be45cd5cd6d550d8fc17ced6fcb1 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 13:20:05 +0100 Subject: [PATCH 23/37] Avoid using `Default` impl of `Partial` --- crates/fj-kernel/src/partial/objects/edge.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index 09ab3319d..7837aaf79 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -47,8 +47,8 @@ impl PartialObject for PartialHalfEdge { fn new() -> Self { let curve = None; - let start_vertex = Partial::default(); - let global_form = Partial::default(); + let start_vertex = Partial::new(); + let global_form = Partial::new(); Self { curve, From 66bb2f2312a3f0764a4f58fddfd8ad25c4917074 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 13:21:38 +0100 Subject: [PATCH 24/37] Remove `Default` implementation of `Partial` --- crates/fj-kernel/src/partial/wrapper.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/crates/fj-kernel/src/partial/wrapper.rs b/crates/fj-kernel/src/partial/wrapper.rs index 857665b0c..f895c2786 100644 --- a/crates/fj-kernel/src/partial/wrapper.rs +++ b/crates/fj-kernel/src/partial/wrapper.rs @@ -29,6 +29,7 @@ pub struct Partial { impl Partial { /// Construct a `Partial` with a default inner partial object + #[allow(clippy::new_without_default)] pub fn new() -> Self { Self::from_partial(T::Partial::new()) } @@ -142,12 +143,6 @@ impl Clone for Partial { } } -impl Default for Partial { - fn default() -> Self { - Self::new() - } -} - impl From> for Partial { fn from(full: Handle) -> Self { let mut cache = FullToPartialCache::default(); From 857c36f6feb7155898e8ae0965d2b2c5e7c7a4bb Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 13:25:50 +0100 Subject: [PATCH 25/37] Clean up `PartialFace` construction --- .../src/algorithms/intersect/curve_face.rs | 7 +-- .../src/algorithms/intersect/face_face.rs | 14 ++--- .../src/algorithms/intersect/face_point.rs | 56 ++++++++----------- .../src/algorithms/intersect/ray_face.rs | 49 +++++++--------- crates/fj-kernel/src/algorithms/sweep/edge.rs | 6 +- crates/fj-kernel/src/algorithms/sweep/face.rs | 9 ++- .../src/algorithms/triangulate/mod.rs | 20 +++---- crates/fj-kernel/src/validate/face.rs | 13 ++--- 8 files changed, 73 insertions(+), 101 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index 42622f711..88b647ca3 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -180,10 +180,9 @@ mod tests { ]; let face = { - let mut face = PartialFace { - surface: Partial::from(services.objects.surfaces.xy_plane()), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + + face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior .write() .update_as_polygon_from_points(exterior); diff --git a/crates/fj-kernel/src/algorithms/intersect/face_face.rs b/crates/fj-kernel/src/algorithms/intersect/face_face.rs index e2c9b2ade..04b69358e 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_face.rs @@ -86,10 +86,9 @@ mod tests { services.objects.surfaces.xz_plane(), ] .map(|surface| { - let mut face = PartialFace { - surface: Partial::from(surface), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + + face.surface = Partial::from(surface); face.exterior.write().update_as_polygon_from_points(points); face.build(&mut services.objects) @@ -116,10 +115,9 @@ mod tests { services.objects.surfaces.xz_plane(), ]; let [a, b] = surfaces.clone().map(|surface| { - let mut face = PartialFace { - surface: Partial::from(surface), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + + face.surface = Partial::from(surface); face.exterior.write().update_as_polygon_from_points(points); face.build(&mut services.objects) diff --git a/crates/fj-kernel/src/algorithms/intersect/face_point.rs b/crates/fj-kernel/src/algorithms/intersect/face_point.rs index 0042c74d9..9ef539ed8 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_point.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_point.rs @@ -148,10 +148,9 @@ mod tests { fn point_is_outside_face() { let mut services = Services::new(); - let mut face = PartialFace { - surface: Partial::from(services.objects.surfaces.xy_plane()), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + + face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points([ [0., 0.], [1., 1.], @@ -170,10 +169,9 @@ mod tests { fn ray_hits_vertex_while_passing_outside() { let mut services = Services::new(); - let mut face = PartialFace { - surface: Partial::from(services.objects.surfaces.xy_plane()), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + + face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points([ [0., 0.], [2., 1.], @@ -195,10 +193,9 @@ mod tests { fn ray_hits_vertex_at_cycle_seam() { let mut services = Services::new(); - let mut face = PartialFace { - surface: Partial::from(services.objects.surfaces.xy_plane()), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + + face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points([ [4., 2.], [0., 4.], @@ -220,10 +217,9 @@ mod tests { fn ray_hits_vertex_while_staying_inside() { let mut services = Services::new(); - let mut face = PartialFace { - surface: Partial::from(services.objects.surfaces.xy_plane()), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + + face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points([ [0., 0.], [2., 1.], @@ -246,10 +242,9 @@ mod tests { fn ray_hits_parallel_edge_and_leaves_face_at_vertex() { let mut services = Services::new(); - let mut face = PartialFace { - surface: Partial::from(services.objects.surfaces.xy_plane()), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + + face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points([ [0., 0.], [2., 1.], @@ -272,10 +267,9 @@ mod tests { fn ray_hits_parallel_edge_and_does_not_leave_face_there() { let mut services = Services::new(); - let mut face = PartialFace { - surface: Partial::from(services.objects.surfaces.xy_plane()), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + + face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points([ [0., 0.], [2., 1.], @@ -299,10 +293,9 @@ mod tests { fn point_is_coincident_with_edge() { let mut services = Services::new(); - let mut face = PartialFace { - surface: Partial::from(services.objects.surfaces.xy_plane()), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + + face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points([ [0., 0.], [2., 0.], @@ -330,10 +323,9 @@ mod tests { fn point_is_coincident_with_vertex() { let mut services = Services::new(); - let mut face = PartialFace { - surface: Partial::from(services.objects.surfaces.xy_plane()), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + + face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points([ [0., 0.], [1., 0.], diff --git a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs index 0cf0881fd..989a1330b 100644 --- a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs @@ -163,10 +163,9 @@ mod tests { let ray = HorizontalRayToTheRight::from([0., 0., 0.]); - let mut face = PartialFace { - surface: Partial::from(services.objects.surfaces.yz_plane()), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + + face.surface = Partial::from(services.objects.surfaces.yz_plane()); face.exterior.write().update_as_polygon_from_points([ [-1., -1.], [1., -1.], @@ -187,10 +186,9 @@ mod tests { let ray = HorizontalRayToTheRight::from([0., 0., 0.]); - let mut face = PartialFace { - surface: Partial::from(services.objects.surfaces.yz_plane()), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + + face.surface = Partial::from(services.objects.surfaces.yz_plane()); face.exterior.write().update_as_polygon_from_points([ [-1., -1.], [1., -1.], @@ -214,10 +212,9 @@ mod tests { let ray = HorizontalRayToTheRight::from([0., 0., 0.]); - let mut face = PartialFace { - surface: Partial::from(services.objects.surfaces.yz_plane()), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + + face.surface = Partial::from(services.objects.surfaces.yz_plane()); face.exterior.write().update_as_polygon_from_points([ [-1., -1.], [1., -1.], @@ -238,10 +235,9 @@ mod tests { let ray = HorizontalRayToTheRight::from([0., 0., 0.]); - let mut face = PartialFace { - surface: Partial::from(services.objects.surfaces.yz_plane()), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + + face.surface = Partial::from(services.objects.surfaces.yz_plane()); face.exterior.write().update_as_polygon_from_points([ [-1., -1.], [1., -1.], @@ -270,10 +266,9 @@ mod tests { let ray = HorizontalRayToTheRight::from([0., 0., 0.]); - let mut face = PartialFace { - surface: Partial::from(services.objects.surfaces.yz_plane()), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + + face.surface = Partial::from(services.objects.surfaces.yz_plane()); face.exterior.write().update_as_polygon_from_points([ [-1., -1.], [1., -1.], @@ -305,10 +300,9 @@ mod tests { let ray = HorizontalRayToTheRight::from([0., 0., 0.]); - let mut face = PartialFace { - surface: Partial::from(services.objects.surfaces.xy_plane()), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + + face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points([ [-1., -1.], [1., -1.], @@ -331,10 +325,9 @@ mod tests { let ray = HorizontalRayToTheRight::from([0., 0., 0.]); - let mut face = PartialFace { - surface: Partial::from(services.objects.surfaces.xy_plane()), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + + face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points([ [-1., -1.], [1., -1.], diff --git a/crates/fj-kernel/src/algorithms/sweep/edge.rs b/crates/fj-kernel/src/algorithms/sweep/edge.rs index 0feb2ebb0..aa983e229 100644 --- a/crates/fj-kernel/src/algorithms/sweep/edge.rs +++ b/crates/fj-kernel/src/algorithms/sweep/edge.rs @@ -26,10 +26,8 @@ impl Sweep for (Handle, &Handle, &Surface, Color) { let path = path.into(); // The result of sweeping an edge is a face. Let's create that. - let mut face = PartialFace { - color: Some(color), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + face.color = Some(color); // A face (and everything in it) is defined on a surface. A surface can // be created by sweeping a curve, so let's sweep the curve of the edge diff --git a/crates/fj-kernel/src/algorithms/sweep/face.rs b/crates/fj-kernel/src/algorithms/sweep/face.rs index 368b409b5..4336784b8 100644 --- a/crates/fj-kernel/src/algorithms/sweep/face.rs +++ b/crates/fj-kernel/src/algorithms/sweep/face.rs @@ -56,11 +56,10 @@ impl Sweep for Handle { let top_surface = bottom_face.surface().clone().translate(path, objects); - let mut top_face = PartialFace { - surface: Partial::from(top_surface.clone()), - color: Some(self.color()), - ..PartialFace::new() - }; + + let mut top_face = PartialFace::new(); + top_face.surface = Partial::from(top_surface.clone()); + top_face.color = Some(self.color()); for (i, cycle) in bottom_face.all_cycles().cloned().enumerate() { let cycle = cycle.reverse(objects); diff --git a/crates/fj-kernel/src/algorithms/triangulate/mod.rs b/crates/fj-kernel/src/algorithms/triangulate/mod.rs index aaf472ec8..35376dc0a 100644 --- a/crates/fj-kernel/src/algorithms/triangulate/mod.rs +++ b/crates/fj-kernel/src/algorithms/triangulate/mod.rs @@ -96,10 +96,8 @@ mod tests { let c = [2., 2.]; let d = [0., 1.]; - let mut face = PartialFace { - surface: Partial::from(services.objects.surfaces.xy_plane()), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior .write() .update_as_polygon_from_points([a, b, c, d]); @@ -137,10 +135,9 @@ mod tests { let h = [3., 1.]; let surface = services.objects.surfaces.xy_plane(); - let mut face = PartialFace { - surface: Partial::from(surface.clone()), - ..PartialFace::new() - }; + + let mut face = PartialFace::new(); + face.surface = Partial::from(surface.clone()); face.exterior .write() .update_as_polygon_from_points([a, b, c, d]); @@ -203,10 +200,9 @@ mod tests { let e = [0., 9.]; let surface = services.objects.surfaces.xy_plane(); - let mut face = PartialFace { - surface: Partial::from(surface.clone()), - ..PartialFace::new() - }; + + let mut face = PartialFace::new(); + face.surface = Partial::from(surface.clone()); face.exterior .write() .update_as_polygon_from_points([a, b, c, d, e]); diff --git a/crates/fj-kernel/src/validate/face.rs b/crates/fj-kernel/src/validate/face.rs index 126c8a142..496404776 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -151,10 +151,9 @@ mod tests { let mut services = Services::new(); let valid = { - let mut face = PartialFace { - surface: Partial::from(services.objects.surfaces.xy_plane()), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + + face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points([ [0., 0.], [3., 0.], @@ -200,10 +199,8 @@ mod tests { let valid = { let surface = services.objects.surfaces.xy_plane(); - let mut face = PartialFace { - surface: Partial::from(surface.clone()), - ..PartialFace::new() - }; + let mut face = PartialFace::new(); + face.surface = Partial::from(surface.clone()); let mut half_edge = face.exterior.write().add_half_edge(); half_edge.write().update_as_circle_from_radius(1.); From 30da534c5cb1a2027ffd4bd3393b1a70bb011ebc Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 13:43:19 +0100 Subject: [PATCH 26/37] Make object service available in builder method It's going to be needed there soon. --- .../fj-kernel/src/algorithms/intersect/curve_face.rs | 2 +- crates/fj-kernel/src/algorithms/sweep/face.rs | 2 +- crates/fj-kernel/src/algorithms/triangulate/mod.rs | 2 +- crates/fj-kernel/src/builder/face.rs | 10 +++++++--- crates/fj-kernel/src/validate/face.rs | 8 +++----- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index 88b647ca3..df0d20e12 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -186,7 +186,7 @@ mod tests { face.exterior .write() .update_as_polygon_from_points(exterior); - face.add_interior() + face.add_interior(&mut services.objects) .write() .update_as_polygon_from_points(interior); diff --git a/crates/fj-kernel/src/algorithms/sweep/face.rs b/crates/fj-kernel/src/algorithms/sweep/face.rs index 4336784b8..69942b180 100644 --- a/crates/fj-kernel/src/algorithms/sweep/face.rs +++ b/crates/fj-kernel/src/algorithms/sweep/face.rs @@ -67,7 +67,7 @@ impl Sweep for Handle { let mut top_cycle = if i == 0 { top_face.exterior.clone() } else { - top_face.add_interior() + top_face.add_interior(objects) }; let mut original_edges = Vec::new(); diff --git a/crates/fj-kernel/src/algorithms/triangulate/mod.rs b/crates/fj-kernel/src/algorithms/triangulate/mod.rs index 35376dc0a..2a84a13cd 100644 --- a/crates/fj-kernel/src/algorithms/triangulate/mod.rs +++ b/crates/fj-kernel/src/algorithms/triangulate/mod.rs @@ -141,7 +141,7 @@ mod tests { face.exterior .write() .update_as_polygon_from_points([a, b, c, d]); - face.add_interior() + face.add_interior(&mut services.objects) .write() .update_as_polygon_from_points([e, f, g, h]); let face = face diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index 9dd4b5502..ac8a6ba47 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -1,16 +1,20 @@ use crate::{ - objects::Cycle, + objects::{Cycle, Objects}, partial::{Partial, PartialFace}, + services::Service, }; /// Builder API for [`PartialFace`] pub trait FaceBuilder { /// Add an interior cycle - fn add_interior(&mut self) -> Partial; + fn add_interior( + &mut self, + objects: &mut Service, + ) -> Partial; } impl FaceBuilder for PartialFace { - fn add_interior(&mut self) -> Partial { + fn add_interior(&mut self, _: &mut Service) -> Partial { let cycle = Partial::new(); 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 496404776..c7cf5c4c7 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -159,11 +159,9 @@ mod tests { [3., 0.], [0., 3.], ]); - face.add_interior().write().update_as_polygon_from_points([ - [1., 1.], - [1., 2.], - [2., 1.], - ]); + face.add_interior(&mut services.objects) + .write() + .update_as_polygon_from_points([[1., 1.], [1., 2.], [2., 1.]]); face.build(&mut services.objects) }; let invalid = { From ce9f27bba1fe2c5398a2882557bd20af15ed4bd5 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 13:43:19 +0100 Subject: [PATCH 27/37] Make object service available in builder method It's going to be needed there soon. --- .../fj-kernel/src/algorithms/approx/edge.rs | 15 +++- .../src/algorithms/intersect/curve_edge.rs | 28 ++++--- .../src/algorithms/intersect/curve_face.rs | 4 +- .../src/algorithms/intersect/face_face.rs | 8 +- .../src/algorithms/intersect/face_point.rs | 76 ++++++++----------- .../src/algorithms/intersect/ray_face.rs | 70 +++++++---------- .../src/algorithms/triangulate/mod.rs | 13 ++-- crates/fj-kernel/src/builder/cycle.rs | 5 +- crates/fj-kernel/src/validate/edge.rs | 5 +- crates/fj-kernel/src/validate/face.rs | 14 ++-- 10 files changed, 119 insertions(+), 119 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/approx/edge.rs b/crates/fj-kernel/src/algorithms/approx/edge.rs index de4cede6a..a4cce6500 100644 --- a/crates/fj-kernel/src/algorithms/approx/edge.rs +++ b/crates/fj-kernel/src/algorithms/approx/edge.rs @@ -249,7 +249,10 @@ mod tests { let mut cycle = PartialCycle::new(); let [mut half_edge, next_half_edge, _] = cycle - .update_as_polygon_from_points([[1., 1.], [2., 1.], [1., 2.]]); + .update_as_polygon_from_points( + [[1., 1.], [2., 1.], [1., 2.]], + &mut services.objects, + ); half_edge.write().infer_vertex_positions_if_necessary( &surface.geometry(), next_half_edge.read().start_vertex.clone(), @@ -281,7 +284,10 @@ mod tests { let mut cycle = PartialCycle::new(); let [mut half_edge, next_half_edge, _] = cycle - .update_as_polygon_from_points([[1., 1.], [2., 1.], [1., 2.]]); + .update_as_polygon_from_points( + [[1., 1.], [2., 1.], [1., 2.]], + &mut services.objects, + ); half_edge.write().infer_vertex_positions_if_necessary( &surface.geometry(), next_half_edge.read().start_vertex.clone(), @@ -313,7 +319,10 @@ mod tests { let mut cycle = PartialCycle::new(); let [mut half_edge, next_half_edge, _] = cycle - .update_as_polygon_from_points([[0., 1.], [1., 1.], [1., 2.]]); + .update_as_polygon_from_points( + [[0., 1.], [1., 1.], [1., 2.]], + &mut services.objects, + ); half_edge.write().boundary[0] = Some(range.boundary[0]); half_edge.write().boundary[1] = Some(range.boundary[1]); diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs index ca3dd628f..1c1e462de 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs @@ -90,7 +90,10 @@ mod tests { let mut cycle = PartialCycle::new(); let [mut half_edge, next_half_edge, _] = cycle - .update_as_polygon_from_points([[1., -1.], [1., 1.], [0., 1.]]); + .update_as_polygon_from_points( + [[1., -1.], [1., 1.], [0., 1.]], + &mut services.objects, + ); half_edge.write().infer_vertex_positions_if_necessary( &surface.geometry(), next_half_edge.read().start_vertex.clone(), @@ -119,11 +122,10 @@ mod tests { let mut cycle = PartialCycle::new(); let [mut half_edge, next_half_edge, _] = cycle - .update_as_polygon_from_points([ - [-1., -1.], - [-1., 1.], - [0., 1.], - ]); + .update_as_polygon_from_points( + [[-1., -1.], [-1., 1.], [0., 1.]], + &mut services.objects, + ); half_edge.write().infer_vertex_positions_if_necessary( &surface.geometry(), next_half_edge.read().start_vertex.clone(), @@ -152,11 +154,10 @@ mod tests { let mut cycle = PartialCycle::new(); let [mut half_edge, next_half_edge, _] = cycle - .update_as_polygon_from_points([ - [-1., -1.], - [1., -1.], - [1., 1.], - ]); + .update_as_polygon_from_points( + [[-1., -1.], [1., -1.], [1., 1.]], + &mut services.objects, + ); half_edge.write().infer_vertex_positions_if_necessary( &surface.geometry(), next_half_edge.read().start_vertex.clone(), @@ -180,7 +181,10 @@ mod tests { let mut cycle = PartialCycle::new(); let [mut half_edge, next_half_edge, _] = cycle - .update_as_polygon_from_points([[-1., 0.], [1., 0.], [1., 1.]]); + .update_as_polygon_from_points( + [[-1., 0.], [1., 0.], [1., 1.]], + &mut services.objects, + ); half_edge.write().infer_vertex_positions_if_necessary( &surface.geometry(), next_half_edge.read().start_vertex.clone(), diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index df0d20e12..40a6607b6 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -185,10 +185,10 @@ mod tests { face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior .write() - .update_as_polygon_from_points(exterior); + .update_as_polygon_from_points(exterior, &mut services.objects); face.add_interior(&mut services.objects) .write() - .update_as_polygon_from_points(interior); + .update_as_polygon_from_points(interior, &mut services.objects); face.build(&mut services.objects) }; diff --git a/crates/fj-kernel/src/algorithms/intersect/face_face.rs b/crates/fj-kernel/src/algorithms/intersect/face_face.rs index 04b69358e..f0c794225 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_face.rs @@ -89,7 +89,9 @@ mod tests { let mut face = PartialFace::new(); face.surface = Partial::from(surface); - face.exterior.write().update_as_polygon_from_points(points); + face.exterior + .write() + .update_as_polygon_from_points(points, &mut services.objects); face.build(&mut services.objects) }); @@ -118,7 +120,9 @@ mod tests { let mut face = PartialFace::new(); face.surface = Partial::from(surface); - face.exterior.write().update_as_polygon_from_points(points); + face.exterior + .write() + .update_as_polygon_from_points(points, &mut services.objects); face.build(&mut services.objects) }); diff --git a/crates/fj-kernel/src/algorithms/intersect/face_point.rs b/crates/fj-kernel/src/algorithms/intersect/face_point.rs index 9ef539ed8..e0471a047 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_point.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_point.rs @@ -151,11 +151,10 @@ mod tests { let mut face = PartialFace::new(); face.surface = Partial::from(services.objects.surfaces.xy_plane()); - face.exterior.write().update_as_polygon_from_points([ - [0., 0.], - [1., 1.], - [0., 2.], - ]); + face.exterior.write().update_as_polygon_from_points( + [[0., 0.], [1., 1.], [0., 2.]], + &mut services.objects, + ); let face = face .build(&mut services.objects) .insert(&mut services.objects); @@ -172,11 +171,10 @@ mod tests { let mut face = PartialFace::new(); face.surface = Partial::from(services.objects.surfaces.xy_plane()); - face.exterior.write().update_as_polygon_from_points([ - [0., 0.], - [2., 1.], - [0., 2.], - ]); + face.exterior.write().update_as_polygon_from_points( + [[0., 0.], [2., 1.], [0., 2.]], + &mut services.objects, + ); let face = face .build(&mut services.objects) .insert(&mut services.objects); @@ -196,11 +194,10 @@ mod tests { let mut face = PartialFace::new(); face.surface = Partial::from(services.objects.surfaces.xy_plane()); - face.exterior.write().update_as_polygon_from_points([ - [4., 2.], - [0., 4.], - [0., 0.], - ]); + face.exterior.write().update_as_polygon_from_points( + [[4., 2.], [0., 4.], [0., 0.]], + &mut services.objects, + ); let face = face .build(&mut services.objects) .insert(&mut services.objects); @@ -220,12 +217,10 @@ mod tests { let mut face = PartialFace::new(); face.surface = Partial::from(services.objects.surfaces.xy_plane()); - face.exterior.write().update_as_polygon_from_points([ - [0., 0.], - [2., 1.], - [3., 0.], - [3., 4.], - ]); + face.exterior.write().update_as_polygon_from_points( + [[0., 0.], [2., 1.], [3., 0.], [3., 4.]], + &mut services.objects, + ); let face = face .build(&mut services.objects) .insert(&mut services.objects); @@ -245,12 +240,10 @@ mod tests { let mut face = PartialFace::new(); face.surface = Partial::from(services.objects.surfaces.xy_plane()); - face.exterior.write().update_as_polygon_from_points([ - [0., 0.], - [2., 1.], - [3., 1.], - [0., 2.], - ]); + face.exterior.write().update_as_polygon_from_points( + [[0., 0.], [2., 1.], [3., 1.], [0., 2.]], + &mut services.objects, + ); let face = face .build(&mut services.objects) .insert(&mut services.objects); @@ -270,13 +263,10 @@ mod tests { let mut face = PartialFace::new(); face.surface = Partial::from(services.objects.surfaces.xy_plane()); - face.exterior.write().update_as_polygon_from_points([ - [0., 0.], - [2., 1.], - [3., 1.], - [4., 0.], - [4., 5.], - ]); + face.exterior.write().update_as_polygon_from_points( + [[0., 0.], [2., 1.], [3., 1.], [4., 0.], [4., 5.]], + &mut services.objects, + ); let face = face .build(&mut services.objects) .insert(&mut services.objects); @@ -296,11 +286,10 @@ mod tests { let mut face = PartialFace::new(); face.surface = Partial::from(services.objects.surfaces.xy_plane()); - face.exterior.write().update_as_polygon_from_points([ - [0., 0.], - [2., 0.], - [0., 1.], - ]); + face.exterior.write().update_as_polygon_from_points( + [[0., 0.], [2., 0.], [0., 1.]], + &mut services.objects, + ); let face = face .build(&mut services.objects) .insert(&mut services.objects); @@ -326,11 +315,10 @@ mod tests { let mut face = PartialFace::new(); face.surface = Partial::from(services.objects.surfaces.xy_plane()); - face.exterior.write().update_as_polygon_from_points([ - [0., 0.], - [1., 0.], - [0., 1.], - ]); + face.exterior.write().update_as_polygon_from_points( + [[0., 0.], [1., 0.], [0., 1.]], + &mut services.objects, + ); let face = face .build(&mut services.objects) .insert(&mut services.objects); diff --git a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs index 989a1330b..c7838c25b 100644 --- a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs @@ -166,12 +166,10 @@ mod tests { let mut face = PartialFace::new(); face.surface = Partial::from(services.objects.surfaces.yz_plane()); - face.exterior.write().update_as_polygon_from_points([ - [-1., -1.], - [1., -1.], - [1., 1.], - [-1., 1.], - ]); + face.exterior.write().update_as_polygon_from_points( + [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], + &mut services.objects, + ); let face = face .build(&mut services.objects) .insert(&mut services.objects) @@ -189,12 +187,10 @@ mod tests { let mut face = PartialFace::new(); face.surface = Partial::from(services.objects.surfaces.yz_plane()); - face.exterior.write().update_as_polygon_from_points([ - [-1., -1.], - [1., -1.], - [1., 1.], - [-1., 1.], - ]); + face.exterior.write().update_as_polygon_from_points( + [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], + &mut services.objects, + ); let face = face .build(&mut services.objects) .insert(&mut services.objects) @@ -215,12 +211,10 @@ mod tests { let mut face = PartialFace::new(); face.surface = Partial::from(services.objects.surfaces.yz_plane()); - face.exterior.write().update_as_polygon_from_points([ - [-1., -1.], - [1., -1.], - [1., 1.], - [-1., 1.], - ]); + face.exterior.write().update_as_polygon_from_points( + [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], + &mut services.objects, + ); let face = face .build(&mut services.objects) .insert(&mut services.objects) @@ -238,12 +232,10 @@ mod tests { let mut face = PartialFace::new(); face.surface = Partial::from(services.objects.surfaces.yz_plane()); - face.exterior.write().update_as_polygon_from_points([ - [-1., -1.], - [1., -1.], - [1., 1.], - [-1., 1.], - ]); + face.exterior.write().update_as_polygon_from_points( + [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], + &mut services.objects, + ); let face = face .build(&mut services.objects) .insert(&mut services.objects) @@ -269,12 +261,10 @@ mod tests { let mut face = PartialFace::new(); face.surface = Partial::from(services.objects.surfaces.yz_plane()); - face.exterior.write().update_as_polygon_from_points([ - [-1., -1.], - [1., -1.], - [1., 1.], - [-1., 1.], - ]); + face.exterior.write().update_as_polygon_from_points( + [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], + &mut services.objects, + ); let face = face .build(&mut services.objects) .insert(&mut services.objects) @@ -303,12 +293,10 @@ mod tests { let mut face = PartialFace::new(); face.surface = Partial::from(services.objects.surfaces.xy_plane()); - face.exterior.write().update_as_polygon_from_points([ - [-1., -1.], - [1., -1.], - [1., 1.], - [-1., 1.], - ]); + face.exterior.write().update_as_polygon_from_points( + [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], + &mut services.objects, + ); let face = face .build(&mut services.objects) .insert(&mut services.objects); @@ -328,12 +316,10 @@ mod tests { let mut face = PartialFace::new(); face.surface = Partial::from(services.objects.surfaces.xy_plane()); - face.exterior.write().update_as_polygon_from_points([ - [-1., -1.], - [1., -1.], - [1., 1.], - [-1., 1.], - ]); + face.exterior.write().update_as_polygon_from_points( + [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], + &mut services.objects, + ); let face = face .build(&mut services.objects) .insert(&mut services.objects) diff --git a/crates/fj-kernel/src/algorithms/triangulate/mod.rs b/crates/fj-kernel/src/algorithms/triangulate/mod.rs index 2a84a13cd..ad239c5d5 100644 --- a/crates/fj-kernel/src/algorithms/triangulate/mod.rs +++ b/crates/fj-kernel/src/algorithms/triangulate/mod.rs @@ -100,7 +100,7 @@ mod tests { face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior .write() - .update_as_polygon_from_points([a, b, c, d]); + .update_as_polygon_from_points([a, b, c, d], &mut services.objects); let face = face .build(&mut services.objects) .insert(&mut services.objects); @@ -140,10 +140,10 @@ mod tests { face.surface = Partial::from(surface.clone()); face.exterior .write() - .update_as_polygon_from_points([a, b, c, d]); + .update_as_polygon_from_points([a, b, c, d], &mut services.objects); face.add_interior(&mut services.objects) .write() - .update_as_polygon_from_points([e, f, g, h]); + .update_as_polygon_from_points([e, f, g, h], &mut services.objects); let face = face .build(&mut services.objects) .insert(&mut services.objects); @@ -203,9 +203,10 @@ mod tests { let mut face = PartialFace::new(); face.surface = Partial::from(surface.clone()); - face.exterior - .write() - .update_as_polygon_from_points([a, b, c, d, e]); + face.exterior.write().update_as_polygon_from_points( + [a, b, c, d, e], + &mut services.objects, + ); let face = face .build(&mut services.objects) .insert(&mut services.objects); diff --git a/crates/fj-kernel/src/builder/cycle.rs b/crates/fj-kernel/src/builder/cycle.rs index ddec16daa..768cc8f9e 100644 --- a/crates/fj-kernel/src/builder/cycle.rs +++ b/crates/fj-kernel/src/builder/cycle.rs @@ -3,8 +3,9 @@ use itertools::Itertools; use crate::{ geometry::surface::SurfaceGeometry, - objects::HalfEdge, + objects::{HalfEdge, Objects}, partial::{Partial, PartialCycle}, + services::Service, }; use super::{HalfEdgeBuilder, ObjectArgument}; @@ -26,6 +27,7 @@ pub trait CycleBuilder { fn update_as_polygon_from_points( &mut self, points: O, + objects: &mut Service, ) -> O::SameSize> where O: ObjectArgument

, @@ -62,6 +64,7 @@ impl CycleBuilder for PartialCycle { fn update_as_polygon_from_points( &mut self, points: O, + _: &mut Service, ) -> O::SameSize> where O: ObjectArgument

, diff --git a/crates/fj-kernel/src/validate/edge.rs b/crates/fj-kernel/src/validate/edge.rs index 4b93a0420..ce61b5eb7 100644 --- a/crates/fj-kernel/src/validate/edge.rs +++ b/crates/fj-kernel/src/validate/edge.rs @@ -93,7 +93,10 @@ mod tests { let mut cycle = PartialCycle::new(); let [mut half_edge, next_half_edge, _] = cycle - .update_as_polygon_from_points([[0., 0.], [1., 0.], [1., 1.]]); + .update_as_polygon_from_points( + [[0., 0.], [1., 0.], [1., 1.]], + &mut services.objects, + ); half_edge.write().infer_vertex_positions_if_necessary( &surface.geometry(), next_half_edge.read().start_vertex.clone(), diff --git a/crates/fj-kernel/src/validate/face.rs b/crates/fj-kernel/src/validate/face.rs index c7cf5c4c7..bc69b2762 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -154,14 +154,16 @@ mod tests { let mut face = PartialFace::new(); face.surface = Partial::from(services.objects.surfaces.xy_plane()); - face.exterior.write().update_as_polygon_from_points([ - [0., 0.], - [3., 0.], - [0., 3.], - ]); + face.exterior.write().update_as_polygon_from_points( + [[0., 0.], [3., 0.], [0., 3.]], + &mut services.objects, + ); face.add_interior(&mut services.objects) .write() - .update_as_polygon_from_points([[1., 1.], [1., 2.], [2., 1.]]); + .update_as_polygon_from_points( + [[1., 1.], [1., 2.], [2., 1.]], + &mut services.objects, + ); face.build(&mut services.objects) }; let invalid = { From 90e261975d429a56667cdd96e7457d3a95075225 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 13:43:19 +0100 Subject: [PATCH 28/37] Make object service available in builder method It's going to be needed there soon. --- crates/fj-kernel/src/algorithms/sweep/face.rs | 8 +++++--- crates/fj-kernel/src/builder/cycle.rs | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/face.rs b/crates/fj-kernel/src/algorithms/sweep/face.rs index 69942b180..b38c8d313 100644 --- a/crates/fj-kernel/src/algorithms/sweep/face.rs +++ b/crates/fj-kernel/src/algorithms/sweep/face.rs @@ -89,9 +89,11 @@ impl Sweep for Handle { top_edges.push(Partial::from(top_edge)); } - top_cycle - .write() - .connect_to_closed_edges(top_edges, &top_surface.geometry()); + top_cycle.write().connect_to_closed_edges( + top_edges, + &top_surface.geometry(), + objects, + ); for (bottom, top) in original_edges .into_iter() diff --git a/crates/fj-kernel/src/builder/cycle.rs b/crates/fj-kernel/src/builder/cycle.rs index 768cc8f9e..fb5f4d02f 100644 --- a/crates/fj-kernel/src/builder/cycle.rs +++ b/crates/fj-kernel/src/builder/cycle.rs @@ -43,6 +43,7 @@ pub trait CycleBuilder { &mut self, edges: O, surface: &SurfaceGeometry, + objects: &mut Service, ) -> O::SameSize> where O: ObjectArgument>; @@ -91,6 +92,7 @@ impl CycleBuilder for PartialCycle { &mut self, edges: O, surface: &SurfaceGeometry, + _: &mut Service, ) -> O::SameSize> where O: ObjectArgument>, From 9f7a58adc84aa29ba6b724173aaee512baa1b574 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 13:43:19 +0100 Subject: [PATCH 29/37] Make object service available in builder method It's going to be needed there soon. --- crates/fj-kernel/src/algorithms/sweep/edge.rs | 8 ++++---- crates/fj-kernel/src/builder/cycle.rs | 15 +++++++++------ crates/fj-kernel/src/validate/face.rs | 3 ++- crates/fj-operations/src/sketch.rs | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/edge.rs b/crates/fj-kernel/src/algorithms/sweep/edge.rs index aa983e229..c43e5df63 100644 --- a/crates/fj-kernel/src/algorithms/sweep/edge.rs +++ b/crates/fj-kernel/src/algorithms/sweep/edge.rs @@ -40,10 +40,10 @@ impl Sweep for (Handle, &Handle, &Surface, Color) { } // Now we're ready to create the edges. - let mut edge_bottom = face.exterior.write().add_half_edge(); - let mut edge_up = face.exterior.write().add_half_edge(); - let mut edge_top = face.exterior.write().add_half_edge(); - let mut edge_down = face.exterior.write().add_half_edge(); + let mut edge_bottom = face.exterior.write().add_half_edge(objects); + let mut edge_up = face.exterior.write().add_half_edge(objects); + let mut edge_top = face.exterior.write().add_half_edge(objects); + let mut edge_down = face.exterior.write().add_half_edge(objects); // Those edges aren't fully defined yet. We'll do that shortly, but // first we have to figure a few things out. diff --git a/crates/fj-kernel/src/builder/cycle.rs b/crates/fj-kernel/src/builder/cycle.rs index fb5f4d02f..8b4c22e6e 100644 --- a/crates/fj-kernel/src/builder/cycle.rs +++ b/crates/fj-kernel/src/builder/cycle.rs @@ -21,7 +21,10 @@ pub trait CycleBuilder { /// /// If this is the first half-edge being added, it is connected to itself, /// meaning its front and back vertices are the same. - fn add_half_edge(&mut self) -> Partial; + fn add_half_edge( + &mut self, + objects: &mut Service, + ) -> Partial; /// Update cycle as a polygon from the provided points fn update_as_polygon_from_points( @@ -56,7 +59,7 @@ pub trait CycleBuilder { } impl CycleBuilder for PartialCycle { - fn add_half_edge(&mut self) -> Partial { + fn add_half_edge(&mut self, _: &mut Service) -> Partial { let half_edge = Partial::new(); self.half_edges.push(half_edge.clone()); half_edge @@ -65,7 +68,7 @@ impl CycleBuilder for PartialCycle { fn update_as_polygon_from_points( &mut self, points: O, - _: &mut Service, + objects: &mut Service, ) -> O::SameSize> where O: ObjectArgument

, @@ -74,7 +77,7 @@ impl CycleBuilder for PartialCycle { let mut start_positions = Vec::new(); let half_edges = points.map(|point| { start_positions.push(point.into()); - self.add_half_edge() + self.add_half_edge(objects) }); for ((start, end), half_edge) in start_positions @@ -92,13 +95,13 @@ impl CycleBuilder for PartialCycle { &mut self, edges: O, surface: &SurfaceGeometry, - _: &mut Service, + objects: &mut Service, ) -> O::SameSize> where O: ObjectArgument>, { edges.map_with_prev(|other, prev| { - let mut this = self.add_half_edge(); + let mut this = self.add_half_edge(objects); this.write().update_from_other_edge(&other, &prev, surface); this }) diff --git a/crates/fj-kernel/src/validate/face.rs b/crates/fj-kernel/src/validate/face.rs index bc69b2762..215832920 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -202,7 +202,8 @@ mod tests { let mut face = PartialFace::new(); face.surface = Partial::from(surface.clone()); - let mut half_edge = face.exterior.write().add_half_edge(); + let mut half_edge = + face.exterior.write().add_half_edge(&mut services.objects); half_edge.write().update_as_circle_from_radius(1.); let next_vertex = half_edge.read().start_vertex.clone(); half_edge.write().infer_vertex_positions_if_necessary( diff --git a/crates/fj-operations/src/sketch.rs b/crates/fj-operations/src/sketch.rs index 6d6abca20..803f30d00 100644 --- a/crates/fj-operations/src/sketch.rs +++ b/crates/fj-operations/src/sketch.rs @@ -64,7 +64,7 @@ impl Shape for fj::Sketch { .into_iter() .map(|fj::SketchSegment { endpoint, route }| { let endpoint = Point::from(endpoint); - let half_edge = cycle.add_half_edge(); + let half_edge = cycle.add_half_edge(objects); (half_edge, endpoint, route) }) .collect::>(); From 1f6c5c22ea0c13ba0ebd90d90bb5e82976fe7b32 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 13:25:50 +0100 Subject: [PATCH 30/37] Clean up `PartialFace` construction --- crates/fj-operations/src/sketch.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/fj-operations/src/sketch.rs b/crates/fj-operations/src/sketch.rs index 803f30d00..d9976918a 100644 --- a/crates/fj-operations/src/sketch.rs +++ b/crates/fj-operations/src/sketch.rs @@ -42,12 +42,12 @@ impl Shape for fj::Sketch { Partial::from_partial(cycle) }; - PartialFace { - surface, - exterior, - color: Some(Color(self.color())), - ..PartialFace::new() - } + let mut face = PartialFace::new(); + face.surface = surface; + face.exterior = exterior; + face.color = Some(Color(self.color())); + + face } fj::Chain::PolyChain(poly_chain) => { let segments = poly_chain.to_segments(); @@ -91,12 +91,12 @@ impl Shape for fj::Sketch { Partial::from_partial(cycle) }; - PartialFace { - surface: Partial::from(surface), - exterior, - color: Some(Color(self.color())), - ..PartialFace::new() - } + let mut face = PartialFace::new(); + face.surface = Partial::from(surface); + face.exterior = exterior; + face.color = Some(Color(self.color())); + + face } }; From a137c2b99d7db0240239d584ba3918abfa5eb22a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 14:00:01 +0100 Subject: [PATCH 31/37] Require objects in partial object constructors This is preparation for replacing the first partial objects with their full variants. --- crates/fj-kernel/src/algorithms/approx/edge.rs | 8 ++++---- .../src/algorithms/intersect/curve_edge.rs | 8 ++++---- .../src/algorithms/intersect/curve_face.rs | 2 +- .../src/algorithms/intersect/face_face.rs | 4 ++-- .../src/algorithms/intersect/face_point.rs | 16 ++++++++-------- .../src/algorithms/intersect/ray_face.rs | 14 +++++++------- crates/fj-kernel/src/algorithms/sweep/edge.rs | 2 +- crates/fj-kernel/src/algorithms/sweep/face.rs | 2 +- .../fj-kernel/src/algorithms/triangulate/mod.rs | 6 +++--- crates/fj-kernel/src/builder/cycle.rs | 7 +++++-- crates/fj-kernel/src/builder/face.rs | 7 +++++-- crates/fj-kernel/src/partial/objects/cycle.rs | 2 +- crates/fj-kernel/src/partial/objects/edge.rs | 8 ++++---- crates/fj-kernel/src/partial/objects/face.rs | 6 +++--- crates/fj-kernel/src/partial/objects/shell.rs | 2 +- crates/fj-kernel/src/partial/objects/sketch.rs | 2 +- crates/fj-kernel/src/partial/objects/solid.rs | 2 +- crates/fj-kernel/src/partial/objects/surface.rs | 2 +- crates/fj-kernel/src/partial/objects/vertex.rs | 2 +- crates/fj-kernel/src/partial/traits.rs | 2 +- crates/fj-kernel/src/partial/wrapper.rs | 4 ++-- crates/fj-kernel/src/validate/edge.rs | 2 +- crates/fj-kernel/src/validate/face.rs | 4 ++-- crates/fj-operations/src/sketch.rs | 10 +++++----- 24 files changed, 65 insertions(+), 59 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/approx/edge.rs b/crates/fj-kernel/src/algorithms/approx/edge.rs index a4cce6500..250091818 100644 --- a/crates/fj-kernel/src/algorithms/approx/edge.rs +++ b/crates/fj-kernel/src/algorithms/approx/edge.rs @@ -246,7 +246,7 @@ mod tests { let surface = services.objects.surfaces.xz_plane(); let half_edge = { - let mut cycle = PartialCycle::new(); + let mut cycle = PartialCycle::new(&mut services.objects); let [mut half_edge, next_half_edge, _] = cycle .update_as_polygon_from_points( @@ -281,7 +281,7 @@ mod tests { .build(&mut services.objects) .insert(&mut services.objects); let half_edge = { - let mut cycle = PartialCycle::new(); + let mut cycle = PartialCycle::new(&mut services.objects); let [mut half_edge, next_half_edge, _] = cycle .update_as_polygon_from_points( @@ -316,7 +316,7 @@ mod tests { .build(&mut services.objects) .insert(&mut services.objects); let half_edge = { - let mut cycle = PartialCycle::new(); + let mut cycle = PartialCycle::new(&mut services.objects); let [mut half_edge, next_half_edge, _] = cycle .update_as_polygon_from_points( @@ -361,7 +361,7 @@ mod tests { let surface = services.objects.surfaces.xz_plane(); let half_edge = { - let mut half_edge = PartialHalfEdge::new(); + let mut half_edge = PartialHalfEdge::new(&mut services.objects); half_edge.update_as_circle_from_radius(1.); let next_vertex = half_edge.start_vertex.clone(); diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs index 1c1e462de..9bf243118 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs @@ -87,7 +87,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let curve = Curve::u_axis(); let half_edge = { - let mut cycle = PartialCycle::new(); + let mut cycle = PartialCycle::new(&mut services.objects); let [mut half_edge, next_half_edge, _] = cycle .update_as_polygon_from_points( @@ -119,7 +119,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let curve = Curve::u_axis(); let half_edge = { - let mut cycle = PartialCycle::new(); + let mut cycle = PartialCycle::new(&mut services.objects); let [mut half_edge, next_half_edge, _] = cycle .update_as_polygon_from_points( @@ -151,7 +151,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let curve = Curve::u_axis(); let half_edge = { - let mut cycle = PartialCycle::new(); + let mut cycle = PartialCycle::new(&mut services.objects); let [mut half_edge, next_half_edge, _] = cycle .update_as_polygon_from_points( @@ -178,7 +178,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let curve = Curve::u_axis(); let half_edge = { - let mut cycle = PartialCycle::new(); + let mut cycle = PartialCycle::new(&mut services.objects); let [mut half_edge, next_half_edge, _] = cycle .update_as_polygon_from_points( diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index 40a6607b6..db1721a55 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -180,7 +180,7 @@ mod tests { ]; let face = { - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior diff --git a/crates/fj-kernel/src/algorithms/intersect/face_face.rs b/crates/fj-kernel/src/algorithms/intersect/face_face.rs index f0c794225..96f54e8b6 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_face.rs @@ -86,7 +86,7 @@ mod tests { services.objects.surfaces.xz_plane(), ] .map(|surface| { - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(surface); face.exterior @@ -117,7 +117,7 @@ mod tests { services.objects.surfaces.xz_plane(), ]; let [a, b] = surfaces.clone().map(|surface| { - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(surface); face.exterior diff --git a/crates/fj-kernel/src/algorithms/intersect/face_point.rs b/crates/fj-kernel/src/algorithms/intersect/face_point.rs index e0471a047..c761f1ad1 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_point.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_point.rs @@ -148,7 +148,7 @@ mod tests { fn point_is_outside_face() { let mut services = Services::new(); - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points( @@ -168,7 +168,7 @@ mod tests { fn ray_hits_vertex_while_passing_outside() { let mut services = Services::new(); - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points( @@ -191,7 +191,7 @@ mod tests { fn ray_hits_vertex_at_cycle_seam() { let mut services = Services::new(); - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points( @@ -214,7 +214,7 @@ mod tests { fn ray_hits_vertex_while_staying_inside() { let mut services = Services::new(); - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points( @@ -237,7 +237,7 @@ mod tests { fn ray_hits_parallel_edge_and_leaves_face_at_vertex() { let mut services = Services::new(); - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points( @@ -260,7 +260,7 @@ mod tests { fn ray_hits_parallel_edge_and_does_not_leave_face_there() { let mut services = Services::new(); - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points( @@ -283,7 +283,7 @@ mod tests { fn point_is_coincident_with_edge() { let mut services = Services::new(); - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points( @@ -312,7 +312,7 @@ mod tests { fn point_is_coincident_with_vertex() { let mut services = Services::new(); - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points( diff --git a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs index c7838c25b..111e24273 100644 --- a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs @@ -163,7 +163,7 @@ mod tests { let ray = HorizontalRayToTheRight::from([0., 0., 0.]); - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(services.objects.surfaces.yz_plane()); face.exterior.write().update_as_polygon_from_points( @@ -184,7 +184,7 @@ mod tests { let ray = HorizontalRayToTheRight::from([0., 0., 0.]); - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(services.objects.surfaces.yz_plane()); face.exterior.write().update_as_polygon_from_points( @@ -208,7 +208,7 @@ mod tests { let ray = HorizontalRayToTheRight::from([0., 0., 0.]); - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(services.objects.surfaces.yz_plane()); face.exterior.write().update_as_polygon_from_points( @@ -229,7 +229,7 @@ mod tests { let ray = HorizontalRayToTheRight::from([0., 0., 0.]); - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(services.objects.surfaces.yz_plane()); face.exterior.write().update_as_polygon_from_points( @@ -258,7 +258,7 @@ mod tests { let ray = HorizontalRayToTheRight::from([0., 0., 0.]); - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(services.objects.surfaces.yz_plane()); face.exterior.write().update_as_polygon_from_points( @@ -290,7 +290,7 @@ mod tests { let ray = HorizontalRayToTheRight::from([0., 0., 0.]); - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points( @@ -313,7 +313,7 @@ mod tests { let ray = HorizontalRayToTheRight::from([0., 0., 0.]); - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points( diff --git a/crates/fj-kernel/src/algorithms/sweep/edge.rs b/crates/fj-kernel/src/algorithms/sweep/edge.rs index c43e5df63..f530949f8 100644 --- a/crates/fj-kernel/src/algorithms/sweep/edge.rs +++ b/crates/fj-kernel/src/algorithms/sweep/edge.rs @@ -26,7 +26,7 @@ impl Sweep for (Handle, &Handle, &Surface, Color) { let path = path.into(); // The result of sweeping an edge is a face. Let's create that. - let mut face = PartialFace::new(); + let mut face = PartialFace::new(objects); face.color = Some(color); // A face (and everything in it) is defined on a surface. A surface can diff --git a/crates/fj-kernel/src/algorithms/sweep/face.rs b/crates/fj-kernel/src/algorithms/sweep/face.rs index b38c8d313..3c63a5bac 100644 --- a/crates/fj-kernel/src/algorithms/sweep/face.rs +++ b/crates/fj-kernel/src/algorithms/sweep/face.rs @@ -57,7 +57,7 @@ impl Sweep for Handle { let top_surface = bottom_face.surface().clone().translate(path, objects); - let mut top_face = PartialFace::new(); + let mut top_face = PartialFace::new(objects); top_face.surface = Partial::from(top_surface.clone()); top_face.color = Some(self.color()); diff --git a/crates/fj-kernel/src/algorithms/triangulate/mod.rs b/crates/fj-kernel/src/algorithms/triangulate/mod.rs index ad239c5d5..5406e88b4 100644 --- a/crates/fj-kernel/src/algorithms/triangulate/mod.rs +++ b/crates/fj-kernel/src/algorithms/triangulate/mod.rs @@ -96,7 +96,7 @@ mod tests { let c = [2., 2.]; let d = [0., 1.]; - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior .write() @@ -136,7 +136,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(surface.clone()); face.exterior .write() @@ -201,7 +201,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(surface.clone()); face.exterior.write().update_as_polygon_from_points( [a, b, c, d, e], diff --git a/crates/fj-kernel/src/builder/cycle.rs b/crates/fj-kernel/src/builder/cycle.rs index 8b4c22e6e..fdb390439 100644 --- a/crates/fj-kernel/src/builder/cycle.rs +++ b/crates/fj-kernel/src/builder/cycle.rs @@ -59,8 +59,11 @@ pub trait CycleBuilder { } impl CycleBuilder for PartialCycle { - fn add_half_edge(&mut self, _: &mut Service) -> Partial { - let half_edge = Partial::new(); + fn add_half_edge( + &mut self, + objects: &mut Service, + ) -> Partial { + let half_edge = Partial::new(objects); self.half_edges.push(half_edge.clone()); half_edge } diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index ac8a6ba47..2ee8339d3 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -14,8 +14,11 @@ pub trait FaceBuilder { } impl FaceBuilder for PartialFace { - fn add_interior(&mut self, _: &mut Service) -> Partial { - let cycle = Partial::new(); + fn add_interior( + &mut self, + objects: &mut Service, + ) -> Partial { + let cycle = Partial::new(objects); self.interiors.push(cycle.clone()); cycle } diff --git a/crates/fj-kernel/src/partial/objects/cycle.rs b/crates/fj-kernel/src/partial/objects/cycle.rs index 5218c3148..5615a74a1 100644 --- a/crates/fj-kernel/src/partial/objects/cycle.rs +++ b/crates/fj-kernel/src/partial/objects/cycle.rs @@ -14,7 +14,7 @@ pub struct PartialCycle { impl PartialObject for PartialCycle { type Full = Cycle; - fn new() -> Self { + fn new(_: &mut Service) -> Self { Self { half_edges: Vec::new(), } diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index 7837aaf79..8b2b6c27d 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -45,10 +45,10 @@ impl PartialHalfEdge { impl PartialObject for PartialHalfEdge { type Full = HalfEdge; - fn new() -> Self { + fn new(objects: &mut Service) -> Self { let curve = None; - let start_vertex = Partial::new(); - let global_form = Partial::new(); + let start_vertex = Partial::new(objects); + let global_form = Partial::new(objects); Self { curve, @@ -102,7 +102,7 @@ pub struct PartialGlobalEdge {} impl PartialObject for PartialGlobalEdge { type Full = GlobalEdge; - fn new() -> Self { + fn new(_: &mut Service) -> Self { Self {} } diff --git a/crates/fj-kernel/src/partial/objects/face.rs b/crates/fj-kernel/src/partial/objects/face.rs index 61810f8b1..ba751b7d7 100644 --- a/crates/fj-kernel/src/partial/objects/face.rs +++ b/crates/fj-kernel/src/partial/objects/face.rs @@ -28,10 +28,10 @@ pub struct PartialFace { impl PartialObject for PartialFace { type Full = Face; - fn new() -> Self { + fn new(objects: &mut Service) -> Self { Self { - surface: Partial::new(), - exterior: Partial::new(), + surface: Partial::new(objects), + exterior: Partial::new(objects), interiors: Vec::new(), color: None, } diff --git a/crates/fj-kernel/src/partial/objects/shell.rs b/crates/fj-kernel/src/partial/objects/shell.rs index d19e75651..b7f3fcc1d 100644 --- a/crates/fj-kernel/src/partial/objects/shell.rs +++ b/crates/fj-kernel/src/partial/objects/shell.rs @@ -14,7 +14,7 @@ pub struct PartialShell { impl PartialObject for PartialShell { type Full = Shell; - fn new() -> Self { + fn new(_: &mut Service) -> Self { Self { faces: Vec::new() } } diff --git a/crates/fj-kernel/src/partial/objects/sketch.rs b/crates/fj-kernel/src/partial/objects/sketch.rs index 78324a68d..74066ce33 100644 --- a/crates/fj-kernel/src/partial/objects/sketch.rs +++ b/crates/fj-kernel/src/partial/objects/sketch.rs @@ -14,7 +14,7 @@ pub struct PartialSketch { impl PartialObject for PartialSketch { type Full = Sketch; - fn new() -> Self { + fn new(_: &mut Service) -> Self { Self { faces: Vec::new() } } diff --git a/crates/fj-kernel/src/partial/objects/solid.rs b/crates/fj-kernel/src/partial/objects/solid.rs index a3e71c8d2..6ab762ccb 100644 --- a/crates/fj-kernel/src/partial/objects/solid.rs +++ b/crates/fj-kernel/src/partial/objects/solid.rs @@ -14,7 +14,7 @@ pub struct PartialSolid { impl PartialObject for PartialSolid { type Full = Solid; - fn new() -> Self { + fn new(_: &mut Service) -> Self { Self { shells: Vec::new() } } diff --git a/crates/fj-kernel/src/partial/objects/surface.rs b/crates/fj-kernel/src/partial/objects/surface.rs index 4784034c9..c2eec099a 100644 --- a/crates/fj-kernel/src/partial/objects/surface.rs +++ b/crates/fj-kernel/src/partial/objects/surface.rs @@ -15,7 +15,7 @@ pub struct PartialSurface { impl PartialObject for PartialSurface { type Full = Surface; - fn new() -> Self { + fn new(_: &mut Service) -> Self { Self { geometry: None } } diff --git a/crates/fj-kernel/src/partial/objects/vertex.rs b/crates/fj-kernel/src/partial/objects/vertex.rs index 8263b9396..00cd408fd 100644 --- a/crates/fj-kernel/src/partial/objects/vertex.rs +++ b/crates/fj-kernel/src/partial/objects/vertex.rs @@ -16,7 +16,7 @@ pub struct PartialVertex { impl PartialObject for PartialVertex { type Full = Vertex; - fn new() -> Self { + fn new(_: &mut Service) -> Self { Self { position: None } } diff --git a/crates/fj-kernel/src/partial/traits.rs b/crates/fj-kernel/src/partial/traits.rs index 02ed12a48..6dbd1f88b 100644 --- a/crates/fj-kernel/src/partial/traits.rs +++ b/crates/fj-kernel/src/partial/traits.rs @@ -16,7 +16,7 @@ pub trait PartialObject: Clone + Debug { type Full: HasPartial; /// Construct a default partial object - fn new() -> Self; + fn new(objects: &mut Service) -> Self; /// Construct a partial object from a full one fn from_full(full: &Self::Full, cache: &mut FullToPartialCache) -> Self; diff --git a/crates/fj-kernel/src/partial/wrapper.rs b/crates/fj-kernel/src/partial/wrapper.rs index f895c2786..00cb6f05d 100644 --- a/crates/fj-kernel/src/partial/wrapper.rs +++ b/crates/fj-kernel/src/partial/wrapper.rs @@ -30,8 +30,8 @@ pub struct Partial { impl Partial { /// Construct a `Partial` with a default inner partial object #[allow(clippy::new_without_default)] - pub fn new() -> Self { - Self::from_partial(T::Partial::new()) + pub fn new(objects: &mut Service) -> Self { + Self::from_partial(T::Partial::new(objects)) } /// Construct a `Partial` from a partial object diff --git a/crates/fj-kernel/src/validate/edge.rs b/crates/fj-kernel/src/validate/edge.rs index ce61b5eb7..e8ca480c5 100644 --- a/crates/fj-kernel/src/validate/edge.rs +++ b/crates/fj-kernel/src/validate/edge.rs @@ -90,7 +90,7 @@ mod tests { let valid = { let surface = services.objects.surfaces.xy_plane(); - let mut cycle = PartialCycle::new(); + let mut cycle = PartialCycle::new(&mut services.objects); let [mut half_edge, next_half_edge, _] = cycle .update_as_polygon_from_points( diff --git a/crates/fj-kernel/src/validate/face.rs b/crates/fj-kernel/src/validate/face.rs index 215832920..1965f197c 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -151,7 +151,7 @@ mod tests { let mut services = Services::new(); let valid = { - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(services.objects.surfaces.xy_plane()); face.exterior.write().update_as_polygon_from_points( @@ -199,7 +199,7 @@ mod tests { let valid = { let surface = services.objects.surfaces.xy_plane(); - let mut face = PartialFace::new(); + let mut face = PartialFace::new(&mut services.objects); face.surface = Partial::from(surface.clone()); let mut half_edge = diff --git a/crates/fj-operations/src/sketch.rs b/crates/fj-operations/src/sketch.rs index d9976918a..40766b1cd 100644 --- a/crates/fj-operations/src/sketch.rs +++ b/crates/fj-operations/src/sketch.rs @@ -31,18 +31,18 @@ impl Shape for fj::Sketch { let surface = Partial::from(surface); let half_edge = { - let mut half_edge = PartialHalfEdge::new(); + let mut half_edge = PartialHalfEdge::new(objects); half_edge.update_as_circle_from_radius(circle.radius()); Partial::from_partial(half_edge) }; let exterior = { - let mut cycle = PartialCycle::new(); + let mut cycle = PartialCycle::new(objects); cycle.half_edges.push(half_edge); Partial::from_partial(cycle) }; - let mut face = PartialFace::new(); + let mut face = PartialFace::new(objects); face.surface = surface; face.exterior = exterior; face.color = Some(Color(self.color())); @@ -57,7 +57,7 @@ impl Shape for fj::Sketch { ); let exterior = { - let mut cycle = PartialCycle::new(); + let mut cycle = PartialCycle::new(objects); let half_edges = poly_chain .to_segments() @@ -91,7 +91,7 @@ impl Shape for fj::Sketch { Partial::from_partial(cycle) }; - let mut face = PartialFace::new(); + let mut face = PartialFace::new(objects); face.surface = Partial::from(surface); face.exterior = exterior; face.color = Some(Color(self.color())); From 2114d8c4db58d7cd9f52ed3f1a84fed9769b6e0b Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 14:02:17 +0100 Subject: [PATCH 32/37] Use `GlobalEdge` in `PartialHalfEdge` --- crates/fj-kernel/src/algorithms/sweep/edge.rs | 2 +- crates/fj-kernel/src/partial/objects/edge.rs | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/edge.rs b/crates/fj-kernel/src/algorithms/sweep/edge.rs index f530949f8..226213844 100644 --- a/crates/fj-kernel/src/algorithms/sweep/edge.rs +++ b/crates/fj-kernel/src/algorithms/sweep/edge.rs @@ -127,7 +127,7 @@ impl Sweep for (Handle, &Handle, &Surface, Color) { [edge_bottom.write(), edge_up.write(), edge_down.write()] .zip_ext(global_edges) .map(|(mut half_edge, global_edge)| { - half_edge.global_form = Partial::from(global_edge); + half_edge.global_form = global_edge; }); // And we're done creating the face! All that's left to do is build our diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index 8b2b6c27d..640103ee8 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -1,9 +1,11 @@ use fj_math::Point; use crate::{ + insert::Insert, objects::{GlobalEdge, HalfEdge, Objects, Vertex}, partial::{FullToPartialCache, MaybeCurve, Partial, PartialObject}, services::Service, + storage::Handle, }; /// A partial [`HalfEdge`] @@ -19,7 +21,7 @@ pub struct PartialHalfEdge { pub start_vertex: Partial, /// The global form of the half-edge - pub global_form: Partial, + pub global_form: Handle, } impl PartialHalfEdge { @@ -48,7 +50,7 @@ impl PartialObject for PartialHalfEdge { fn new(objects: &mut Service) -> Self { let curve = None; let start_vertex = Partial::new(objects); - let global_form = Partial::new(objects); + let global_form = GlobalEdge::new().insert(objects); Self { curve, @@ -69,10 +71,7 @@ impl PartialObject for PartialHalfEdge { half_edge.start_vertex().clone(), cache, ), - global_form: Partial::from_full( - half_edge.global_form().clone(), - cache, - ), + global_form: half_edge.global_form().clone(), } } @@ -89,7 +88,7 @@ impl PartialObject for PartialHalfEdge { point.expect("Can't build `HalfEdge` without boundary positions") }); let start_vertex = self.start_vertex.build(objects); - let global_form = self.global_form.build(objects); + let global_form = self.global_form; HalfEdge::new(curve, boundary, start_vertex, global_form) } From 85ec1890e7071748d85b50ef02bdc7b70ee1edc1 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 14:03:36 +0100 Subject: [PATCH 33/37] Inline variables --- crates/fj-kernel/src/partial/objects/edge.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index 640103ee8..e309a51f4 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -48,15 +48,11 @@ impl PartialObject for PartialHalfEdge { type Full = HalfEdge; fn new(objects: &mut Service) -> Self { - let curve = None; - let start_vertex = Partial::new(objects); - let global_form = GlobalEdge::new().insert(objects); - Self { - curve, + curve: None, boundary: [None; 2], - start_vertex, - global_form, + start_vertex: Partial::new(objects), + global_form: GlobalEdge::new().insert(objects), } } From a04d7ee7f8e9ddc5a56f8016af92dd475d200b85 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 14:04:17 +0100 Subject: [PATCH 34/37] Inline variable --- crates/fj-kernel/src/partial/objects/edge.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index e309a51f4..523801523 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -84,9 +84,8 @@ impl PartialObject for PartialHalfEdge { point.expect("Can't build `HalfEdge` without boundary positions") }); let start_vertex = self.start_vertex.build(objects); - let global_form = self.global_form; - HalfEdge::new(curve, boundary, start_vertex, global_form) + HalfEdge::new(curve, boundary, start_vertex, self.global_form) } } From 95ba176e645841ec53095dc49ae1abf19b584240 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 14:05:12 +0100 Subject: [PATCH 35/37] Remove `GlobalEdgeBuilder` --- crates/fj-kernel/src/builder/edge.rs | 10 +--------- crates/fj-kernel/src/builder/mod.rs | 11 +++-------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/crates/fj-kernel/src/builder/edge.rs b/crates/fj-kernel/src/builder/edge.rs index 571878f22..c7d461616 100644 --- a/crates/fj-kernel/src/builder/edge.rs +++ b/crates/fj-kernel/src/builder/edge.rs @@ -7,7 +7,7 @@ use crate::{ surface::SurfaceGeometry, }, objects::{HalfEdge, Vertex}, - partial::{MaybeCurve, Partial, PartialGlobalEdge, PartialHalfEdge}, + partial::{MaybeCurve, Partial, PartialHalfEdge}, }; /// Builder API for [`PartialHalfEdge`] @@ -253,11 +253,3 @@ impl HalfEdgeBuilder for PartialHalfEdge { other_prev.read().start_vertex.read().position; } } - -/// Builder API for [`PartialGlobalEdge`] -pub trait GlobalEdgeBuilder { - // No methods are currently defined. This trait serves as a placeholder, to - // make it clear where to add such methods, once necessary. -} - -impl GlobalEdgeBuilder for PartialGlobalEdge {} diff --git a/crates/fj-kernel/src/builder/mod.rs b/crates/fj-kernel/src/builder/mod.rs index 4c0def19b..c7426ad9c 100644 --- a/crates/fj-kernel/src/builder/mod.rs +++ b/crates/fj-kernel/src/builder/mod.rs @@ -13,14 +13,9 @@ mod vertex; use std::array; pub use self::{ - cycle::CycleBuilder, - edge::{GlobalEdgeBuilder, HalfEdgeBuilder}, - face::FaceBuilder, - shell::ShellBuilder, - sketch::SketchBuilder, - solid::SolidBuilder, - surface::SurfaceBuilder, - vertex::VertexBuilder, + cycle::CycleBuilder, edge::HalfEdgeBuilder, face::FaceBuilder, + shell::ShellBuilder, sketch::SketchBuilder, solid::SolidBuilder, + surface::SurfaceBuilder, vertex::VertexBuilder, }; /// Pass objects to a builder method From 566c3d347d8d7ccf4df577d8f6d5583d8936ea0a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 14:05:57 +0100 Subject: [PATCH 36/37] Remove `PartialGlobalEdge` --- crates/fj-kernel/src/partial/mod.rs | 12 +++--------- crates/fj-kernel/src/partial/objects/edge.rs | 20 -------------------- crates/fj-kernel/src/partial/traits.rs | 1 - 3 files changed, 3 insertions(+), 30 deletions(-) diff --git a/crates/fj-kernel/src/partial/mod.rs b/crates/fj-kernel/src/partial/mod.rs index 35979ce53..0ccf0c466 100644 --- a/crates/fj-kernel/src/partial/mod.rs +++ b/crates/fj-kernel/src/partial/mod.rs @@ -16,15 +16,9 @@ mod wrapper; pub use self::{ objects::{ - curve::MaybeCurve, - cycle::PartialCycle, - edge::{PartialGlobalEdge, PartialHalfEdge}, - face::PartialFace, - shell::PartialShell, - sketch::PartialSketch, - solid::PartialSolid, - surface::PartialSurface, - vertex::PartialVertex, + curve::MaybeCurve, cycle::PartialCycle, edge::PartialHalfEdge, + face::PartialFace, shell::PartialShell, sketch::PartialSketch, + solid::PartialSolid, surface::PartialSurface, vertex::PartialVertex, }, traits::{HasPartial, PartialObject}, wrapper::{FullToPartialCache, Partial}, diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index 523801523..50c9b197c 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -88,23 +88,3 @@ impl PartialObject for PartialHalfEdge { HalfEdge::new(curve, boundary, start_vertex, self.global_form) } } - -/// A partial [`GlobalEdge`] -#[derive(Clone, Debug)] -pub struct PartialGlobalEdge {} - -impl PartialObject for PartialGlobalEdge { - type Full = GlobalEdge; - - fn new(_: &mut Service) -> Self { - Self {} - } - - fn from_full(_: &Self::Full, _: &mut FullToPartialCache) -> Self { - Self {} - } - - fn build(self, _: &mut Service) -> Self::Full { - GlobalEdge::new() - } -} diff --git a/crates/fj-kernel/src/partial/traits.rs b/crates/fj-kernel/src/partial/traits.rs index 6dbd1f88b..0a61347f8 100644 --- a/crates/fj-kernel/src/partial/traits.rs +++ b/crates/fj-kernel/src/partial/traits.rs @@ -38,7 +38,6 @@ macro_rules! impl_trait { impl_trait!( Cycle, PartialCycle; Face, PartialFace; - GlobalEdge, PartialGlobalEdge; HalfEdge, PartialHalfEdge; Shell, PartialShell; Sketch, PartialSketch; From d8b3d70a8698ae76176f36f3e8918472aba242e6 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 14:14:55 +0100 Subject: [PATCH 37/37] Remove unused `allow` --- crates/fj-kernel/src/partial/wrapper.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/fj-kernel/src/partial/wrapper.rs b/crates/fj-kernel/src/partial/wrapper.rs index 00cb6f05d..d42353bda 100644 --- a/crates/fj-kernel/src/partial/wrapper.rs +++ b/crates/fj-kernel/src/partial/wrapper.rs @@ -29,7 +29,6 @@ pub struct Partial { impl Partial { /// Construct a `Partial` with a default inner partial object - #[allow(clippy::new_without_default)] pub fn new(objects: &mut Service) -> Self { Self::from_partial(T::Partial::new(objects)) }