Skip to content

Commit

Permalink
Implement GenTriMesh for types that deref to it
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Oct 14, 2024
1 parent a9ed3ba commit 1c0ad95
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions crates/fj-core/src/geometry/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
//! system to the new one based on uniform representation is still ongoing. As a
//! result of that, this module might still be incomplete.

use std::ops::Deref;

use fj_math::{Aabb, LineSegment, Point, Scalar, Triangle};

use super::{CurveBoundary, Path, Tolerance};
Expand Down Expand Up @@ -147,3 +149,29 @@ pub trait GenTriMesh {
tolerance: Tolerance,
) -> Vec<Point<2>>;
}

impl<T> GenTriMesh for T
where
T: Deref,
T::Target: GenTriMesh,
{
fn origin(&self) -> Point<3> {
self.deref().origin()
}

fn triangle_at(
&self,
point_surface: Point<2>,
tolerance: Tolerance,
) -> (Triangle<3>, [Scalar; 3]) {
self.deref().triangle_at(point_surface, tolerance)
}

fn generate_tri_mesh(
&self,
boundary: Aabb<2>,
tolerance: Tolerance,
) -> Vec<Point<2>> {
self.deref().generate_tri_mesh(boundary, tolerance)
}
}

0 comments on commit 1c0ad95

Please sign in to comment.