Skip to main content

marching-cubes

Isosurface extraction from 3D volumes. Numpy in, indexed triangle mesh out.

the samples the surface
A sphere sampled on a 16³ grid, every voxel below the isovalue drawn as a block The triangle mesh marching cubes extracts from those same samples

A sphere sampled on a 16³ grid. On the left every voxel below the isovalue is drawn as a block, which is all the surface a volume gives you on its own. On the right is what marching_cubes reads out of the same numbers, interpolating each crossing to place vertices between the samples.

pip install marching-cubes-numpy

The distribution is named marching-cubes-numpy; the import is marching_cubes.

import numpy as np
from marching_cubes import marching_cubes

x, y, z = np.indices((64, 64, 64)) - 32
volume = np.sqrt(x**2 + y**2 + z**2) - 20.0

vertices, faces = marching_cubes(volume, 0.0)

vertices is an (n, 3) array of float64 positions in index coordinates, so vertices[:, 0] runs along the first axis of volume. faces is an (m, 3) array of int32 indices into vertices.

Corners with a value below the isovalue are inside the surface, and triangles are wound so that their normals point outwards, towards the higher values. Vertices are shared between adjacent triangles, and the surface is closed and manifold wherever it does not run off the edge of the volume.

Only numpy is required. The package is annotated and ships a py.typed marker, so type checkers see the shapes and dtypes above without any stub package.

Development

The 256-entry triangulation table is derived rather than transcribed; see tools/generate_tri_table.py.

pip install -e ".[dev]"
pytest
mypy
python bench/benchmark.py

The images above are rendered by tools/render_readme_images.py, which needs Blender on the path.

Release files for marching-cubes-numpy 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for marching-cubes-numpy 0.1.0
File Size Uploaded
marching_cubes_numpy-0.1.0.tar.gz 14.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for marching-cubes-numpy 0.1.0
File Interpreter ABI Platform
marching_cubes_numpy-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.4 kB

Release files / marching_cubes_numpy-0.1.0.tar.gz

Download URL marching_cubes_numpy-0.1.0.tar.gz
Size 14.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2dddc18377153a1f32f21fa0f63dc3e3633f0f02b106ed4079d04309cf7d75b0
BLAKE2b-256 checksum
How to use checksums
8e77d78d60d78cbe7893181a2bec0551ae97d7893bc8d716795516c2f0589209
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.

Transparency log

Release files / marching_cubes_numpy-0.1.0-py3-none-any.whl

Download URL marching_cubes_numpy-0.1.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b5abb0b1f360ecae50212dd57a667fbdc5e7cbe1466f7b1f24dfba21cb0e15a3
BLAKE2b-256 checksum
How to use checksums
58620b0151e9510916bd78e40e01f0df762ff759d8f95eb65e909449c2114203
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page