Skip to content

Commit

Permalink
Merge pull request #611 from hannobraun/surface
Browse files Browse the repository at this point in the history
Add `Surface::plane_from_points`
  • Loading branch information
hannobraun authored May 20, 2022
2 parents 25f464e + 58f6b08 commit c255947
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
5 changes: 2 additions & 3 deletions crates/fj-kernel/src/algorithms/sweep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ mod tests {

use crate::{
algorithms::Tolerance,
geometry::{Surface, SweptCurve},
geometry::Surface,
shape::{Handle, Shape},
topology::{Cycle, Edge, Face},
};
Expand Down Expand Up @@ -230,8 +230,7 @@ mod tests {

let cycles = shape.insert(Cycle::new(vec![ab, bc, ca]))?;

let surface =
Surface::SweptCurve(SweptCurve::plane_from_points([a, b, c]));
let surface = Surface::plane_from_points([a, b, c]);
let surface = if reverse { surface.reverse() } else { surface };
let surface = shape.insert(surface)?;

Expand Down
12 changes: 11 additions & 1 deletion crates/fj-kernel/src/geometry/surfaces/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pub mod swept;

pub use self::swept::SweptCurve;

use fj_math::{Point, Transform, Vector};
use fj_math::{Line, Point, Transform, Vector};

use crate::geometry;

Expand Down Expand Up @@ -40,6 +40,16 @@ impl Surface {
})
}

/// Construct a plane from 3 points
pub fn plane_from_points(points: [impl Into<Point<3>>; 3]) -> Self {
let [a, b, c] = points.map(Into::into);

let curve = Curve::Line(Line::from_points([a, b]));
let path = c - a;

Self::SweptCurve(SweptCurve { curve, path })
}

/// Create a new instance that is reversed
#[must_use]
pub fn reverse(self) -> Self {
Expand Down
9 changes: 0 additions & 9 deletions crates/fj-kernel/src/geometry/surfaces/swept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ pub struct SweptCurve {
}

impl SweptCurve {
/// Construct a plane from 3 points
#[cfg(test)]
pub fn plane_from_points([a, b, c]: [Point<3>; 3]) -> Self {
let curve = Curve::Line(Line::from_points([a, b]));
let path = c - a;

Self { curve, path }
}

/// Create a new instance that is reversed
#[must_use]
pub fn reverse(mut self) -> Self {
Expand Down

0 comments on commit c255947

Please sign in to comment.