//! A punched cube generated by shape operator `AND`. use truck_modeling::*; fn main() { let v = builder::vertex(Point3::origin()); let e = builder::tsweep(&v, Vector3::unit_x()); let f = builder::tsweep(&e, Vector3::unit_y()); let cube = builder::tsweep(&f, Vector3::unit_z()); let v = builder::vertex(Point3::new(0.5, 0.25, -0.5)); let w = builder::rsweep(&v, Point3::new(0.5, 0.5, 0.0), Vector3::unit_z(), Rad(7.0)); let f = builder::try_attach_plane(&[w]).unwrap(); let mut cylinder = builder::tsweep(&f, Vector3::unit_z() * 2.0); cylinder.not(); let and = truck_shapeops::and(&cube, &cylinder, 0.05).unwrap(); and.edge_iter().for_each(|edge| { let mut curve = edge.curve(); if let Curve::IntersectionCurve(inter) = &curve { if matches! { inter.leader(), Leader::Polyline(_) } { let flag = curve.to_bspline_leader(0.01, 0.1, 20); println!("{flag}"); } } edge.set_curve(curve); }); let json = serde_json::to_vec_pretty(&and).unwrap(); std::fs::write("punched-cube-shapeops.json", json).unwrap(); }