Inline CurveBuilder method

This commit is contained in:
Hanno Braun 2023-02-24 14:34:00 +01:00
parent 0df6ef2e3f
commit ff5b39483d
2 changed files with 10 additions and 28 deletions

View File

@ -1,25 +1,9 @@
use fj_math::Point;
use crate::{geometry::path::SurfacePath, partial::PartialCurve};
use crate::partial::PartialCurve;
/// Builder API for [`PartialCurve`]
pub trait CurveBuilder {
/// Update partial curve to be a line, from provided points and line coords
///
/// Returns the updated path.
fn update_as_line_from_points_with_line_coords(
&mut self,
points: [(impl Into<Point<1>>, impl Into<Point<2>>); 2],
) -> SurfacePath;
// No methods are currently defined. This trait serves as a placeholder, to
// make it clear where to add such methods, once necessary.
}
impl CurveBuilder for PartialCurve {
fn update_as_line_from_points_with_line_coords(
&mut self,
points: [(impl Into<Point<1>>, impl Into<Point<2>>); 2],
) -> SurfacePath {
let path = SurfacePath::from_points_with_line_coords(points);
self.path = Some(path.into());
path
}
}
impl CurveBuilder for PartialCurve {}

View File

@ -10,8 +10,6 @@ use crate::{
partial::{MaybeSurfacePath, Partial, PartialGlobalEdge, PartialHalfEdge},
};
use super::CurveBuilder;
/// Builder API for [`PartialHalfEdge`]
pub trait HalfEdgeBuilder {
/// Update partial half-edge to represent the u-axis of the surface it is on
@ -174,12 +172,12 @@ impl HalfEdgeBuilder for PartialHalfEdge {
});
let path = if let [Some(start), Some(end)] = boundary {
let boundary = [start, end];
self.curve
.write()
.update_as_line_from_points_with_line_coords(
boundary.zip_ext(points_surface),
)
let points = [start, end].zip_ext(points_surface);
let path = SurfacePath::from_points_with_line_coords(points);
self.curve.write().path = Some(path.into());
path
} else {
let (path, _) = SurfacePath::line_from_points(points_surface);
self.curve.write().path = Some(path.into());