Getting started
The kernel is not on crates.io yet. Depend on it by git:
[dependencies]
ogeom = { git = "https://github.com/gilbertorconde/ogeom-rs" }
Use the ogeom umbrella crate. It re-exports the whole API as modules
(ogeom::algo, ogeom::boolean, ogeom::topo, ogeom::io, …). The
ogeom-* crates underneath are an implementation detail and their
boundaries will change.
A first solid
A block with a hole through it: two primitives, one boolean, and a volume check.
let mut model = Model::new();
let tol = Tolerances::millimetres();
// A 20×20×10 block, and a Ø8 hole through its middle.
let block = ogeom::algo::make_box(&mut model, Frame::WORLD, (20.0, 20.0, 10.0), tol)
.unwrap()
.shape;
let axis = Frame::new(Point::new(10.0, 10.0, 0.0), Direction::Z, Direction::X, tol).unwrap();
let drill = ogeom::algo::make_cylinder(&mut model, axis, 4.0, 10.0, tol)
.unwrap()
.shape;
let part = ogeom::boolean::cut(&mut model, &block, &drill, tol)
.unwrap()
.shape;
// The result is measured, not assumed: volume against the closed form.
let volume = ogeom::algo::volume_properties(&model, &part, Deflection::default(), tol)
.unwrap()
.mass;
let exact = 20.0 * 20.0 * 10.0 - core::f64::consts::PI * 4.0 * 4.0 * 10.0;
assert!((volume - exact).abs() / exact < 0.01);
The same patterns apply to the whole API:
Modelowns all data. Geometry, topology, tolerances and history live in oneModel. Operations take&mut model. AShapeis a cheap handle into the model; copying it copies no geometry. See the data model.- Every operation takes a
Tolerances. There is no global epsilon.Tolerances::millimetres()is the preset for models in millimetres. See Tolerances. - Every operation returns a
Built.built.shapeis the result. The rest ofBuiltis the history: which input entities generated or were modified into which outputs. Every operation fills it in, so parametric applications can rely on it. - Errors are values. Everything returns
Result. When the kernel cannot produce a correct result, it returns a named refusal instead of bad geometry.