diff --git a/crates/fj-kernel/src/objects/edge.rs b/crates/fj-kernel/src/objects/edge.rs index a82f0b795..39749cb3e 100644 --- a/crates/fj-kernel/src/objects/edge.rs +++ b/crates/fj-kernel/src/objects/edge.rs @@ -56,12 +56,10 @@ impl HalfEdge { assert_eq!( vertices_in_normalized_order .access_in_normalized_order() - .clone() .map(|global_vertex| global_vertex.id()), global_form .vertices() .access_in_normalized_order() - .clone() .map(|global_vertex| global_vertex.id()), "The global forms of a half-edge's vertices must match the \ vertices of the half-edge's global form" @@ -192,8 +190,8 @@ impl VerticesInNormalizedOrder { /// Access the vertices /// /// The vertices in the returned array will be in normalized order. - pub fn access_in_normalized_order(&self) -> &[Handle; 2] { - &self.0 + pub fn access_in_normalized_order(&self) -> [Handle; 2] { + self.0.clone() } } diff --git a/crates/fj-kernel/src/partial/maybe_partial.rs b/crates/fj-kernel/src/partial/maybe_partial.rs index 647038d4e..71406b779 100644 --- a/crates/fj-kernel/src/partial/maybe_partial.rs +++ b/crates/fj-kernel/src/partial/maybe_partial.rs @@ -118,12 +118,12 @@ impl MaybePartial { } /// Access the vertices - pub fn vertices(&self) -> Option<&[Handle; 2]> { + pub fn vertices(&self) -> Option<[MaybePartial; 2]> { match self { - Self::Full(full) => { - Some(full.vertices().access_in_normalized_order()) - } - Self::Partial(partial) => partial.vertices.as_ref(), + Self::Full(full) => Some( + full.vertices().access_in_normalized_order().map(Into::into), + ), + Self::Partial(partial) => partial.vertices.clone(), } } } diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index 669ca7986..5faf78ef3 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -42,8 +42,10 @@ impl PartialHalfEdge { } /// Access the vertices of the global form, if available - pub fn extract_global_vertices(&self) -> Option<[Handle; 2]> { - self.global_form.vertices().cloned() + pub fn extract_global_vertices( + &self, + ) -> Option<[MaybePartial; 2]> { + self.global_form.vertices() } /// Update the partial half-edge with the given surface @@ -136,7 +138,7 @@ impl PartialHalfEdge { let global_vertex = self .extract_global_vertices() - .map(|[global_form, _]| MaybePartial::from(global_form)) + .map(|[global_form, _]| global_form) .unwrap_or_else(|| { GlobalVertex::partial() .from_curve_and_position(curve.clone(), a_curve) @@ -320,7 +322,7 @@ pub struct PartialGlobalEdge { /// The vertices that bound the [`GlobalEdge`] in the curve /// /// Must be provided before [`PartialGlobalEdge::build`] is called. - pub vertices: Option<[Handle; 2]>, + pub vertices: Option<[MaybePartial; 2]>, } impl PartialGlobalEdge { @@ -335,10 +337,10 @@ impl PartialGlobalEdge { /// Update the partial global edge with the given vertices pub fn with_vertices( mut self, - vertices: Option<[Handle; 2]>, + vertices: Option<[impl Into>; 2]>, ) -> Self { if let Some(vertices) = vertices { - self.vertices = Some(vertices); + self.vertices = Some(vertices.map(Into::into)); } self } @@ -365,7 +367,8 @@ impl PartialGlobalEdge { .expect("Can't build `GlobalEdge` without `GlobalCurve`"); let vertices = self .vertices - .expect("Can't build `GlobalEdge` without vertices"); + .expect("Can't build `GlobalEdge` without vertices") + .try_map_ext(|global_vertex| global_vertex.into_full(objects))?; Ok(objects .global_edges @@ -378,7 +381,10 @@ impl From<&GlobalEdge> for PartialGlobalEdge { Self { curve: Some(global_edge.curve().clone().into()), vertices: Some( - global_edge.vertices().access_in_normalized_order().clone(), + global_edge + .vertices() + .access_in_normalized_order() + .map(Into::into), ), } }