From 6a0e1b9719061253e4cbca5085e5334e2dfc1ed4 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Wed, 13 Jul 2022 17:57:23 +0200 Subject: [PATCH 1/3] Add `CurveFaceIntersectionList::is_empty` --- crates/fj-kernel/src/algorithms/intersection/curve_face.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/fj-kernel/src/algorithms/intersection/curve_face.rs b/crates/fj-kernel/src/algorithms/intersection/curve_face.rs index e8334460b..c33dff638 100644 --- a/crates/fj-kernel/src/algorithms/intersection/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersection/curve_face.rs @@ -159,6 +159,11 @@ impl CurveFaceIntersectionList { Self { intervals } } + + /// Indicate whether the intersection list is empty + pub fn is_empty(&self) -> bool { + self.intervals.is_empty() + } } #[cfg(test)] From abc4f291ff11bb2a0fc6f2681fbb723373926d3c Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 14 Jul 2022 14:24:24 +0200 Subject: [PATCH 2/3] Add `CurveFaceIntersection` --- crates/fj-kernel/src/algorithms/intersection/curve_face.rs | 5 ++++- crates/fj-kernel/src/algorithms/intersection/mod.rs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersection/curve_face.rs b/crates/fj-kernel/src/algorithms/intersection/curve_face.rs index c33dff638..162bf5f08 100644 --- a/crates/fj-kernel/src/algorithms/intersection/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersection/curve_face.rs @@ -6,7 +6,7 @@ use crate::objects::{Curve, Face}; /// The intersections between a [`Curve`] and a [`Face`], in curve coordinates #[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] pub struct CurveFaceIntersectionList { - intervals: Vec<[Scalar; 2]>, + intervals: Vec, } impl CurveFaceIntersectionList { @@ -166,6 +166,9 @@ impl CurveFaceIntersectionList { } } +/// An intersection between a curve and a face, in curve coordinates +pub type CurveFaceIntersection = [Scalar; 2]; + #[cfg(test)] mod tests { use fj_math::{Line, Point, Vector}; diff --git a/crates/fj-kernel/src/algorithms/intersection/mod.rs b/crates/fj-kernel/src/algorithms/intersection/mod.rs index 109177f97..a67988b48 100644 --- a/crates/fj-kernel/src/algorithms/intersection/mod.rs +++ b/crates/fj-kernel/src/algorithms/intersection/mod.rs @@ -5,7 +5,7 @@ mod line_segment; mod surface_surface; pub use self::{ - curve_face::CurveFaceIntersectionList, + curve_face::{CurveFaceIntersection, CurveFaceIntersectionList}, line_segment::{line_segment, LineSegmentIntersection}, surface_surface::surface_surface, }; From 6f7b6ceff21232ecba9d5ac4afce6b4a455d880d Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 14 Jul 2022 14:26:53 +0200 Subject: [PATCH 3/3] Implement `IntoIterator` for intersection list --- .../src/algorithms/intersection/curve_face.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/fj-kernel/src/algorithms/intersection/curve_face.rs b/crates/fj-kernel/src/algorithms/intersection/curve_face.rs index 162bf5f08..201263d18 100644 --- a/crates/fj-kernel/src/algorithms/intersection/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersection/curve_face.rs @@ -1,3 +1,5 @@ +use std::vec; + use fj_math::{Scalar, Segment}; use parry2d_f64::query::{Ray, RayCast}; @@ -166,6 +168,15 @@ impl CurveFaceIntersectionList { } } +impl IntoIterator for CurveFaceIntersectionList { + type Item = CurveFaceIntersection; + type IntoIter = vec::IntoIter; + + fn into_iter(self) -> Self::IntoIter { + self.intervals.into_iter() + } +} + /// An intersection between a curve and a face, in curve coordinates pub type CurveFaceIntersection = [Scalar; 2];