mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-26 18:16:11 +00:00
Inline CurveBuilder
method
This commit is contained in:
parent
0df6ef2e3f
commit
ff5b39483d
@ -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 {}
|
||||
|
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user