Merge pull request #1830 from hannobraun/cleanup

Make some cleanups
This commit is contained in:
Hanno Braun 2023-05-22 13:10:03 +02:00 committed by GitHub
commit b28cf86d49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 3 additions and 35 deletions

View File

@ -28,12 +28,12 @@ impl Region {
/// Construct an instance of `Region` /// Construct an instance of `Region`
pub fn new( pub fn new(
exterior: Handle<Cycle>, exterior: Handle<Cycle>,
interiors: Vec<Handle<Cycle>>, interiors: impl IntoIterator<Item = Handle<Cycle>>,
color: Option<Color>, color: Option<Color>,
) -> Self { ) -> Self {
Self { Self {
exterior, exterior,
interiors, interiors: interiors.into_iter().collect(),
color, color,
} }
} }

View File

@ -47,8 +47,6 @@ impl Face {
interiors: impl IntoIterator<Item = Handle<Cycle>>, interiors: impl IntoIterator<Item = Handle<Cycle>>,
color: Option<Color>, color: Option<Color>,
) -> Self { ) -> Self {
let interiors = interiors.into_iter().collect();
Self { Self {
surface, surface,
region: Region::new(exterior, interiors, color), region: Region::new(exterior, interiors, color),
@ -111,17 +109,6 @@ impl FaceSet {
pub fn new() -> Self { pub fn new() -> Self {
Self::default() Self::default()
} }
/// Find the given face
pub fn find(&self, face: &Handle<Face>) -> Option<Handle<Face>> {
for f in self {
if f == face {
return Some(f.clone());
}
}
None
}
} }
impl Extend<Handle<Face>> for FaceSet { impl Extend<Handle<Face>> for FaceSet {

View File

@ -26,9 +26,4 @@ impl Shell {
pub fn faces(&self) -> &FaceSet { pub fn faces(&self) -> &FaceSet {
&self.faces &self.faces
} }
/// Find the given face in the shell
pub fn find_face(&self, face: &Handle<Face>) -> Option<Handle<Face>> {
self.faces().find(face)
}
} }

View File

@ -1,9 +1,6 @@
use std::collections::BTreeSet; use std::collections::BTreeSet;
use crate::{ use crate::{objects::Shell, storage::Handle};
objects::{Face, Shell},
storage::Handle,
};
/// A 3-dimensional shape, built from [`Shell`]s. Many Solids will contains only /// A 3-dimensional shape, built from [`Shell`]s. Many Solids will contains only
/// one shell, but if the Solid contains cavities they will be represented by a /// one shell, but if the Solid contains cavities they will be represented by a
@ -30,15 +27,4 @@ impl Solid {
pub fn shells(&self) -> impl Iterator<Item = &Handle<Shell>> { pub fn shells(&self) -> impl Iterator<Item = &Handle<Shell>> {
self.shells.iter() self.shells.iter()
} }
/// Find the given face in the solid
pub fn find_face(&self, face: &Handle<Face>) -> Option<Handle<Face>> {
for shell in self.shells() {
if let Some(face) = shell.find_face(face) {
return Some(face);
}
}
None
}
} }