Skip to content

Commit

Permalink
Merge accessors of fj::Difference2d
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Mar 29, 2022
1 parent 71eccc8 commit 45269c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
10 changes: 7 additions & 3 deletions fj-operations/src/difference_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ impl ToShape for fj::Difference2d {

let mut shape = Shape::new();

let [mut a, mut b] = [&self.a(), &self.b()]
.map(|shape| shape.to_shape(tolerance, debug_info));
// Can be cleaned up, once `each_ref` is stable:
// https://doc.rust-lang.org/std/primitive.array.html#method.each_ref
let [a, b] = self.shapes();
let shapes = [&a, &b];
let [mut a, mut b] =
shapes.map(|shape| shape.to_shape(tolerance, debug_info));

// Check preconditions.
//
Expand Down Expand Up @@ -76,7 +80,7 @@ impl ToShape for fj::Difference2d {
// This is a conservative estimate of the bounding box: It's never going
// to be bigger than the bounding box of the original shape that another
// is being subtracted from.
self.a().bounding_volume()
self.shapes()[0].bounding_volume()
}
}

Expand Down
11 changes: 3 additions & 8 deletions fj/src/shape_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,9 @@ impl Difference2d {
self.shapes[0].color()
}

/// Access the original shape
pub fn a(&self) -> &Shape2d {
&self.shapes[0]
}

/// Access the shape being subtracted
pub fn b(&self) -> &Shape2d {
&self.shapes[1]
/// Access the shapes that make up the difference
pub fn shapes(&self) -> &[Shape2d; 2] {
&self.shapes
}
}

Expand Down

0 comments on commit 45269c8

Please sign in to comment.