marching_cubes/
lib.rs

1//! A marching cubes implementation in Rust
2//!
3//! This library provides a fast and efficient implementation of the marching cubes algorithm in Rust.
4//! The algorithm is used to extract isosurfaces from 3D volumetric data and is commonly used in fields such as computer graphics, medical imaging, and scientific visualization.
5//!
6//! # Examples
7//!
8//! ```
9//! use iso::{MarchingCubes, GridCell, Triangle};
10//!
11//! let grid = GridCell {
12//!     positions: [
13//!         [0.0, 0.0, 0.0],
14//!         [1.0, 0.0, 0.0],
15//!         [1.0, 1.0, 0.0],
16//!         [0.0, 1.0, 0.0],
17//!         [0.0, 0.0, 1.0],
18//!         [1.0, 0.0, 1.0],
19//!         [1.0, 1.0, 1.0],
20//!         [0.0, 1.0, 1.0]
21//!     ],
22//!     value: [0.0, 0.5, 0.5, 1.0, 0.0, 1.0, 1.0, 0.0],
23//! };
24//! let mut triangles = vec![];
25//! 
26//! let isolevel = 0.5;
27//! let mc = MarchingCubes::new(isolevel, grid); 
28//! let triangle_count = mc.polygonise(&mut triangles);
29//!
30//! assert_eq!(triangle_count, 4);
31//! ```
32//! The `MarchingCubes` struct is the main entry point to the library.
33//! The `new` method creates a new instance of the algorithm and takes two arguments: the 3D volumetric data as a nested array of scalar values and the isovalue used to extract the isosurface.
34//! The `polygonise` method executes the algorithm and returns the resulting vertices as a vector of 3D points.
35//!
36//! Note that the example code uses a 4x4x4 volume for simplicity, but in practice the volume size can be much larger and the algorithm will scale accordingly.
37
38pub mod container;
39pub mod marching;
40pub mod tables;