-
-
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 #1305 from hannobraun/partial
Start extracting new builder API from partial object API
- Loading branch information
Showing
22 changed files
with
373 additions
and
238 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
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
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
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,48 @@ | ||
use fj_math::{Point, Scalar, Vector}; | ||
|
||
use crate::{partial::PartialCurve, path::SurfacePath}; | ||
|
||
/// Builder API for [`PartialCurve`] | ||
pub trait CurveBuilder { | ||
/// Update partial curve to represent the u-axis | ||
fn update_as_u_axis(self) -> Self; | ||
|
||
/// Update partial curve to represent the v-axis | ||
fn update_as_v_axis(self) -> Self; | ||
|
||
/// Update partial curve as a circle, from the provided radius | ||
fn update_as_circle_from_radius(self, radius: impl Into<Scalar>) -> Self; | ||
|
||
/// Update partial curve as a line, from the provided points | ||
fn update_as_line_from_points( | ||
self, | ||
points: [impl Into<Point<2>>; 2], | ||
) -> Self; | ||
} | ||
|
||
impl CurveBuilder for PartialCurve { | ||
fn update_as_u_axis(self) -> Self { | ||
let a = Point::origin(); | ||
let b = a + Vector::unit_u(); | ||
|
||
self.update_as_line_from_points([a, b]) | ||
} | ||
|
||
fn update_as_v_axis(self) -> Self { | ||
let a = Point::origin(); | ||
let b = a + Vector::unit_v(); | ||
|
||
self.update_as_line_from_points([a, b]) | ||
} | ||
|
||
fn update_as_circle_from_radius(self, radius: impl Into<Scalar>) -> Self { | ||
self.with_path(Some(SurfacePath::circle_from_radius(radius))) | ||
} | ||
|
||
fn update_as_line_from_points( | ||
self, | ||
points: [impl Into<Point<2>>; 2], | ||
) -> Self { | ||
self.with_path(Some(SurfacePath::line_from_points(points))) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,11 +1,22 @@ | ||
//! API for building objects | ||
// These are the old-style builders that need to be transferred to the partial | ||
// object API. Issue: | ||
// https://github.com/hannobraun/Fornjot/issues/1147 | ||
mod face; | ||
mod shell; | ||
mod sketch; | ||
mod solid; | ||
|
||
// These are new-style builders that build on top of the partial object API. | ||
mod curve; | ||
mod vertex; | ||
|
||
pub use self::{ | ||
face::FaceBuilder, shell::ShellBuilder, sketch::SketchBuilder, | ||
curve::CurveBuilder, | ||
face::FaceBuilder, | ||
shell::ShellBuilder, | ||
sketch::SketchBuilder, | ||
solid::SolidBuilder, | ||
vertex::{GlobalVertexBuilder, SurfaceVertexBuilder, VertexBuilder}, | ||
}; |
Oops, something went wrong.