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::partial::PartialCurve;
use crate::{geometry::path::SurfacePath, partial::PartialCurve};
/// Builder API for [`PartialCurve`] /// Builder API for [`PartialCurve`]
pub trait CurveBuilder { pub trait CurveBuilder {
/// Update partial curve to be a line, from provided points and line coords // No methods are currently defined. This trait serves as a placeholder, to
/// // make it clear where to add such methods, once necessary.
/// 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;
} }
impl CurveBuilder for PartialCurve { 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
}
}

View File

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