mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-26 17:15:52 +00:00
Store faces in Storage
This commit is contained in:
parent
4d5a279f71
commit
2aeb724992
@ -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);
|
||||
|
@ -17,19 +17,23 @@ pub struct Faces<'r> {
|
||||
impl Faces<'_> {
|
||||
/// Add a face to the shape
|
||||
pub fn add(&mut self, face: Face) -> Handle<Face> {
|
||||
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<Item = Face> + '_ {
|
||||
self.faces.iter().cloned()
|
||||
pub fn all(&self) -> impl Iterator<Item = Handle<Face>> + '_ {
|
||||
self.faces.iter().map(|storage| storage.handle())
|
||||
}
|
||||
|
||||
pub fn triangles(
|
||||
|
@ -92,4 +92,4 @@ impl Shape {
|
||||
|
||||
type VerticesInner = Vec<Storage<Vertex>>;
|
||||
type CyclesInner = Vec<Storage<Cycle>>;
|
||||
type FacesInner = Vec<Face>;
|
||||
type FacesInner = Vec<Storage<Face>>;
|
||||
|
@ -56,7 +56,8 @@ impl ToShape for fj::Difference2d {
|
||||
);
|
||||
};
|
||||
|
||||
let (a, b, surface_a, surface_b) = match (a, b) {
|
||||
let (a, b, surface_a, surface_b) =
|
||||
match ((*a).clone(), (*b).clone()) {
|
||||
(
|
||||
Face::Face {
|
||||
cycles: a,
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user