Skip to content

Commit

Permalink
Merge pull request #826 from hannobraun/intersection
Browse files Browse the repository at this point in the history
Extend API of `CurveFaceIntersectionList`
  • Loading branch information
hannobraun authored Jul 15, 2022
2 parents 4e3b840 + 6f7b6ce commit 19fb526
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion crates/fj-kernel/src/algorithms/intersection/curve_face.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::vec;

use fj_math::{Scalar, Segment};
use parry2d_f64::query::{Ray, RayCast};

Expand All @@ -6,7 +8,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<CurveFaceIntersection>,
}

impl CurveFaceIntersectionList {
Expand Down Expand Up @@ -159,8 +161,25 @@ impl CurveFaceIntersectionList {

Self { intervals }
}

/// Indicate whether the intersection list is empty
pub fn is_empty(&self) -> bool {
self.intervals.is_empty()
}
}

impl IntoIterator for CurveFaceIntersectionList {
type Item = CurveFaceIntersection;
type IntoIter = vec::IntoIter<Self::Item>;

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];

#[cfg(test)]
mod tests {
use fj_math::{Line, Point, Vector};
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/algorithms/intersection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

0 comments on commit 19fb526

Please sign in to comment.