Add UpdateCurveGeometry::make_line_on_surface

This commit is contained in:
Hanno Braun 2024-04-29 14:58:55 +02:00
parent 3d83f929b6
commit 0904651d6c

View File

@ -1,5 +1,8 @@
use fj_interop::ext::ArrayExt;
use fj_math::Point;
use crate::{
geometry::{Geometry, LocalCurveGeom, SurfacePath},
geometry::{CurveBoundary, Geometry, LocalCurveGeom, SurfacePath},
layers::Layer,
storage::Handle,
topology::{Curve, Surface},
@ -14,6 +17,21 @@ pub trait UpdateCurveGeometry {
surface: Handle<Surface>,
geometry: &mut Layer<Geometry>,
) -> Self;
/// Define the geometry as a line
///
/// The line is constructed from two points on the provided surface.
///
/// Optionally the coordinates of those points on the curve can be supplied.
/// If those are not provided, it is assumed that the provided surface
/// points have the curve coordinates `0` and `1`.
fn make_line_on_surface(
self,
points_surface: [impl Into<Point<2>>; 2],
points_curve: Option<CurveBoundary<Point<1>>>,
surface: Handle<Surface>,
geometry: &mut Layer<Geometry>,
) -> Self;
}
impl UpdateCurveGeometry for Handle<Curve> {
@ -27,4 +45,19 @@ impl UpdateCurveGeometry for Handle<Curve> {
self
}
fn make_line_on_surface(
self,
points_surface: [impl Into<Point<2>>; 2],
points_curve: Option<CurveBoundary<Point<1>>>,
surface: Handle<Surface>,
geometry: &mut Layer<Geometry>,
) -> Self {
let points_curve = points_curve.unwrap_or_default();
let path = SurfacePath::line_from_points_with_coords(
points_curve.inner.zip_ext(points_surface),
);
self.make_path_on_surface(path, surface, geometry)
}
}