diff --git a/src/kernel/algorithms/sweep.rs b/src/kernel/algorithms/sweep.rs index 8b006fe7b..cad604db5 100644 --- a/src/kernel/algorithms/sweep.rs +++ b/src/kernel/algorithms/sweep.rs @@ -53,7 +53,7 @@ pub fn sweep_shape( } for face in bottom_faces { - shape.faces().add(face); + shape.faces().add((*face).clone()); } for face in top_faces { shape.faces().add(face); diff --git a/src/kernel/shape/faces.rs b/src/kernel/shape/faces.rs index 0c177317b..e1c8b3787 100644 --- a/src/kernel/shape/faces.rs +++ b/src/kernel/shape/faces.rs @@ -17,19 +17,23 @@ pub struct Faces<'r> { impl Faces<'_> { /// Add a face to the shape pub fn add(&mut self, face: Face) -> Handle { - self.faces.push(face.clone()); - Storage::new(face).handle() + let storage = Storage::new(face); + let handle = storage.handle(); + + self.faces.push(storage); + + handle } /// Check whether the shape contains a specific face #[cfg(test)] pub fn contains(&self, face: &Face) -> bool { - self.faces.contains(face) + self.faces.contains(&Storage::new(face.clone())) } /// Access an iterator over all faces - pub fn all(&self) -> impl Iterator + '_ { - self.faces.iter().cloned() + pub fn all(&self) -> impl Iterator> + '_ { + self.faces.iter().map(|storage| storage.handle()) } pub fn triangles( diff --git a/src/kernel/shape/mod.rs b/src/kernel/shape/mod.rs index 95e1786bd..1c37ddcfb 100644 --- a/src/kernel/shape/mod.rs +++ b/src/kernel/shape/mod.rs @@ -92,4 +92,4 @@ impl Shape { type VerticesInner = Vec>; type CyclesInner = Vec>; -type FacesInner = Vec; +type FacesInner = Vec>; diff --git a/src/kernel/shapes/difference_2d.rs b/src/kernel/shapes/difference_2d.rs index 80ff5dfc2..c1eac9f4c 100644 --- a/src/kernel/shapes/difference_2d.rs +++ b/src/kernel/shapes/difference_2d.rs @@ -56,22 +56,23 @@ impl ToShape for fj::Difference2d { ); }; - let (a, b, surface_a, surface_b) = match (a, b) { - ( - Face::Face { - cycles: a, - surface: surface_a, - }, - Face::Face { - cycles: b, - surface: surface_b, - }, - ) => (a, b, surface_a, surface_b), - _ => { - // None of the 2D types still use the triangles representation. - unreachable!() - } - }; + let (a, b, surface_a, surface_b) = + match ((*a).clone(), (*b).clone()) { + ( + Face::Face { + cycles: a, + surface: surface_a, + }, + Face::Face { + cycles: b, + surface: surface_b, + }, + ) => (a, b, surface_a, surface_b), + _ => { + // None of the 2D types still use the triangles representation. + unreachable!() + } + }; assert!( surface_a == surface_b, diff --git a/src/kernel/shapes/union.rs b/src/kernel/shapes/union.rs index 5b6a5cee3..8147510fc 100644 --- a/src/kernel/shapes/union.rs +++ b/src/kernel/shapes/union.rs @@ -19,10 +19,10 @@ impl ToShape for fj::Union { // See issue: // https://github.com/hannobraun/Fornjot/issues/42 for face in a.faces().all() { - shape.faces().add(face); + shape.faces().add((*face).clone()); } for face in b.faces().all() { - shape.faces().add(face); + shape.faces().add((*face).clone()); } shape