Re-use cuboid model in split model

This commit is contained in:
Hanno Braun 2023-12-14 13:03:21 +01:00
parent 4aaacc2af3
commit c1d2fc1f1e
3 changed files with 13 additions and 29 deletions

1
Cargo.lock generated
View File

@ -2989,6 +2989,7 @@ dependencies = [
name = "split"
version = "0.1.0"
dependencies = [
"cuboid",
"fj",
]

View File

@ -3,5 +3,9 @@ name = "split"
version = "0.1.0"
edition = "2021"
[dependencies.fj]
path = "../../crates/fj"
[dependencies.cuboid]
path = "../cuboid"

View File

@ -1,17 +1,11 @@
use fj::{
core::{
objects::{Region, Sketch, Solid},
operations::{
build::{BuildRegion, BuildSketch},
insert::Insert,
split::SplitFace,
sweep::{SweepFaceOfShell, SweepSketch},
update::{UpdateSketch, UpdateSolid},
},
services::Services,
storage::Handle,
use fj::core::{
objects::Solid,
operations::{
insert::Insert, split::SplitFace, sweep::SweepFaceOfShell,
update::UpdateSolid,
},
math::Vector,
services::Services,
storage::Handle,
};
pub fn model(
@ -19,22 +13,7 @@ pub fn model(
split_pos: f64,
services: &mut Services,
) -> Handle<Solid> {
let sketch = Sketch::empty().add_region(
Region::polygon(
[
[-size / 2., -size / 2.],
[size / 2., -size / 2.],
[size / 2., size / 2.],
[-size / 2., size / 2.],
],
services,
)
.insert(services),
);
let surface = services.objects.surfaces.xy_plane();
let path = Vector::from([0., 0., size]);
let solid = sketch.sweep_sketch(surface, path, services);
let solid = cuboid::model([size, size, size], services);
solid
.update_shell(solid.shells().only(), |shell| {