From d89b69918643322d533fbb6ead908670bdb47151 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 11 Nov 2022 11:31:07 +0100 Subject: [PATCH 01/20] Add `MergeWith` --- crates/fj-kernel/src/partial/merge.rs | 13 +++++++++++++ crates/fj-kernel/src/partial/mod.rs | 2 ++ 2 files changed, 15 insertions(+) create mode 100644 crates/fj-kernel/src/partial/merge.rs diff --git a/crates/fj-kernel/src/partial/merge.rs b/crates/fj-kernel/src/partial/merge.rs new file mode 100644 index 000000000..4d080b839 --- /dev/null +++ b/crates/fj-kernel/src/partial/merge.rs @@ -0,0 +1,13 @@ +/// Trait for merging partial objects +/// +/// Implemented for all partial objects themselves, and also some related types +/// that partial objects usually contain. +pub trait MergeWith: Sized { + /// Merge this object with another + /// + /// # Panics + /// + /// Merging two objects that cannot be merged is considered a programmer + /// error and will result in a panic. + fn merge_with(self, other: impl Into) -> Self; +} diff --git a/crates/fj-kernel/src/partial/mod.rs b/crates/fj-kernel/src/partial/mod.rs index f7e845d07..e0e941638 100644 --- a/crates/fj-kernel/src/partial/mod.rs +++ b/crates/fj-kernel/src/partial/mod.rs @@ -35,12 +35,14 @@ //! [#1147]: https://github.com/hannobraun/Fornjot/issues/1147 mod maybe_partial; +mod merge; mod objects; mod traits; mod util; pub use self::{ maybe_partial::MaybePartial, + merge::MergeWith, objects::{ curve::{PartialCurve, PartialGlobalCurve}, cycle::PartialCycle, From 3b7d6478f34dc4a87008a703a234212e8e8f0d01 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 11 Nov 2022 11:54:34 +0100 Subject: [PATCH 02/20] Implement `MergeWith` for `Option` --- crates/fj-kernel/src/partial/merge.rs | 30 +++++++++++++++++++ crates/fj-kernel/src/partial/objects/curve.rs | 6 ++-- crates/fj-kernel/src/partial/objects/cycle.rs | 6 ++-- crates/fj-kernel/src/partial/objects/face.rs | 6 ++-- .../fj-kernel/src/partial/objects/vertex.rs | 10 +++---- crates/fj-kernel/src/partial/util.rs | 16 ---------- 6 files changed, 43 insertions(+), 31 deletions(-) diff --git a/crates/fj-kernel/src/partial/merge.rs b/crates/fj-kernel/src/partial/merge.rs index 4d080b839..5353e15d3 100644 --- a/crates/fj-kernel/src/partial/merge.rs +++ b/crates/fj-kernel/src/partial/merge.rs @@ -11,3 +11,33 @@ pub trait MergeWith: Sized { /// error and will result in a panic. fn merge_with(self, other: impl Into) -> Self; } + +impl MergeWith for Option +where + T: PartialEq, +{ + fn merge_with(self, other: impl Into) -> Self { + let other = other.into(); + + if self == other { + return self; + } + + // We know that `self != other`, or we wouldn't have made it here. + if self.is_some() && other.is_some() { + // It would be great if we could optionally merge the two values + // recursively, if they support that, but that requires + // `specialization`: + // https://doc.rust-lang.org/nightly/unstable-book/language-features/specialization.html + // + // Or maybe `min_specialization`: + // https://doc.rust-lang.org/nightly/unstable-book/language-features/min-specialization.html + // + // Basically, we'd have one default implementation for all types, + // and a specialized one for `T: MergeWith`. + panic!("Can't merge two `Option`s that are both `Some`") + } + + self.xor(other) + } +} diff --git a/crates/fj-kernel/src/partial/objects/curve.rs b/crates/fj-kernel/src/partial/objects/curve.rs index 6c08f77fd..6875f6eaf 100644 --- a/crates/fj-kernel/src/partial/objects/curve.rs +++ b/crates/fj-kernel/src/partial/objects/curve.rs @@ -1,6 +1,6 @@ use crate::{ objects::{Curve, GlobalCurve, Objects, Surface}, - partial::{util::merge_options, MaybePartial}, + partial::{MaybePartial, MergeWith}, path::SurfacePath, storage::Handle, validate::ValidationError, @@ -73,8 +73,8 @@ impl PartialCurve { }; Self { - path: merge_options(self.path, other.path), - surface: merge_options(self.surface, other.surface), + path: self.path.merge_with(other.path), + surface: self.surface.merge_with(other.surface), global_form, } } diff --git a/crates/fj-kernel/src/partial/objects/cycle.rs b/crates/fj-kernel/src/partial/objects/cycle.rs index bbefef967..a543dc7a7 100644 --- a/crates/fj-kernel/src/partial/objects/cycle.rs +++ b/crates/fj-kernel/src/partial/objects/cycle.rs @@ -1,9 +1,7 @@ use crate::{ builder::HalfEdgeBuilder, objects::{Cycle, HalfEdge, Objects, Surface}, - partial::{ - util::merge_options, MaybePartial, PartialHalfEdge, PartialVertex, - }, + partial::{MaybePartial, MergeWith, PartialHalfEdge, PartialVertex}, storage::Handle, validate::ValidationError, }; @@ -45,7 +43,7 @@ impl PartialCycle { let mut surface = self.surface(); for half_edge in half_edges { - surface = merge_options(surface, half_edge.curve().surface()); + surface = surface.merge_with(half_edge.curve().surface()); self.half_edges.push(half_edge); } diff --git a/crates/fj-kernel/src/partial/objects/face.rs b/crates/fj-kernel/src/partial/objects/face.rs index f2dcc8460..0b48d1f58 100644 --- a/crates/fj-kernel/src/partial/objects/face.rs +++ b/crates/fj-kernel/src/partial/objects/face.rs @@ -2,7 +2,7 @@ use fj_interop::mesh::Color; use crate::{ objects::{Cycle, Face, Objects, Surface}, - partial::{util::merge_options, MaybePartial}, + partial::{MaybePartial, MergeWith}, storage::Handle, validate::ValidationError, }; @@ -76,10 +76,10 @@ impl PartialFace { interiors.extend(other.interiors); Self { - surface: merge_options(self.surface, other.surface), + surface: self.surface.merge_with(other.surface), exterior: self.exterior.merge_with(other.exterior), interiors, - color: merge_options(self.color, other.color), + color: self.color.merge_with(other.color), } } diff --git a/crates/fj-kernel/src/partial/objects/vertex.rs b/crates/fj-kernel/src/partial/objects/vertex.rs index e7693ca50..f8ce82ac8 100644 --- a/crates/fj-kernel/src/partial/objects/vertex.rs +++ b/crates/fj-kernel/src/partial/objects/vertex.rs @@ -3,7 +3,7 @@ use fj_math::Point; use crate::{ builder::GlobalVertexBuilder, objects::{Curve, GlobalVertex, Objects, Surface, SurfaceVertex, Vertex}, - partial::{util::merge_options, MaybePartial}, + partial::{MaybePartial, MergeWith}, storage::Handle, validate::ValidationError, }; @@ -63,7 +63,7 @@ impl PartialVertex { /// Merge this partial object with another pub fn merge_with(self, other: Self) -> Self { Self { - position: merge_options(self.position, other.position), + position: self.position.merge_with(other.position), curve: self.curve.merge_with(other.curve), surface_form: self.surface_form.merge_with(other.surface_form), } @@ -168,8 +168,8 @@ impl PartialSurfaceVertex { /// Merge this partial object with another pub fn merge_with(self, other: Self) -> Self { Self { - position: merge_options(self.position, other.position), - surface: merge_options(self.surface, other.surface), + position: self.position.merge_with(other.position), + surface: self.surface.merge_with(other.surface), global_form: self.global_form.merge_with(other.global_form), } } @@ -235,7 +235,7 @@ impl PartialGlobalVertex { /// Merge this partial object with another pub fn merge_with(self, other: Self) -> Self { Self { - position: merge_options(self.position, other.position), + position: self.position.merge_with(other.position), } } diff --git a/crates/fj-kernel/src/partial/util.rs b/crates/fj-kernel/src/partial/util.rs index a0c11dc7c..b7597a39f 100644 --- a/crates/fj-kernel/src/partial/util.rs +++ b/crates/fj-kernel/src/partial/util.rs @@ -2,22 +2,6 @@ use iter_fixed::IntoIteratorFixed; use super::{HasPartial, MaybePartial}; -pub fn merge_options(a: Option, b: Option) -> Option -where - T: Eq, -{ - if a == b { - return a; - } - - // We know that `a != b`, or we wouldn't have made it here. - if a.is_some() && b.is_some() { - panic!("Can't merge `Option`s if both are defined"); - } - - a.xor(b) -} - pub fn merge_arrays( a: [MaybePartial; 2], b: [MaybePartial; 2], From b0f725d99ec2b446ff3fb63762ea3deba4ddc209 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 11 Nov 2022 12:30:48 +0100 Subject: [PATCH 03/20] Implement `MergeWith` for `MaybePartial` --- crates/fj-kernel/src/partial/maybe_partial.rs | 46 ++++++++++--------- crates/fj-kernel/src/partial/objects/edge.rs | 2 +- crates/fj-kernel/src/partial/util.rs | 2 +- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/crates/fj-kernel/src/partial/maybe_partial.rs b/crates/fj-kernel/src/partial/maybe_partial.rs index 4a232fb71..f7ca6ca9e 100644 --- a/crates/fj-kernel/src/partial/maybe_partial.rs +++ b/crates/fj-kernel/src/partial/maybe_partial.rs @@ -11,7 +11,7 @@ use crate::{ validate::{Validate, ValidationError}, }; -use super::{HasPartial, Partial}; +use super::{HasPartial, MergeWith, Partial}; /// Can be used everywhere either a partial or full objects are accepted /// @@ -65,26 +65,6 @@ impl MaybePartial { } } - /// Merge this `MaybePartial` with another of the same type - pub fn merge_with(self, other: impl Into) -> Self { - match (self, other.into()) { - (Self::Full(a), Self::Full(b)) => { - if a.id() != b.id() { - panic!("Can't merge two full objects") - } - - // If they're equal, which they are, if we reach this point, - // then merging them is a no-op. - Self::Full(a) - } - (Self::Full(full), Self::Partial(_)) - | (Self::Partial(_), Self::Full(full)) => Self::Full(full), - (Self::Partial(a), Self::Partial(b)) => { - Self::Partial(a.merge_with(b)) - } - } - } - /// Return or build a full object /// /// If this already is a full object, it is returned. If this is a partial @@ -128,6 +108,30 @@ where } } +impl MergeWith for MaybePartial +where + T: HasPartial, +{ + fn merge_with(self, other: impl Into) -> Self { + match (self, other.into()) { + (Self::Full(a), Self::Full(b)) => { + if a.id() != b.id() { + panic!("Can't merge two full objects") + } + + // If they're equal, which they are, if we reach this point, + // then merging them is a no-op. + Self::Full(a) + } + (Self::Full(full), Self::Partial(_)) + | (Self::Partial(_), Self::Full(full)) => Self::Full(full), + (Self::Partial(a), Self::Partial(b)) => { + Self::Partial(a.merge_with(b)) + } + } + } +} + impl From> for MaybePartial where T: HasPartial, diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index f2d7e3cea..6ea6776be 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -6,7 +6,7 @@ use crate::{ Curve, GlobalCurve, GlobalEdge, GlobalVertex, HalfEdge, Objects, Surface, Vertex, }, - partial::{util::merge_arrays, MaybePartial}, + partial::{util::merge_arrays, MaybePartial, MergeWith}, storage::Handle, validate::ValidationError, }; diff --git a/crates/fj-kernel/src/partial/util.rs b/crates/fj-kernel/src/partial/util.rs index b7597a39f..d86f8e82b 100644 --- a/crates/fj-kernel/src/partial/util.rs +++ b/crates/fj-kernel/src/partial/util.rs @@ -1,6 +1,6 @@ use iter_fixed::IntoIteratorFixed; -use super::{HasPartial, MaybePartial}; +use super::{HasPartial, MaybePartial, MergeWith}; pub fn merge_arrays( a: [MaybePartial; 2], From 29ad4e861a8e51e125e3d9eb42234c9b522db0a5 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 11 Nov 2022 12:32:46 +0100 Subject: [PATCH 04/20] Implement `MergeWith` for arrays --- crates/fj-kernel/src/partial/merge.rs | 14 ++++++++++++++ crates/fj-kernel/src/partial/mod.rs | 1 - crates/fj-kernel/src/partial/objects/edge.rs | 6 +++--- crates/fj-kernel/src/partial/util.rs | 13 ------------- 4 files changed, 17 insertions(+), 17 deletions(-) delete mode 100644 crates/fj-kernel/src/partial/util.rs diff --git a/crates/fj-kernel/src/partial/merge.rs b/crates/fj-kernel/src/partial/merge.rs index 5353e15d3..33e974a7e 100644 --- a/crates/fj-kernel/src/partial/merge.rs +++ b/crates/fj-kernel/src/partial/merge.rs @@ -1,3 +1,5 @@ +use iter_fixed::IntoIteratorFixed; + /// Trait for merging partial objects /// /// Implemented for all partial objects themselves, and also some related types @@ -12,6 +14,18 @@ pub trait MergeWith: Sized { fn merge_with(self, other: impl Into) -> Self; } +impl MergeWith for [T; N] +where + T: MergeWith, +{ + fn merge_with(self, other: impl Into) -> Self { + self.into_iter_fixed() + .zip(other.into()) + .collect::<[_; N]>() + .map(|(a, b)| a.merge_with(b)) + } +} + impl MergeWith for Option where T: PartialEq, diff --git a/crates/fj-kernel/src/partial/mod.rs b/crates/fj-kernel/src/partial/mod.rs index e0e941638..d09870ed9 100644 --- a/crates/fj-kernel/src/partial/mod.rs +++ b/crates/fj-kernel/src/partial/mod.rs @@ -38,7 +38,6 @@ mod maybe_partial; mod merge; mod objects; mod traits; -mod util; pub use self::{ maybe_partial::MaybePartial, diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index 6ea6776be..3b4d3ce74 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -6,7 +6,7 @@ use crate::{ Curve, GlobalCurve, GlobalEdge, GlobalVertex, HalfEdge, Objects, Surface, Vertex, }, - partial::{util::merge_arrays, MaybePartial, MergeWith}, + partial::{MaybePartial, MergeWith}, storage::Handle, validate::ValidationError, }; @@ -96,7 +96,7 @@ impl PartialHalfEdge { pub fn merge_with(self, other: Self) -> Self { Self { curve: self.curve.merge_with(other.curve), - vertices: merge_arrays(self.vertices, other.vertices), + vertices: self.vertices.merge_with(other.vertices), global_form: self.global_form.merge_with(other.global_form), } } @@ -182,7 +182,7 @@ impl PartialGlobalEdge { // redundant combination of `Option` and `MaybePartial`. There's some // code relying on that, however, so we have to live with it for now. let vertices = match (self.vertices, other.vertices) { - (Some(a), Some(b)) => Some(merge_arrays(a, b)), + (Some(a), Some(b)) => Some(a.merge_with(b)), (Some(vertices), None) | (None, Some(vertices)) => Some(vertices), (None, None) => None, }; diff --git a/crates/fj-kernel/src/partial/util.rs b/crates/fj-kernel/src/partial/util.rs deleted file mode 100644 index d86f8e82b..000000000 --- a/crates/fj-kernel/src/partial/util.rs +++ /dev/null @@ -1,13 +0,0 @@ -use iter_fixed::IntoIteratorFixed; - -use super::{HasPartial, MaybePartial, MergeWith}; - -pub fn merge_arrays( - a: [MaybePartial; 2], - b: [MaybePartial; 2], -) -> [MaybePartial; 2] { - a.into_iter_fixed() - .zip(b) - .collect::<[_; 2]>() - .map(|(a, b)| a.merge_with(b)) -} From 842a303d83ed9fd96d584058000ad32ec8f15a0d Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 11 Nov 2022 12:36:36 +0100 Subject: [PATCH 05/20] Implement `MergeWith` for `Handle` --- crates/fj-kernel/src/partial/maybe_partial.rs | 10 +--------- crates/fj-kernel/src/partial/merge.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/crates/fj-kernel/src/partial/maybe_partial.rs b/crates/fj-kernel/src/partial/maybe_partial.rs index f7ca6ca9e..84d24b938 100644 --- a/crates/fj-kernel/src/partial/maybe_partial.rs +++ b/crates/fj-kernel/src/partial/maybe_partial.rs @@ -114,15 +114,7 @@ where { fn merge_with(self, other: impl Into) -> Self { match (self, other.into()) { - (Self::Full(a), Self::Full(b)) => { - if a.id() != b.id() { - panic!("Can't merge two full objects") - } - - // If they're equal, which they are, if we reach this point, - // then merging them is a no-op. - Self::Full(a) - } + (Self::Full(a), Self::Full(b)) => Self::Full(a.merge_with(b)), (Self::Full(full), Self::Partial(_)) | (Self::Partial(_), Self::Full(full)) => Self::Full(full), (Self::Partial(a), Self::Partial(b)) => { diff --git a/crates/fj-kernel/src/partial/merge.rs b/crates/fj-kernel/src/partial/merge.rs index 33e974a7e..ce306e1b7 100644 --- a/crates/fj-kernel/src/partial/merge.rs +++ b/crates/fj-kernel/src/partial/merge.rs @@ -1,5 +1,7 @@ use iter_fixed::IntoIteratorFixed; +use crate::storage::Handle; + /// Trait for merging partial objects /// /// Implemented for all partial objects themselves, and also some related types @@ -55,3 +57,13 @@ where self.xor(other) } } + +impl MergeWith for Handle { + fn merge_with(self, other: impl Into) -> Self { + if self.id() == other.into().id() { + return self; + } + + panic!("Can't merge two distinct objects") + } +} From 1c51114963ed365e08b457a5fad71e4156ab6201 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 11 Nov 2022 12:42:00 +0100 Subject: [PATCH 06/20] Implement `MergeWith` for `PartialGlobalCurve` --- crates/fj-kernel/src/partial/objects/curve.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/partial/objects/curve.rs b/crates/fj-kernel/src/partial/objects/curve.rs index 6875f6eaf..03e8bfcdd 100644 --- a/crates/fj-kernel/src/partial/objects/curve.rs +++ b/crates/fj-kernel/src/partial/objects/curve.rs @@ -118,8 +118,8 @@ pub struct PartialGlobalCurve; impl PartialGlobalCurve { /// Merge this partial object with another - pub fn merge_with(self, _: Self) -> Self { - Self + pub fn merge_with(self, other: Self) -> Self { + ::merge_with(self, other) } /// Build a full [`GlobalCurve`] from the partial global curve @@ -128,6 +128,12 @@ impl PartialGlobalCurve { } } +impl MergeWith for PartialGlobalCurve { + fn merge_with(self, _: impl Into) -> Self { + Self + } +} + impl From<&GlobalCurve> for PartialGlobalCurve { fn from(_: &GlobalCurve) -> Self { Self From 35a20634ddb1a0d447a12a1d7ad5d168a21af1e8 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 11 Nov 2022 12:51:34 +0100 Subject: [PATCH 07/20] Implement `MergeWith` for `PartialHalfEdge` --- crates/fj-kernel/src/partial/objects/edge.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index 3b4d3ce74..b8d67623e 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -94,11 +94,7 @@ impl PartialHalfEdge { /// Merge this partial object with another pub fn merge_with(self, other: Self) -> Self { - Self { - curve: self.curve.merge_with(other.curve), - vertices: self.vertices.merge_with(other.vertices), - global_form: self.global_form.merge_with(other.global_form), - } + ::merge_with(self, other) } /// Build a full [`HalfEdge`] from the partial half-edge @@ -121,6 +117,18 @@ impl PartialHalfEdge { } } +impl MergeWith for PartialHalfEdge { + fn merge_with(self, other: impl Into) -> Self { + let other = other.into(); + + Self { + curve: self.curve.merge_with(other.curve), + vertices: self.vertices.merge_with(other.vertices), + global_form: self.global_form.merge_with(other.global_form), + } + } +} + impl From<&HalfEdge> for PartialHalfEdge { fn from(half_edge: &HalfEdge) -> Self { let [back_vertex, front_vertex] = From 343fae1a3fa938e4ad972f666d68cb2d4a959623 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 11 Nov 2022 12:53:11 +0100 Subject: [PATCH 08/20] Implement `MergeWith` for `PartialVertex` --- crates/fj-kernel/src/partial/objects/vertex.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/fj-kernel/src/partial/objects/vertex.rs b/crates/fj-kernel/src/partial/objects/vertex.rs index f8ce82ac8..49d964ced 100644 --- a/crates/fj-kernel/src/partial/objects/vertex.rs +++ b/crates/fj-kernel/src/partial/objects/vertex.rs @@ -62,11 +62,7 @@ impl PartialVertex { /// Merge this partial object with another pub fn merge_with(self, other: Self) -> Self { - Self { - position: self.position.merge_with(other.position), - curve: self.curve.merge_with(other.curve), - surface_form: self.surface_form.merge_with(other.surface_form), - } + ::merge_with(self, other) } /// Build a full [`Vertex`] from the partial vertex @@ -99,6 +95,18 @@ impl PartialVertex { } } +impl MergeWith for PartialVertex { + fn merge_with(self, other: impl Into) -> Self { + let other = other.into(); + + Self { + position: self.position.merge_with(other.position), + curve: self.curve.merge_with(other.curve), + surface_form: self.surface_form.merge_with(other.surface_form), + } + } +} + impl From<&Vertex> for PartialVertex { fn from(vertex: &Vertex) -> Self { Self { From 7e489c7413022f2749827af76f42a6afcbbf139c Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 11 Nov 2022 12:54:21 +0100 Subject: [PATCH 09/20] Implement `MergeWith` for `PartialSurfaceVertex` --- crates/fj-kernel/src/partial/objects/vertex.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/fj-kernel/src/partial/objects/vertex.rs b/crates/fj-kernel/src/partial/objects/vertex.rs index 49d964ced..80c53bf2b 100644 --- a/crates/fj-kernel/src/partial/objects/vertex.rs +++ b/crates/fj-kernel/src/partial/objects/vertex.rs @@ -175,11 +175,7 @@ impl PartialSurfaceVertex { /// Merge this partial object with another pub fn merge_with(self, other: Self) -> Self { - Self { - position: self.position.merge_with(other.position), - surface: self.surface.merge_with(other.surface), - global_form: self.global_form.merge_with(other.global_form), - } + ::merge_with(self, other) } /// Build a full [`SurfaceVertex`] from the partial surface vertex @@ -205,6 +201,18 @@ impl PartialSurfaceVertex { } } +impl MergeWith for PartialSurfaceVertex { + fn merge_with(self, other: impl Into) -> Self { + let other = other.into(); + + Self { + position: self.position.merge_with(other.position), + surface: self.surface.merge_with(other.surface), + global_form: self.global_form.merge_with(other.global_form), + } + } +} + impl From<&SurfaceVertex> for PartialSurfaceVertex { fn from(surface_vertex: &SurfaceVertex) -> Self { Self { From 2f93c4cb12fb670873a3acac3e8cbb4a64c7129f Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 11 Nov 2022 12:55:15 +0100 Subject: [PATCH 10/20] Implement `MergeWith` for `PartialGlobalVertex` --- crates/fj-kernel/src/partial/objects/vertex.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/fj-kernel/src/partial/objects/vertex.rs b/crates/fj-kernel/src/partial/objects/vertex.rs index 80c53bf2b..9190e2ecc 100644 --- a/crates/fj-kernel/src/partial/objects/vertex.rs +++ b/crates/fj-kernel/src/partial/objects/vertex.rs @@ -250,9 +250,7 @@ impl PartialGlobalVertex { /// Merge this partial object with another pub fn merge_with(self, other: Self) -> Self { - Self { - position: self.position.merge_with(other.position), - } + ::merge_with(self, other) } /// Build a full [`GlobalVertex`] from the partial global vertex @@ -265,6 +263,16 @@ impl PartialGlobalVertex { } } +impl MergeWith for PartialGlobalVertex { + fn merge_with(self, other: impl Into) -> Self { + let other = other.into(); + + Self { + position: self.position.merge_with(other.position), + } + } +} + impl From<&GlobalVertex> for PartialGlobalVertex { fn from(global_vertex: &GlobalVertex) -> Self { Self { From 12062ca475c8d175b315a514604f5a0d7b6a5c34 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 11 Nov 2022 13:40:42 +0100 Subject: [PATCH 11/20] Add `Mergeable` --- crates/fj-kernel/src/partial/merge.rs | 6 ++++++ crates/fj-kernel/src/partial/mod.rs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/partial/merge.rs b/crates/fj-kernel/src/partial/merge.rs index ce306e1b7..eea27a35f 100644 --- a/crates/fj-kernel/src/partial/merge.rs +++ b/crates/fj-kernel/src/partial/merge.rs @@ -16,6 +16,12 @@ pub trait MergeWith: Sized { fn merge_with(self, other: impl Into) -> Self; } +/// Wrapper struct that indicates that the contents can be merged +/// +/// Used in connection with [`MergeWith`] to select one implementation over +/// another. +pub struct Mergeable(pub T); + impl MergeWith for [T; N] where T: MergeWith, diff --git a/crates/fj-kernel/src/partial/mod.rs b/crates/fj-kernel/src/partial/mod.rs index d09870ed9..2f81c0d25 100644 --- a/crates/fj-kernel/src/partial/mod.rs +++ b/crates/fj-kernel/src/partial/mod.rs @@ -41,7 +41,7 @@ mod traits; pub use self::{ maybe_partial::MaybePartial, - merge::MergeWith, + merge::{MergeWith, Mergeable}, objects::{ curve::{PartialCurve, PartialGlobalCurve}, cycle::PartialCycle, From 28a1e30f1f50e0f9acfa5a2312596efcfa9d8cb6 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 11 Nov 2022 13:08:03 +0100 Subject: [PATCH 12/20] Implement `MergeWith` for `Mergeable>` --- crates/fj-kernel/src/partial/merge.rs | 29 ++++++++++++------- crates/fj-kernel/src/partial/objects/curve.rs | 17 +++-------- crates/fj-kernel/src/partial/objects/edge.rs | 15 +++------- 3 files changed, 27 insertions(+), 34 deletions(-) diff --git a/crates/fj-kernel/src/partial/merge.rs b/crates/fj-kernel/src/partial/merge.rs index eea27a35f..905d74be7 100644 --- a/crates/fj-kernel/src/partial/merge.rs +++ b/crates/fj-kernel/src/partial/merge.rs @@ -47,16 +47,6 @@ where // We know that `self != other`, or we wouldn't have made it here. if self.is_some() && other.is_some() { - // It would be great if we could optionally merge the two values - // recursively, if they support that, but that requires - // `specialization`: - // https://doc.rust-lang.org/nightly/unstable-book/language-features/specialization.html - // - // Or maybe `min_specialization`: - // https://doc.rust-lang.org/nightly/unstable-book/language-features/min-specialization.html - // - // Basically, we'd have one default implementation for all types, - // and a specialized one for `T: MergeWith`. panic!("Can't merge two `Option`s that are both `Some`") } @@ -64,6 +54,25 @@ where } } +// We wouldn't need to use `Mergeable` here, if we had `specialization`: +// https://doc.rust-lang.org/nightly/unstable-book/language-features/specialization.html +// +// Or maybe `min_specialization`: +// https://doc.rust-lang.org/nightly/unstable-book/language-features/min-specialization.html +impl MergeWith for Mergeable> +where + T: MergeWith, +{ + fn merge_with(self, other: impl Into) -> Self { + let merged = match (self.0, other.into().0) { + (Some(a), Some(b)) => Some(a.merge_with(b)), + (a, b) => a.xor(b), + }; + + Self(merged) + } +} + impl MergeWith for Handle { fn merge_with(self, other: impl Into) -> Self { if self.id() == other.into().id() { diff --git a/crates/fj-kernel/src/partial/objects/curve.rs b/crates/fj-kernel/src/partial/objects/curve.rs index 03e8bfcdd..1812a3a7a 100644 --- a/crates/fj-kernel/src/partial/objects/curve.rs +++ b/crates/fj-kernel/src/partial/objects/curve.rs @@ -1,6 +1,6 @@ use crate::{ objects::{Curve, GlobalCurve, Objects, Surface}, - partial::{MaybePartial, MergeWith}, + partial::{MaybePartial, MergeWith, Mergeable}, path::SurfacePath, storage::Handle, validate::ValidationError, @@ -61,21 +61,12 @@ impl PartialCurve { /// Merge this partial object with another pub fn merge_with(self, other: Self) -> Self { - // This is harder than it should be, as `global_form` uses the redundant - // `Option>` representation. There's some code relying - // on that though, so we have to live with it for now. - let global_form = match (self.global_form, other.global_form) { - (Some(a), Some(b)) => Some(a.merge_with(b)), - (Some(global_form), None) | (None, Some(global_form)) => { - Some(global_form) - } - (None, None) => None, - }; - Self { path: self.path.merge_with(other.path), surface: self.surface.merge_with(other.surface), - global_form, + global_form: Mergeable(self.global_form) + .merge_with(Mergeable(other.global_form)) + .0, } } diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index b8d67623e..315a24d77 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -6,7 +6,7 @@ use crate::{ Curve, GlobalCurve, GlobalEdge, GlobalVertex, HalfEdge, Objects, Surface, Vertex, }, - partial::{MaybePartial, MergeWith}, + partial::{MaybePartial, MergeWith, Mergeable}, storage::Handle, validate::ValidationError, }; @@ -186,18 +186,11 @@ impl PartialGlobalEdge { /// Merge this partial object with another pub fn merge_with(self, other: Self) -> Self { - // This is harder than it needs to be, because `vertices` uses the - // redundant combination of `Option` and `MaybePartial`. There's some - // code relying on that, however, so we have to live with it for now. - let vertices = match (self.vertices, other.vertices) { - (Some(a), Some(b)) => Some(a.merge_with(b)), - (Some(vertices), None) | (None, Some(vertices)) => Some(vertices), - (None, None) => None, - }; - Self { curve: self.curve.merge_with(other.curve), - vertices, + vertices: Mergeable(self.vertices) + .merge_with(Mergeable(other.vertices)) + .0, } } From d75e18d23ccea9d034324116df8244933165e0d6 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 11 Nov 2022 13:10:55 +0100 Subject: [PATCH 13/20] Implement `MergeWith` for `PartialCurve` --- crates/fj-kernel/src/partial/objects/curve.rs | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/crates/fj-kernel/src/partial/objects/curve.rs b/crates/fj-kernel/src/partial/objects/curve.rs index 1812a3a7a..c073106e8 100644 --- a/crates/fj-kernel/src/partial/objects/curve.rs +++ b/crates/fj-kernel/src/partial/objects/curve.rs @@ -61,13 +61,7 @@ impl PartialCurve { /// Merge this partial object with another pub fn merge_with(self, other: Self) -> Self { - Self { - path: self.path.merge_with(other.path), - surface: self.surface.merge_with(other.surface), - global_form: Mergeable(self.global_form) - .merge_with(Mergeable(other.global_form)) - .0, - } + ::merge_with(self, other) } /// Build a full [`Curve`] from the partial curve @@ -86,6 +80,20 @@ impl PartialCurve { } } +impl MergeWith for PartialCurve { + fn merge_with(self, other: impl Into) -> Self { + let other = other.into(); + + Self { + path: self.path.merge_with(other.path), + surface: self.surface.merge_with(other.surface), + global_form: Mergeable(self.global_form) + .merge_with(Mergeable(other.global_form)) + .0, + } + } +} + impl From<&Curve> for PartialCurve { fn from(curve: &Curve) -> Self { Self { From 6f106eefa79c73500036583a8060828069a59573 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 11 Nov 2022 13:26:23 +0100 Subject: [PATCH 14/20] Implement `MergeWith` for `Vec` --- crates/fj-kernel/src/partial/merge.rs | 15 +++++++++++++++ crates/fj-kernel/src/partial/objects/cycle.rs | 13 +------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/crates/fj-kernel/src/partial/merge.rs b/crates/fj-kernel/src/partial/merge.rs index 905d74be7..715977238 100644 --- a/crates/fj-kernel/src/partial/merge.rs +++ b/crates/fj-kernel/src/partial/merge.rs @@ -73,6 +73,21 @@ where } } +impl MergeWith for Vec { + fn merge_with(self, other: impl Into) -> Self { + let other = other.into(); + + match (self.is_empty(), other.is_empty()) { + (true, true) => { + panic!("Can't merge `PartialHalfEdge`, if both have half-edges") + } + (true, false) => other, + (false, true) => self, + (false, false) => self, // doesn't matter which we use + } + } +} + impl MergeWith for Handle { fn merge_with(self, other: impl Into) -> Self { if self.id() == other.into().id() { diff --git a/crates/fj-kernel/src/partial/objects/cycle.rs b/crates/fj-kernel/src/partial/objects/cycle.rs index a543dc7a7..1795362cf 100644 --- a/crates/fj-kernel/src/partial/objects/cycle.rs +++ b/crates/fj-kernel/src/partial/objects/cycle.rs @@ -66,18 +66,7 @@ impl PartialCycle { /// Merge this partial object with another pub fn merge_with(self, other: Self) -> Self { - let a_is_empty = self.half_edges.is_empty(); - let b_is_empty = other.half_edges.is_empty(); - let half_edges = match (a_is_empty, b_is_empty) { - (true, true) => { - panic!("Can't merge `PartialHalfEdge`, if both have half-edges") - } - (true, false) => self.half_edges, - (false, true) => other.half_edges, - (false, false) => self.half_edges, // doesn't matter which we use - }; - - Self { half_edges } + Self { half_edges: self.half_edges.merge_with(other.half_edges) } } /// Build a full [`Cycle`] from the partial cycle From f054664766d631e7764814cf4a56d5a12804279a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 11 Nov 2022 13:27:19 +0100 Subject: [PATCH 15/20] Implement `MergeWith` for `PartialCycle` --- crates/fj-kernel/src/partial/objects/cycle.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/partial/objects/cycle.rs b/crates/fj-kernel/src/partial/objects/cycle.rs index 1795362cf..38b1b0e14 100644 --- a/crates/fj-kernel/src/partial/objects/cycle.rs +++ b/crates/fj-kernel/src/partial/objects/cycle.rs @@ -66,7 +66,7 @@ impl PartialCycle { /// Merge this partial object with another pub fn merge_with(self, other: Self) -> Self { - Self { half_edges: self.half_edges.merge_with(other.half_edges) } + ::merge_with(self, other) } /// Build a full [`Cycle`] from the partial cycle @@ -133,6 +133,16 @@ impl PartialCycle { } } +impl MergeWith for PartialCycle { + fn merge_with(self, other: impl Into) -> Self { + let other = other.into(); + + Self { + half_edges: self.half_edges.merge_with(other.half_edges), + } + } +} + impl From<&Cycle> for PartialCycle { fn from(cycle: &Cycle) -> Self { Self { From fb1e2ca71edf064cc0763ce8981ca81bfa97706a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 11 Nov 2022 13:30:02 +0100 Subject: [PATCH 16/20] Implement `MergeWith` for `PartialGlobalEdge` --- crates/fj-kernel/src/partial/objects/edge.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index 315a24d77..e0ecd28f3 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -186,12 +186,7 @@ impl PartialGlobalEdge { /// Merge this partial object with another pub fn merge_with(self, other: Self) -> Self { - Self { - curve: self.curve.merge_with(other.curve), - vertices: Mergeable(self.vertices) - .merge_with(Mergeable(other.vertices)) - .0, - } + ::merge_with(self, other) } /// Build a full [`GlobalEdge`] from the partial global edge @@ -209,6 +204,19 @@ impl PartialGlobalEdge { } } +impl MergeWith for PartialGlobalEdge { + fn merge_with(self, other: impl Into) -> Self { + let other = other.into(); + + Self { + curve: self.curve.merge_with(other.curve), + vertices: Mergeable(self.vertices) + .merge_with(Mergeable(other.vertices)) + .0, + } + } +} + impl From<&GlobalEdge> for PartialGlobalEdge { fn from(global_edge: &GlobalEdge) -> Self { Self { From 80f21489f55ede2fad61dca35b31db05ca8dc450 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 11 Nov 2022 13:33:56 +0100 Subject: [PATCH 17/20] Implement `MergeWith` for `Mergeable>` --- crates/fj-kernel/src/partial/merge.rs | 7 +++++++ crates/fj-kernel/src/partial/objects/face.rs | 9 ++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/fj-kernel/src/partial/merge.rs b/crates/fj-kernel/src/partial/merge.rs index 715977238..dac76cf55 100644 --- a/crates/fj-kernel/src/partial/merge.rs +++ b/crates/fj-kernel/src/partial/merge.rs @@ -88,6 +88,13 @@ impl MergeWith for Vec { } } +impl MergeWith for Mergeable> { + fn merge_with(mut self, other: impl Into) -> Self { + self.0.extend(other.into().0); + self + } +} + impl MergeWith for Handle { fn merge_with(self, other: impl Into) -> Self { if self.id() == other.into().id() { diff --git a/crates/fj-kernel/src/partial/objects/face.rs b/crates/fj-kernel/src/partial/objects/face.rs index 0b48d1f58..f37dd40f5 100644 --- a/crates/fj-kernel/src/partial/objects/face.rs +++ b/crates/fj-kernel/src/partial/objects/face.rs @@ -2,7 +2,7 @@ use fj_interop::mesh::Color; use crate::{ objects::{Cycle, Face, Objects, Surface}, - partial::{MaybePartial, MergeWith}, + partial::{MaybePartial, MergeWith, Mergeable}, storage::Handle, validate::ValidationError, }; @@ -72,13 +72,12 @@ impl PartialFace { /// Merge this partial object with another pub fn merge_with(self, other: Self) -> Self { - let mut interiors = self.interiors; - interiors.extend(other.interiors); - Self { surface: self.surface.merge_with(other.surface), exterior: self.exterior.merge_with(other.exterior), - interiors, + interiors: Mergeable(self.interiors) + .merge_with(Mergeable(other.interiors)) + .0, color: self.color.merge_with(other.color), } } From e73f8202cf63bd37e0169fbc25806899e48887c2 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 11 Nov 2022 13:35:04 +0100 Subject: [PATCH 18/20] Implement `MergeWith` for `PartialFace` --- crates/fj-kernel/src/partial/objects/face.rs | 24 +++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/crates/fj-kernel/src/partial/objects/face.rs b/crates/fj-kernel/src/partial/objects/face.rs index f37dd40f5..e96bcf4d4 100644 --- a/crates/fj-kernel/src/partial/objects/face.rs +++ b/crates/fj-kernel/src/partial/objects/face.rs @@ -72,14 +72,7 @@ impl PartialFace { /// Merge this partial object with another pub fn merge_with(self, other: Self) -> Self { - Self { - surface: self.surface.merge_with(other.surface), - exterior: self.exterior.merge_with(other.exterior), - interiors: Mergeable(self.interiors) - .merge_with(Mergeable(other.interiors)) - .0, - color: self.color.merge_with(other.color), - } + ::merge_with(self, other) } /// Construct a polygon from a list of points @@ -96,6 +89,21 @@ impl PartialFace { } } +impl MergeWith for PartialFace { + fn merge_with(self, other: impl Into) -> Self { + let other = other.into(); + + Self { + surface: self.surface.merge_with(other.surface), + exterior: self.exterior.merge_with(other.exterior), + interiors: Mergeable(self.interiors) + .merge_with(Mergeable(other.interiors)) + .0, + color: self.color.merge_with(other.color), + } + } +} + impl From<&Face> for PartialFace { fn from(face: &Face) -> Self { Self { From 88bc99e13e20eeedcc814698dac1dcb22822d26c Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 11 Nov 2022 13:36:55 +0100 Subject: [PATCH 19/20] Use `MergeWith` recursively in `MaybePartial` impl --- crates/fj-kernel/src/partial/maybe_partial.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/fj-kernel/src/partial/maybe_partial.rs b/crates/fj-kernel/src/partial/maybe_partial.rs index 84d24b938..03caa5e6c 100644 --- a/crates/fj-kernel/src/partial/maybe_partial.rs +++ b/crates/fj-kernel/src/partial/maybe_partial.rs @@ -111,6 +111,7 @@ where impl MergeWith for MaybePartial where T: HasPartial, + T::Partial: MergeWith, { fn merge_with(self, other: impl Into) -> Self { match (self, other.into()) { From fd1b7deba759b3e98dc5c55c47047d7f75b03fe2 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 11 Nov 2022 13:37:15 +0100 Subject: [PATCH 20/20] Remove redundant code --- crates/fj-kernel/src/partial/objects/curve.rs | 10 ---------- crates/fj-kernel/src/partial/objects/cycle.rs | 5 ----- crates/fj-kernel/src/partial/objects/edge.rs | 10 ---------- crates/fj-kernel/src/partial/objects/face.rs | 5 ----- crates/fj-kernel/src/partial/objects/mod.rs | 4 ---- crates/fj-kernel/src/partial/objects/vertex.rs | 15 --------------- crates/fj-kernel/src/partial/traits.rs | 3 --- 7 files changed, 52 deletions(-) diff --git a/crates/fj-kernel/src/partial/objects/curve.rs b/crates/fj-kernel/src/partial/objects/curve.rs index c073106e8..233b6b2c7 100644 --- a/crates/fj-kernel/src/partial/objects/curve.rs +++ b/crates/fj-kernel/src/partial/objects/curve.rs @@ -59,11 +59,6 @@ impl PartialCurve { self } - /// Merge this partial object with another - pub fn merge_with(self, other: Self) -> Self { - ::merge_with(self, other) - } - /// Build a full [`Curve`] from the partial curve pub fn build(self, objects: &Objects) -> Result { let path = self.path.expect("Can't build `Curve` without path"); @@ -116,11 +111,6 @@ impl From<&Curve> for PartialCurve { pub struct PartialGlobalCurve; impl PartialGlobalCurve { - /// Merge this partial object with another - pub fn merge_with(self, other: Self) -> Self { - ::merge_with(self, other) - } - /// Build a full [`GlobalCurve`] from the partial global curve pub fn build(self, _: &Objects) -> Result { Ok(GlobalCurve) diff --git a/crates/fj-kernel/src/partial/objects/cycle.rs b/crates/fj-kernel/src/partial/objects/cycle.rs index 38b1b0e14..a802133e3 100644 --- a/crates/fj-kernel/src/partial/objects/cycle.rs +++ b/crates/fj-kernel/src/partial/objects/cycle.rs @@ -64,11 +64,6 @@ impl PartialCycle { self } - /// Merge this partial object with another - pub fn merge_with(self, other: Self) -> Self { - ::merge_with(self, other) - } - /// Build a full [`Cycle`] from the partial cycle pub fn build( mut self, diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index e0ecd28f3..40e32906e 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -92,11 +92,6 @@ impl PartialHalfEdge { self } - /// Merge this partial object with another - pub fn merge_with(self, other: Self) -> Self { - ::merge_with(self, other) - } - /// Build a full [`HalfEdge`] from the partial half-edge pub fn build(self, objects: &Objects) -> Result { let curve = self.curve.into_full(objects)?; @@ -184,11 +179,6 @@ impl PartialGlobalEdge { self } - /// Merge this partial object with another - pub fn merge_with(self, other: Self) -> Self { - ::merge_with(self, other) - } - /// Build a full [`GlobalEdge`] from the partial global edge pub fn build( self, diff --git a/crates/fj-kernel/src/partial/objects/face.rs b/crates/fj-kernel/src/partial/objects/face.rs index e96bcf4d4..02d837484 100644 --- a/crates/fj-kernel/src/partial/objects/face.rs +++ b/crates/fj-kernel/src/partial/objects/face.rs @@ -70,11 +70,6 @@ impl PartialFace { self } - /// Merge this partial object with another - pub fn merge_with(self, other: Self) -> Self { - ::merge_with(self, other) - } - /// Construct a polygon from a list of points pub fn build(self, objects: &Objects) -> Result { let exterior = self.exterior.into_full(objects)?; diff --git a/crates/fj-kernel/src/partial/objects/mod.rs b/crates/fj-kernel/src/partial/objects/mod.rs index 277752a94..917f53a56 100644 --- a/crates/fj-kernel/src/partial/objects/mod.rs +++ b/crates/fj-kernel/src/partial/objects/mod.rs @@ -25,10 +25,6 @@ macro_rules! impl_traits { impl Partial for $partial { type Full = $full; - fn merge_with(self, other: Self) -> Self { - self.merge_with(other) - } - fn build(self, objects: &Objects) -> Result< Self::Full, diff --git a/crates/fj-kernel/src/partial/objects/vertex.rs b/crates/fj-kernel/src/partial/objects/vertex.rs index 9190e2ecc..eaa7ac355 100644 --- a/crates/fj-kernel/src/partial/objects/vertex.rs +++ b/crates/fj-kernel/src/partial/objects/vertex.rs @@ -60,11 +60,6 @@ impl PartialVertex { self } - /// Merge this partial object with another - pub fn merge_with(self, other: Self) -> Self { - ::merge_with(self, other) - } - /// Build a full [`Vertex`] from the partial vertex /// /// # Panics @@ -173,11 +168,6 @@ impl PartialSurfaceVertex { self } - /// Merge this partial object with another - pub fn merge_with(self, other: Self) -> Self { - ::merge_with(self, other) - } - /// Build a full [`SurfaceVertex`] from the partial surface vertex pub fn build( self, @@ -248,11 +238,6 @@ impl PartialGlobalVertex { self } - /// Merge this partial object with another - pub fn merge_with(self, other: Self) -> Self { - ::merge_with(self, other) - } - /// Build a full [`GlobalVertex`] from the partial global vertex pub fn build(self, _: &Objects) -> Result { let position = self diff --git a/crates/fj-kernel/src/partial/traits.rs b/crates/fj-kernel/src/partial/traits.rs index c0b1a1d54..3b149317b 100644 --- a/crates/fj-kernel/src/partial/traits.rs +++ b/crates/fj-kernel/src/partial/traits.rs @@ -68,9 +68,6 @@ pub trait Partial: Default + for<'a> From<&'a Self::Full> { /// The type representing the full variant of this object type Full; - /// Merge another partial object of the same type into this one - fn merge_with(self, other: Self) -> Self; - /// Build a full object from this partial one /// /// Implementations of this method will typically try to infer any missing