The Marching Cubes algorithm for creating isosurfaces
Project description
Mcubes: Marching Cubes Isosurface library
Uses the Marching Cubes algorithm to create isosurfaces in Rust or Python, from volume data. Designed to be easy to integrate in applications.
Based loosely on PyMarchingCubes.
Outputs a native Mesh, which contains native Vertexs. In practice, you will convert these to whatever
mesh struct your application uses. For example, graphics::Mesh.
Uses lin-alg for its Vec3 type; this is the library's only dependency.
Used by the Daedalus molecule viewer to view experimentally-derived electron density from protein crystals.
The grid must be regularly spaced, along 3 orthogonal axes. Values are either a Vec<f32>, or points which impl
mcubes::GridPoint. This trait contains a single method: To get the value at that point.
Example creating a solvent-accessible-surface mesh by setting the ISO level to 0, and
rendering only the vertices.
Example use:
use mcubes::{GridPoint, MarchingCubes, MeshSide};
/// An example data struct from your application. If you use something like this
/// to represent a point, you may with to use the `from_gridpoints` constructor.
pub struct ElectronDensity {
pub coords: Vec3,
pub density: f64,
}
impl GridPoint for ElectronDensity {
fn value(&self) -> f64 { self.density }
}
fn create_mesh(hdr: &MapHeader, density: &[ElectronDensity], iso_level: f32) {
let mc = MarchingCubes::from_gridpoints(
// 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),
density,
// The value to draw the isosurface at.
iso_level,
);
// If you are using a `Vec<f32` for data instead if `GridPoint`, use this constructor:
let mc = MarchingCubes::new(
(hdr.nx as usize, hdr.ny as usize, hdr.nz as usize),
(hdr.cell[0], hdr.cell[1], hdr.cell[2]),
(hdr.mx as f32, hdr.my as f32, hdr.mz as f32),
values, // Vec<f32>
iso_level,
);
// Use MeshSide::Inside or MeshSide::Outside as required.
let mesh = mc.generate(MeshSide::Both);
// Example of converting the generic output mesh to a graphic engine's:
let vertices = mesh
.vertices
.iter()
.map(|v| graphics::Vertex::new(v.posit.to_arr(), v.normal))
.collect();
scene.meshes[MESH_DENSITY_SURFACE] = graphics::Mesh {
vertices,
indices: mesh.indices,
material: 0,
};
}
Why another Marching Cubes library? I couldn't figure out how to use the existing ones.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcubes-0.1.6.tar.gz.
File metadata
- Download URL: mcubes-0.1.6.tar.gz
- Upload date:
- Size: 4.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7ad9a454dacdcdff5246cff0d199ac8becc2854a40bf3640d1a3759c404507c
|
|
| MD5 |
37dc7c29f05dabe6986dae642b6510da
|
|
| BLAKE2b-256 |
02e44045c3dfe1949347516e6c221e76b60da3df1a5d5a7fd72afa01951c71b5
|
File details
Details for the file mcubes-0.1.6-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: mcubes-0.1.6-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 153.3 kB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
114139aef1d6ea266b67ba16e9124d75c02d18b8ca3d7ad53220ffe38ff8b0ea
|
|
| MD5 |
cae1aa80d9af306277feb8c1c2bfb0f6
|
|
| BLAKE2b-256 |
d48c549ff245a7846d5443785be2fd14a5c5191072f9c2caee4d0107c79ed4e2
|
File details
Details for the file mcubes-0.1.6-cp310-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: mcubes-0.1.6-cp310-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 463.4 kB
- Tags: CPython 3.10+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b918b8bce3ed377b14656fcb4887f3de3d4c5f43709b1e7eeb2a3832cce41b2
|
|
| MD5 |
677b500178724e2fc0389662301821d6
|
|
| BLAKE2b-256 |
543118e3af99abb45c921c3f77abece8c5b3a702156066c331883dfab2a72db0
|
File details
Details for the file mcubes-0.1.6-cp310-abi3-musllinux_1_2_armv7l.whl.
File metadata
- Download URL: mcubes-0.1.6-cp310-abi3-musllinux_1_2_armv7l.whl
- Upload date:
- Size: 565.2 kB
- Tags: CPython 3.10+, musllinux: musl 1.2+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1caa557db84794a760c0df203ddabd86fff6d018e35b97d7017a52eaa4a6cfa
|
|
| MD5 |
5c7964b18099bfdffc8e17d5b1fc6b9e
|
|
| BLAKE2b-256 |
43c0360d151fb228f245b07f26e8f1032040f04fcf97a6c661f76ee5a4a97356
|
File details
Details for the file mcubes-0.1.6-cp310-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: mcubes-0.1.6-cp310-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 469.7 kB
- Tags: CPython 3.10+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d46d01eec8b5894d5f7ddb3514e4bb393755e84845aed994ae9a556d01281a53
|
|
| MD5 |
6eb63ce4223a23fc923ea295407bee1b
|
|
| BLAKE2b-256 |
4bc5ce11050704185d9621d88db29fbd6bb948e43a9572842088e9e3a8f3a9da
|
File details
Details for the file mcubes-0.1.6-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: mcubes-0.1.6-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 293.3 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90c60563be188cb950b5b64319c10b15dc7a2f6c477538faa0ad13c92d2d7dc3
|
|
| MD5 |
f4bf083c8bc0c3ea400fd3b0b7005f0c
|
|
| BLAKE2b-256 |
a520cda18bae2b48949d59076e4938561f80d9b347744ebbffd4421c87470a1c
|
File details
Details for the file mcubes-0.1.6-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.
File metadata
- Download URL: mcubes-0.1.6-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 329.8 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63534023173fadc596248de4b985595785e4a92c56a2e55e99289ac6c55c0b32
|
|
| MD5 |
cdd8e24e7005d9a9394783cad2c01d87
|
|
| BLAKE2b-256 |
c5c7540b8cdd7c8dfeb061927ca9acef53d317711f87d76075ea450f47a83efd
|
File details
Details for the file mcubes-0.1.6-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.
File metadata
- Download URL: mcubes-0.1.6-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 417.3 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b624201cd03725bb3954ad274ecd59ff5a8a9a7ee84b262b171a9b35ff70f25d
|
|
| MD5 |
97c7becda59bc5a77fc3b1713046ac5e
|
|
| BLAKE2b-256 |
fa1aca5fcc776fbcecfd4e091a93e2533e381b8ece0f37b29f475fc196b79503
|
File details
Details for the file mcubes-0.1.6-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.
File metadata
- Download URL: mcubes-0.1.6-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 302.1 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9dfc3e6d30eda78805b47e0ac406796efb62b3f20aa13b9da9082242a2e87c87
|
|
| MD5 |
f74217f40d1aeb928ece2663435af400
|
|
| BLAKE2b-256 |
4ecbd6d58170d1f0b68f9eb2953274bd3febef4d1f3e116dd2567e5012de61f6
|
File details
Details for the file mcubes-0.1.6-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: mcubes-0.1.6-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 291.1 kB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9dde95e43b64b252d53abf6d159955bc9d047dc4ee9a9a5297a8844ab3159a0
|
|
| MD5 |
3b40b3cbe5329eb9fdfe32d1becf55cd
|
|
| BLAKE2b-256 |
f809d92490d2afd56356b1ca3664bd0eb9970825083081a143d6eb9b838e9ecf
|
File details
Details for the file mcubes-0.1.6-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: mcubes-0.1.6-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 259.7 kB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ca2fcb93b4726979979a49f548778039d9276de30c63dc56de2658e443d7948
|
|
| MD5 |
8c2ff3cae3daa3b2aa92181852bc7cee
|
|
| BLAKE2b-256 |
742096606cd041c3155252fdb00a8edcfc86845e4c7ddd6c0c3529a420525f6f
|
File details
Details for the file mcubes-0.1.6-cp310-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: mcubes-0.1.6-cp310-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 267.7 kB
- Tags: CPython 3.10+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f564e399a87f3e9de1c05889b0100f4809deb8fa138e34921e23e3601529e136
|
|
| MD5 |
244bc325e16381206090e286997732d2
|
|
| BLAKE2b-256 |
8f7d7dcb6a54046dcdbf540939fc3d28f75613f739b44a4d45e3ad9c23785e84
|