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.
Metadata
Release files for mcubes 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mcubes-0.1.6.tar.gz | 4.3 MB | Details |
Built distributions (wheels)
Total release size: 8.1 MB
Release files / mcubes-0.1.6.tar.gz
| Download URL | mcubes-0.1.6.tar.gz |
|---|---|
| Size | 4.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7ad9a454dacdcdff5246cff0d199ac8becc2854a40bf3640d1a3759c404507c
|
|
BLAKE2b-256 checksum How to use checksums |
02e44045c3dfe1949347516e6c221e76b60da3df1a5d5a7fd72afa01951c71b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.9.4
|
Release files / mcubes-0.1.6-cp310-abi3-win_amd64.whl
| Download URL | mcubes-0.1.6-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 153.3 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
114139aef1d6ea266b67ba16e9124d75c02d18b8ca3d7ad53220ffe38ff8b0ea
|
|
BLAKE2b-256 checksum How to use checksums |
d48c549ff245a7846d5443785be2fd14a5c5191072f9c2caee4d0107c79ed4e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.9.4
|
Release files / mcubes-0.1.6-cp310-abi3-musllinux_1_2_x86_64.whl
| Download URL | mcubes-0.1.6-cp310-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 463.4 kB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
8b918b8bce3ed377b14656fcb4887f3de3d4c5f43709b1e7eeb2a3832cce41b2
|
|
BLAKE2b-256 checksum How to use checksums |
543118e3af99abb45c921c3f77abece8c5b3a702156066c331883dfab2a72db0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.9.4
|
Release files / mcubes-0.1.6-cp310-abi3-musllinux_1_2_armv7l.whl
| Download URL | mcubes-0.1.6-cp310-abi3-musllinux_1_2_armv7l.whl |
|---|---|
| Size | 565.2 kB |
| Tags | CPython 3.10 Linux musl 1.2+ ARMv7l abi3 |
|
SHA-256 checksum How to use checksums |
a1caa557db84794a760c0df203ddabd86fff6d018e35b97d7017a52eaa4a6cfa
|
|
BLAKE2b-256 checksum How to use checksums |
43c0360d151fb228f245b07f26e8f1032040f04fcf97a6c661f76ee5a4a97356
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.9.4
|
Release files / mcubes-0.1.6-cp310-abi3-musllinux_1_2_aarch64.whl
| Download URL | mcubes-0.1.6-cp310-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 469.7 kB |
| Tags | CPython 3.10 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
d46d01eec8b5894d5f7ddb3514e4bb393755e84845aed994ae9a556d01281a53
|
|
BLAKE2b-256 checksum How to use checksums |
4bc5ce11050704185d9621d88db29fbd6bb948e43a9572842088e9e3a8f3a9da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.9.4
|
Release files / mcubes-0.1.6-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | mcubes-0.1.6-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 293.3 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
90c60563be188cb950b5b64319c10b15dc7a2f6c477538faa0ad13c92d2d7dc3
|
|
BLAKE2b-256 checksum How to use checksums |
a520cda18bae2b48949d59076e4938561f80d9b347744ebbffd4421c87470a1c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.9.4
|
Release files / mcubes-0.1.6-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
| Download URL | mcubes-0.1.6-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl |
|---|---|
| Size | 329.8 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ IBM System/390x abi3 |
|
SHA-256 checksum How to use checksums |
63534023173fadc596248de4b985595785e4a92c56a2e55e99289ac6c55c0b32
|
|
BLAKE2b-256 checksum How to use checksums |
c5c7540b8cdd7c8dfeb061927ca9acef53d317711f87d76075ea450f47a83efd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.9.4
|
Release files / mcubes-0.1.6-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
| Download URL | mcubes-0.1.6-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl |
|---|---|
| Size | 417.3 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ PowerPC 64-le abi3 |
|
SHA-256 checksum How to use checksums |
b624201cd03725bb3954ad274ecd59ff5a8a9a7ee84b262b171a9b35ff70f25d
|
|
BLAKE2b-256 checksum How to use checksums |
fa1aca5fcc776fbcecfd4e091a93e2533e381b8ece0f37b29f475fc196b79503
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.9.4
|
Release files / mcubes-0.1.6-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
| Download URL | mcubes-0.1.6-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl |
|---|---|
| Size | 302.1 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARMv7l abi3 |
|
SHA-256 checksum How to use checksums |
9dfc3e6d30eda78805b47e0ac406796efb62b3f20aa13b9da9082242a2e87c87
|
|
BLAKE2b-256 checksum How to use checksums |
4ecbd6d58170d1f0b68f9eb2953274bd3febef4d1f3e116dd2567e5012de61f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.9.4
|
Release files / mcubes-0.1.6-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | mcubes-0.1.6-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 291.1 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
b9dde95e43b64b252d53abf6d159955bc9d047dc4ee9a9a5297a8844ab3159a0
|
|
BLAKE2b-256 checksum How to use checksums |
f809d92490d2afd56356b1ca3664bd0eb9970825083081a143d6eb9b838e9ecf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.9.4
|
Release files / mcubes-0.1.6-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | mcubes-0.1.6-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 259.7 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
1ca2fcb93b4726979979a49f548778039d9276de30c63dc56de2658e443d7948
|
|
BLAKE2b-256 checksum How to use checksums |
742096606cd041c3155252fdb00a8edcfc86845e4c7ddd6c0c3529a420525f6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.9.4
|
Release files / mcubes-0.1.6-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | mcubes-0.1.6-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 267.7 kB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
f564e399a87f3e9de1c05889b0100f4809deb8fa138e34921e23e3601529e136
|
|
BLAKE2b-256 checksum How to use checksums |
8f7d7dcb6a54046dcdbf540939fc3d28f75613f739b44a4d45e3ad9c23785e84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.9.4
|