From 61bc5afd393a59d3650a475f5310d92e04412022 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 9 Sep 2022 15:30:05 +0200 Subject: [PATCH 1/3] Add `Faces::find` --- crates/fj-kernel/src/objects/face.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/fj-kernel/src/objects/face.rs b/crates/fj-kernel/src/objects/face.rs index 4ff8d86fd..0bedae194 100644 --- a/crates/fj-kernel/src/objects/face.rs +++ b/crates/fj-kernel/src/objects/face.rs @@ -18,6 +18,17 @@ impl Faces { pub fn new() -> Self { Self::default() } + + /// Find the given face + pub fn find(&self, face: &Face) -> Option { + for f in self { + if f == face { + return Some(f.clone()); + } + } + + None + } } impl Extend for Faces { From 2453730f7c73f766093e9a739a94e6fd4d73506b Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 9 Sep 2022 15:30:31 +0200 Subject: [PATCH 2/3] Add `Shell::find_face` --- crates/fj-kernel/src/objects/shell.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/fj-kernel/src/objects/shell.rs b/crates/fj-kernel/src/objects/shell.rs index eff78abf5..adf917335 100644 --- a/crates/fj-kernel/src/objects/shell.rs +++ b/crates/fj-kernel/src/objects/shell.rs @@ -47,6 +47,11 @@ impl Shell { pub fn into_faces(self) -> Faces { self.faces } + + /// Find the given face in this shell + pub fn find_face(&self, face: &Face) -> Option { + self.faces().find(face) + } } impl Default for Shell { From 05aa620e85b694a7e16b2c746dcfdc41bed092dd Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 9 Sep 2022 15:30:49 +0200 Subject: [PATCH 3/3] Add `Solid::find_face` --- crates/fj-kernel/src/objects/solid.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/objects/solid.rs b/crates/fj-kernel/src/objects/solid.rs index 18558937b..e5b2f0e86 100644 --- a/crates/fj-kernel/src/objects/solid.rs +++ b/crates/fj-kernel/src/objects/solid.rs @@ -2,7 +2,7 @@ use std::collections::BTreeSet; use crate::builder::SolidBuilder; -use super::Shell; +use super::{Face, Shell}; /// A 3-dimensional shape /// @@ -49,6 +49,17 @@ impl Solid { pub fn into_shells(self) -> impl Iterator { self.shells.into_iter() } + + /// Find the given face in this solid + pub fn find_face(&self, face: &Face) -> Option { + for shell in self.shells() { + if let Some(face) = shell.find_face(face) { + return Some(face); + } + } + + None + } } impl Default for Solid {