Convert tuple struct into regular struct

This commit is contained in:
Hanno Braun 2022-03-08 13:55:22 +01:00
parent 98c28517cc
commit d7a8a2935b
2 changed files with 8 additions and 6 deletions

View File

@ -8,24 +8,26 @@ use super::handle::{Handle, Storage};
/// The faces of a shape
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct Faces(pub(super) Vec<Face>);
pub struct Faces {
pub(super) faces: Vec<Face>,
}
impl Faces {
/// Add a face to the shape
pub fn add(&mut self, face: Face) -> Handle<Face> {
self.0.push(face.clone());
self.faces.push(face.clone());
Storage::new(face).handle()
}
/// Check whether the shape contains a specific face
#[cfg(test)]
pub fn contains(&self, face: &Face) -> bool {
self.0.contains(face)
self.faces.contains(face)
}
/// Access an iterator over all faces
pub fn all(&self) -> impl Iterator<Item = Face> + '_ {
self.0.iter().cloned()
self.faces.iter().cloned()
}
pub fn triangles(
@ -34,7 +36,7 @@ impl Faces {
out: &mut Vec<Triangle<3>>,
debug_info: &mut DebugInfo,
) {
for face in &self.0 {
for face in &self.faces {
face.triangles(tolerance, out, debug_info);
}
}

View File

@ -43,7 +43,7 @@ impl Shape {
vertices: VerticesInner::new(),
cycles: CyclesInner::new(),
faces: Faces(Vec::new()),
faces: Faces { faces: Vec::new() },
}
}