pub fn marching_cubes(
grid: &[f64],
nx: usize,
ny: usize,
nz: usize,
dx: f64,
dy: f64,
dz: f64,
origin_x: f64,
origin_y: f64,
origin_z: f64,
isolevel: f64,
out_vertices: &mut [Point3],
out_triangles: &mut [[u32; 3]],
) -> Result<(usize, usize), IsosurfaceError>Expand description
Marching cubes isosurface extraction.
Extracts a triangle mesh from a scalar field grid sampled on a regular
3D grid of size nx * ny * nz at isolevel isolevel.
The grid is indexed as grid[x + y * nx + z * nx * ny].
The cell spacing is (dx, dy, dz).
The origin is at (origin_x, origin_y, origin_z).
out_vertices needs nx * ny * nz * 3 entries (upper bound).
out_triangles needs nx * ny * nz * 5 entries (upper bound, 5 tris per cell).
Returns (vertex_count, triangle_count).