Skip to content

Adds Marching Cubes algorithm to PhysicsNeMo-Mesh#1488

Open
peterdsharpe wants to merge 8 commits intoNVIDIA:mainfrom
peterdsharpe:psharpe/add-mesh-marching-cubes
Open

Adds Marching Cubes algorithm to PhysicsNeMo-Mesh#1488
peterdsharpe wants to merge 8 commits intoNVIDIA:mainfrom
peterdsharpe:psharpe/add-mesh-marching-cubes

Conversation

@peterdsharpe
Copy link
Collaborator

@peterdsharpe peterdsharpe commented Mar 11, 2026

PhysicsNeMo Pull Request

Description

Allows mesh generation from SDF files using marching cubes. Part of softening the deprecation blow of #1487.

Checklist

Dependencies

Review Process

All PRs are reviewed by the PhysicsNeMo team before merging.

Depending on which files are changed, GitHub may automatically assign a maintainer for review.

We are also testing AI-based code review tools (e.g., Greptile), which may add automated comments with a confidence score.
This score reflects the AI’s assessment of merge readiness and is not a qualitative judgment of your work, nor is
it an indication that the PR will be accepted / rejected.

AI-generated feedback should be reviewed critically for usefulness.
You are not required to respond to every AI comment, but they are intended to help both authors and reviewers.
Please react to Greptile comments with 👍 or 👎 to provide feedback on their accuracy.

@peterdsharpe peterdsharpe marked this pull request as ready for review March 11, 2026 20:02
@peterdsharpe peterdsharpe enabled auto-merge March 11, 2026 20:02
@peterdsharpe
Copy link
Collaborator Author

/blossom-ci

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 11, 2026

Greptile Summary

This PR adds a physicsnemo.mesh.generate subpackage providing a marching_cubes function that extracts isosurfaces from 3D scalar fields (e.g. SDFs) using NVIDIA Warp, returning a Mesh object. It is well-structured with good docstrings, solid test coverage for geometry accuracy, and proper input validation for dimensionality and coordinate-length mismatches. Two issues were found:

  • CHANGELOG incorrectly claims scikit-image support: The entry at line 23 states "Supports Warp and scikit-image backends" but no scikit-image code path exists anywhere in the implementation — only Warp is used. This will mislead users in CPU-only environments.
  • Non-uniform coordinate mapping is silently incorrect: The physical-space coordinate transform (origin + index * spacing) assumes uniformly spaced coords vectors. Passing non-uniformly spaced arrays produces wrong vertex positions without any error or warning. Since wp.MarchingCubes also assumes a regular voxel grid, this limitation should be validated or clearly documented.

Important Files Changed

Filename Overview
physicsnemo/mesh/generate/marching_cubes.py Adds marching cubes isosurface extraction using Warp. The coordinate mapping to physical space assumes uniform grid spacing but does not validate this, which will silently produce incorrect vertex positions for non-uniform coordinate arrays.
physicsnemo/mesh/generate/init.py New subpackage init that re-exports marching_cubes. Clean and minimal; no issues.
CHANGELOG.md CHANGELOG entry incorrectly states "Supports Warp and scikit-image backends" — no scikit-image backend is implemented in this PR.
test/mesh/generate/test_marching_cubes.py Comprehensive tests covering geometry accuracy, coordinate mapping, dtype, and validation. All coord tests use uniformly spaced inputs, so the non-uniform spacing bug is not caught.
test/mesh/generate/init.py Empty test package init with license header only. No issues.

Last reviewed commit: e193fe0

peterdsharpe and others added 2 commits March 11, 2026 16:09
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
…olation for non-uniform grid coordinates. Adds a new test case to validate the behavior with non-uniform coordinates, ensuring correct mesh generation and topology. Updates documentation for clarity on coordinate mapping.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant