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

Change add_region into add_regions #2203

Merged
merged 1 commit into from
Feb 12, 2024
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
12 changes: 9 additions & 3 deletions crates/fj-core/src/operations/update/sketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ use crate::{
pub trait UpdateSketch {
/// Add a region to the sketch
#[must_use]
fn add_region(&self, region: Handle<Region>) -> Self;
fn add_regions(
&self,
regions: impl IntoIterator<Item = Handle<Region>>,
) -> Self;

/// Update a region of the sketch
///
Expand All @@ -25,8 +28,11 @@ pub trait UpdateSketch {
}

impl UpdateSketch for Sketch {
fn add_region(&self, region: Handle<Region>) -> Self {
Sketch::new(self.regions().iter().cloned().chain([region]))
fn add_regions(
&self,
regions: impl IntoIterator<Item = Handle<Region>>,
) -> Self {
Sketch::new(self.regions().iter().cloned().chain(regions))
}

fn update_region<const N: usize>(
Expand Down
20 changes: 9 additions & 11 deletions models/cuboid/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@ pub fn model(
let sweep_path = Vector::from([Scalar::ZERO, Scalar::ZERO, z]);

Sketch::empty()
.add_region(
Region::polygon(
[
[-x / 2., -y / 2.],
[x / 2., -y / 2.],
[x / 2., y / 2.],
[-x / 2., y / 2.],
],
core,
)
.insert(&mut core.services),
.add_regions([Region::polygon(
[
[-x / 2., -y / 2.],
[x / 2., -y / 2.],
[x / 2., y / 2.],
[-x / 2., y / 2.],
],
core,
)
.insert(&mut core.services)])
.sweep_sketch(bottom_surface, sweep_path, core)
}
12 changes: 5 additions & 7 deletions models/spacer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ pub fn model(
let sweep_path = Vector::from([0., 0., height]);

Sketch::empty()
.add_region(
Region::circle(Point::origin(), outer, core)
.add_interiors([Cycle::circle(Point::origin(), inner, core)
.reverse(core)
.insert(&mut core.services)])
.insert(&mut core.services),
)
.add_regions([Region::circle(Point::origin(), outer, core)
.add_interiors([Cycle::circle(Point::origin(), inner, core)
.reverse(core)
.insert(&mut core.services)])
.insert(&mut core.services)])
.sweep_sketch(bottom_surface, sweep_path, core)
}
12 changes: 5 additions & 7 deletions models/star/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,10 @@ pub fn model(
let sweep_path = Vector::from([0., 0., h]);

Sketch::empty()
.add_region(
Region::polygon(outer_points, core)
.add_interiors([Cycle::polygon(inner_points, core)
.reverse(core)
.insert(&mut core.services)])
.insert(&mut core.services),
)
.add_regions([Region::polygon(outer_points, core)
.add_interiors([Cycle::polygon(inner_points, core)
.reverse(core)
.insert(&mut core.services)])
.insert(&mut core.services)])
.sweep_sketch(bottom_surface, sweep_path, core)
}