Skip to content

Commit

Permalink
Simplify cuboid using BuildSketch
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed May 30, 2023
1 parent 0ea99f8 commit 08f522a
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions models/cuboid/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use fj_kernel::{
algorithms::sweep::Sweep,
geometry::region::Region,
objects::{Cycle, Sketch, Solid},
operations::{BuildCycle, Insert},
objects::{Sketch, Solid},
operations::{BuildSketch, Insert},
services::Services,
storage::Handle,
};
Expand All @@ -11,22 +10,16 @@ use fj_math::Vector;
pub fn cuboid(x: f64, y: f64, z: f64) -> Handle<Solid> {
let mut services = Services::new();

let sketch = {
let exterior = Cycle::polygon(
[
[-x / 2., -y / 2.],
[x / 2., -y / 2.],
[x / 2., y / 2.],
[-x / 2., y / 2.],
],
&mut services,
)
.insert(&mut services);

let region = Region::new(exterior, Vec::new(), None);

Sketch::new([region]).insert(&mut services)
};
let sketch = Sketch::polygon(
[
[-x / 2., -y / 2.],
[x / 2., -y / 2.],
[x / 2., y / 2.],
[-x / 2., y / 2.],
],
&mut services,
)
.insert(&mut services);

let surface = services.objects.surfaces.xy_plane();

Expand Down

0 comments on commit 08f522a

Please sign in to comment.