-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1076 from hannobraun/builder
Add builder API for `Vertex
- Loading branch information
Showing
4 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use fj_math::Point; | ||
|
||
use crate::objects::{Curve, GlobalVertex, SurfaceVertex, Vertex}; | ||
|
||
/// API for building a [`Vertex`] | ||
pub struct VertexBuilder { | ||
curve: Curve, | ||
} | ||
|
||
impl VertexBuilder { | ||
/// Construct a new instance of `VertexBuilder` | ||
/// | ||
/// Also see [`Vertex::build`]. | ||
pub fn new(curve: Curve) -> Self { | ||
Self { curve } | ||
} | ||
|
||
/// Build a vertex from a curve position | ||
pub fn from_point(&self, point: impl Into<Point<1>>) -> Vertex { | ||
let point = point.into(); | ||
let &surface = self.curve.surface(); | ||
|
||
let global_form = GlobalVertex::from_position( | ||
self.curve | ||
.global_form() | ||
.kind() | ||
.point_from_curve_coords(point), | ||
); | ||
let surface_form = SurfaceVertex::new( | ||
self.curve.kind().point_from_curve_coords(point), | ||
surface, | ||
global_form, | ||
); | ||
|
||
Vertex::new([0.], self.curve, surface_form, global_form) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters