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" name = "split"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cuboid",
"fj", "fj",
] ]

View File

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

View File

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