Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Intersect trait; rename intersection module to intersect #946

Merged
merged 4 commits into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions crates/fj-kernel/src/algorithms/cast_ray/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ pub use self::segment::RaySegmentHit;
use fj_math::Point;

/// Implemented by types that support ray casting
///
/// # Implementation Note
///
/// This is basically a more limited version of [`Intersect`]. It probably makes
/// sense to migrate all of this trait's implementations to [`Intersect`] and
/// remove this trait.
///
/// [`Intersect`]: super::intersect::Intersect
pub trait CastRay<const D: usize> {
/// The type that describes a hit of the ray on the implementing type
type Hit;
Expand Down
8 changes: 8 additions & 0 deletions crates/fj-kernel/src/algorithms/contains/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
mod face_point;

/// Test whether an object or shape contains another
///
/// # Implementation Note
///
/// This is basically a more limited version of [`Intersect`]. It probably makes
/// sense to migrate all of this trait's implementations to [`Intersect`] and
/// remove this trait.
///
/// [`Intersect`]: super::intersect::Intersect
pub trait Contains<T> {
/// Test whether an object or shape contains another
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ use std::vec;

use fj_math::Point;

use crate::{
algorithms::intersection::CurveEdgeIntersection,
objects::{Curve, Face},
};
use crate::objects::{Curve, Face};

use super::CurveEdgeIntersection;

/// The intersections between a [`Curve`] and a [`Face`], in curve coordinates
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ mod tests {
use pretty_assertions::assert_eq;

use crate::{
algorithms::intersection::CurveFaceIntersection,
algorithms::intersect::CurveFaceIntersection,
objects::{Curve, Face, Surface},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl LineSegmentIntersection {
mod tests {
use fj_math::{Line, Point, Scalar, Segment, Vector};

use crate::algorithms::intersection::LineSegmentIntersection;
use super::LineSegmentIntersection;

#[test]
fn compute_one_hit() {
Expand Down
29 changes: 29 additions & 0 deletions crates/fj-kernel/src/algorithms/intersect/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//! Intersection algorithms

mod curve_edge;
mod curve_face;
mod face_face;
mod line_segment;
mod surface_surface;

pub use self::{
curve_edge::CurveEdgeIntersection,
curve_face::{CurveFaceIntersection, CurveFaceIntersectionInterval},
face_face::FaceFaceIntersection,
line_segment::LineSegmentIntersection,
surface_surface::SurfaceSurfaceIntersection,
};

/// Compute the intersection between a tuple of objects
///
/// # Implementation Note
///
/// This trait is newer than most of the intersection algorithms in this module.
/// Most of them don't support it yet.
pub trait Intersect {
/// The type that describes the intersection between the objects in `Self`
type Intersection;

/// Compute the intersection between a tuple of objects
fn intersect(&self) -> Option<Self::Intersection>;
}
15 changes: 0 additions & 15 deletions crates/fj-kernel/src/algorithms/intersection/mod.rs

This file was deleted.

2 changes: 1 addition & 1 deletion crates/fj-kernel/src/algorithms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod transform;
mod triangulate;

pub mod cast_ray;
pub mod intersection;
pub mod intersect;

pub use self::{
approx::{CycleApprox, FaceApprox, InvalidTolerance, Tolerance},
Expand Down