mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-11 02:37:00 +00:00
Add SurfaceGeom::generate_tri_mesh
This commit is contained in:
parent
671ffc169a
commit
eeb2eb1786
@ -1,6 +1,6 @@
|
||||
//! The geometry that defines a surface
|
||||
|
||||
use fj_math::{Point, Scalar, Transform, Triangle, Vector};
|
||||
use fj_math::{Aabb, Point, Scalar, Transform, Triangle, Vector};
|
||||
|
||||
use super::{traits::GenPolyline, Path, Tolerance};
|
||||
|
||||
@ -76,6 +76,30 @@ impl SurfaceGeom {
|
||||
(triangle, barycentric_coords)
|
||||
}
|
||||
|
||||
/// # Generated a triangle mesh within the provided boundary
|
||||
pub fn generate_tri_mesh(
|
||||
&self,
|
||||
boundary: Aabb<2>,
|
||||
tolerance: Tolerance,
|
||||
) -> Vec<Point<2>> {
|
||||
let boundary_curve = [[boundary.min.u], [boundary.max.u]];
|
||||
let points_curve =
|
||||
self.u.generate_polyline(boundary_curve.into(), tolerance);
|
||||
|
||||
points_curve
|
||||
.iter()
|
||||
.copied()
|
||||
.map(|point| [point.t, Scalar::ZERO])
|
||||
.chain(
|
||||
points_curve
|
||||
.iter()
|
||||
.copied()
|
||||
.map(|point| [point.t, self.v.magnitude()]),
|
||||
)
|
||||
.map(Point::from)
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Convert a point in surface coordinates to model coordinates
|
||||
pub fn point_from_surface_coords(
|
||||
&self,
|
||||
|
Loading…
Reference in New Issue
Block a user