diff --git a/crates/viewer/src/main.rs b/crates/viewer/src/main.rs index eb92d530..57daacb5 100644 --- a/crates/viewer/src/main.rs +++ b/crates/viewer/src/main.rs @@ -47,7 +47,7 @@ impl GameApp for ViewerApp { // Model sourced from: // https://nist.gov/ctl/smart-connected-systems-division/smart-connected-manufacturing-systems-group/mbe-pmi-0 // let keycap = Shape::read_step("crates/viewer/models/nist_ftc_06.step").unwrap(); - let keycap = examples::gizmo::shape(); + let keycap = examples::flywheel::shape(); let mesh = keycap.mesh(); let cad_mesh = CadMesh::from_mesh(&mesh, graphics_device.device()); diff --git a/examples/src/bowl.rs b/examples/src/bowl.rs index 9755bfe2..bfb2cd17 100644 --- a/examples/src/bowl.rs +++ b/examples/src/bowl.rs @@ -1,10 +1,10 @@ use glam::dvec3; use opencascade::{ - primitives::{self, Direction, Solid}, + primitives::{Direction, Shape, Solid}, workplane::Workplane, }; -pub fn main() { +pub fn shape() -> Shape { let bot_rad: f64 = 30.0; let top_rad: f64 = 40.0; let height: f64 = 30.0; @@ -14,16 +14,16 @@ pub fn main() { // inner ( shell does not exist yest) let inner = bowly_shape(bot_rad - thickness, top_rad - thickness, height, thickness); - (loft, _) = loft.subtract_shape(&inner); + loft = loft.subtract(&inner).into(); // rouind out the top let top_side = loft.faces().farthest(Direction::PosZ).edges(); loft.fillet_edges(thickness / 2.0, top_side); - loft.write_stl("bowl.stl").unwrap(); + loft } -fn bowly_shape(bot_rad: f64, top_rad: f64, height: f64, offset: f64) -> primitives::Shape { +fn bowly_shape(bot_rad: f64, top_rad: f64, height: f64, offset: f64) -> Shape { let bottom = Workplane::xy().circle(0.0, 0.0, bot_rad); let mut top = Workplane::xy().circle(0.0, 0.0, top_rad); top.translate(dvec3(0.0, 0.0, height)); diff --git a/examples/src/flywheel.rs b/examples/src/flywheel.rs index 351dc932..ea21a095 100644 --- a/examples/src/flywheel.rs +++ b/examples/src/flywheel.rs @@ -1,7 +1,7 @@ use glam::dvec3; use opencascade::{angle::Angle, primitives::Shape, workplane::Workplane}; -pub fn main() { +pub fn shape() -> Shape { let outer: f64 = 30.0; let height: f64 = 8.0; let thickness: f64 = 8.0; @@ -10,14 +10,14 @@ pub fn main() { let ring = rim(outer, thickness, height); let sp = spokes(outer - thickness / 2.0, thickness / 2.0, spoke_count); - let (mut fly, smooth) = ring.union_shape(&sp); - fly.fillet_edges(1.0, smooth); + let mut fly = ring.union(&sp); + fly.fillet_new_edges(1.0); let the_hub = hub(hub_outer, thickness); - let (mut fly, hub_con) = fly.union_shape(&the_hub); - fly.fillet_edges(1.0, hub_con); + let mut fly = fly.union(&the_hub); + fly.fillet_new_edges(1.0); - fly.write_stl("flywheel.stl").unwrap(); + fly.into() } fn rim(outer: f64, thickness: f64, height: f64) -> Shape { @@ -25,7 +25,7 @@ fn rim(outer: f64, thickness: f64, height: f64) -> Shape { let mut ring = outer_wire.to_face().extrude(dvec3(0.0, 0.0, height)).to_shape(); let inner_wire = Workplane::xy().circle(0.0, 0.0, outer - thickness / 2.0); let inner_ring = inner_wire.to_face().extrude(dvec3(0.0, 0.0, height)).to_shape(); - (ring, _) = ring.subtract_shape(&inner_ring); + ring = ring.subtract(&inner_ring).into(); ring.chamfer(0.1); ring } @@ -51,7 +51,7 @@ fn spokes(length: f64, thickness: f64, count: usize) -> Shape { let mut first_s = spoke(length, thickness, 0.0); for i in 1..count { let s = spoke(length, thickness, incr * i as f64); - (first_s, _) = first_s.union_shape(&s); + first_s = first_s.union(&s).into(); } first_s } diff --git a/examples/src/lib.rs b/examples/src/lib.rs index 312b91b6..7c4c148a 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -1,5 +1,7 @@ +pub mod bowl; pub mod box_shape; pub mod chamfer; +pub mod flywheel; pub mod gizmo; pub mod high_level_bottle; pub mod keyboard_case;