mcubes 0.1.0

The Marching Cubes algorithm for creating isosurfaces
Documentation

Mcubes: Marching Cubes library

Crate Docs

Uses the Marching Cubes algorithm to create isosurfaces in Rust, from volume data. Designed to be easy to integrate.

Based loosely on PyMarchingCubes.

For now, depends on the graphics library for Mesh and Vertex. We will remove this requirement later, for a lighter dependency tree.

Uses lin-alg for its Vec3 type.

Used by the Daedalus molecule viewer to view experimentally-derived electron density from protein crystals.

Example use:

use mcubes::{GridPoint, MarchingCubes};

pub struct ElectronDensity {
    pub coords: Vec3,
    pub density: f64,
}

impl GridPoint for ElectronDensity {
    fn value(&self) -> f64 { self.density }
}

fn create_mesh(hdr: &MapHeader, mol: &Molecule, iso_level: f32) {
    let mc = MarchingCubes::new(
        // Number of grid points along each axis
        (hdr.nx as usize, hdr.ny as usize, hdr.nz as usize),
        // Grid dimensions per unit cell along each axis
        (hdr.cell[0], hdr.cell[1], hdr.cell[2]),
        // Sampling interval along each axis. (Usually the same as grid point number of grid points.)
        (hdr.mx as f32, hdr.my as f32, hdr.mz as f32),
        mol.elec_density,
        // The value to draw the isosurface at.
        iso_level,
    );

    let mesh = mc.generate();
}

Why another Marching Cubes library? I couldn't figure out how to use the other ones.