Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant field in SketchBuilder #1408

Merged
merged 2 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions crates/fj-kernel/src/algorithms/sweep/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,11 @@ mod tests {

let surface = services.objects.surfaces.xy_plane();
let solid = Sketch::builder()
.with_surface(surface.clone())
.with_polygon_from_points(TRIANGLE, &mut services.objects)
.with_polygon_from_points(
surface.clone(),
TRIANGLE,
&mut services.objects,
)
.build(&mut services.objects)
.sweep(UP, &mut services.objects);

Expand Down Expand Up @@ -148,8 +151,11 @@ mod tests {

let surface = services.objects.surfaces.xy_plane();
let solid = Sketch::builder()
.with_surface(surface.clone())
.with_polygon_from_points(TRIANGLE, &mut services.objects)
.with_polygon_from_points(
surface.clone(),
TRIANGLE,
&mut services.objects,
)
.build(&mut services.objects)
.sweep(DOWN, &mut services.objects);

Expand Down
16 changes: 2 additions & 14 deletions crates/fj-kernel/src/builder/sketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,11 @@ use super::FaceBuilder;
///
/// Also see [`Sketch::builder`].
pub struct SketchBuilder {
/// The surface that the [`Sketch`] is defined in
pub surface: Option<Handle<Surface>>,

/// The faces that make up the [`Sketch`]
pub faces: FaceSet,
}

impl SketchBuilder {
/// Build the [`Sketch`] with the provided [`Surface`]
pub fn with_surface(mut self, surface: Handle<Surface>) -> Self {
self.surface = Some(surface);
self
}

/// Build the [`Sketch`] with the provided faces
pub fn with_faces(
mut self,
Expand All @@ -40,15 +31,12 @@ impl SketchBuilder {
/// Construct a polygon from a list of points
pub fn with_polygon_from_points(
mut self,
surface: Handle<Surface>,
points: impl IntoIterator<Item = impl Into<Point<2>>>,
objects: &mut Service<Objects>,
) -> Self {
let surface = self
.surface
.as_ref()
.expect("Can't build `Sketch` without `Surface`");
self.faces.extend([Face::partial()
.with_exterior_polygon_from_points(surface.clone(), points)
.with_exterior_polygon_from_points(surface, points)
.build(objects)
.insert(objects)]);
self
Expand Down
1 change: 0 additions & 1 deletion crates/fj-kernel/src/objects/full/sketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ impl Sketch {
/// Build a `Sketch` using [`SketchBuilder`]
pub fn builder() -> SketchBuilder {
SketchBuilder {
surface: None,
faces: FaceSet::new(),
}
}
Expand Down