Expand description
Octree construction and meshing
This module implements
Manifold Dual Contouring,
to generate a triangle mesh from an implicit surface (or anything
implementing Shape).
The resulting meshes should be
- Manifold
- Watertight
- Preserving sharp features (corners / edges)
However, they may contain self-intersections, and are not guaranteed to catch thin features (below the sampling grid resolution).
The resulting Mesh objects can be written out as STL files.
Here’s a full example, meshing a sphere:
use fidget_core::{
context::Tree,
vm::VmShape
};
use fidget_mesh::{Octree, Settings};
let radius_squared = Tree::x().square()
+ Tree::y().square()
+ Tree::z().square();
let tree: Tree = radius_squared.sqrt() - 0.6;
let shape = VmShape::from(tree);
let settings = Settings {
depth: 4,
..Default::default()
};
let o = Octree::build(&shape, &settings).unwrap();
let mesh = o.walk_dual();
// Open a file to write, e.g.
// let mut f = std::fs::File::create("out.stl")?;
mesh.write_stl(&mut f)?;