Skip to content

Commit

Permalink
Merge pull request #2203 from hannobraun/update
Browse files Browse the repository at this point in the history
Change `add_region` into `add_regions`
  • Loading branch information
hannobraun authored Feb 12, 2024
2 parents 2414498 + a2d62a8 commit fce60c9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
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)
}

0 comments on commit fce60c9

Please sign in to comment.