From af0a18ff9e8827199d10df0639b9397ed1cedcaf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Aug 2026 19:37:49 +0000 Subject: [PATCH 1/7] Update libigl marching cubes bindings Co-authored-by: alecjacobson <2241689+alecjacobson@users.noreply.github.com> --- CMakeLists.txt | 3 +-- src/marching_cubes.cpp | 12 +++++++++--- tests/test_all.py | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fc53163..19f48136 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,7 +60,7 @@ option(LIBIGL_CYCODEBASE "Build igl::cycodebase bindings" ON) FetchContent_Declare( libigl GIT_REPOSITORY https://github.com/libigl/libigl.git - GIT_TAG 477e15a3d566a21f415aa5ee62992b12a836b01b + GIT_TAG 72217e00bae6a7e041221e187aafbdc793f905d2 ) FetchContent_MakeAvailable(libigl) @@ -208,4 +208,3 @@ if(LIBIGL_CYCODEBASE) endif() - diff --git a/src/marching_cubes.cpp b/src/marching_cubes.cpp index 72c14972..336b17b8 100644 --- a/src/marching_cubes.cpp +++ b/src/marching_cubes.cpp @@ -35,8 +35,9 @@ namespace pyigl { Eigen::MatrixXN V; Eigen::MatrixXI F; - igl::marching_cubes(S,GV,GI,isovalue,V,F); - return std::make_tuple(V,F); + std::unordered_map E2V; + igl::marching_cubes(S,GV,GI,isovalue,V,F,E2V); + return std::make_tuple(V,F,E2V); } } @@ -86,5 +87,10 @@ points, and generates a mesh defined by vertices and faces @param[in] GI #GI by 8 list of grid corner indices into rows of GV @param[in] isovalue the isovalue of the surface to reconstruct @param[out] V #V by 3 list of mesh vertex positions -@param[out] F #F by 3 list of mesh triangle indices into rows of V)"); +@param[out] F #F by 3 list of mesh triangle indices into rows of V +@param[out] E2V map from edge key to index into rows of V + +# unpack keys into (i,j,v) index triplets +EV = np.array([[k & 0xFFFFFFFF, k >> 32, v] for k, v in E2V.items()], dtype=np.int64) +)"); } diff --git a/tests/test_all.py b/tests/test_all.py index 9728d16d..314ef366 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -625,7 +625,8 @@ def udf_sphere(Q): h = h0 / (2**max_depth) unique_ijk, J, unique_corners = igl.unique_sparse_voxel_corners(origin,h0,max_depth,ijk) unique_S = sdf_sphere(unique_corners) - V,F = igl.marching_cubes(unique_S,unique_corners,J,0.0) + V,F,E2V = igl.marching_cubes(unique_S,unique_corners,J,0.0) + EV = np.array([[k & 0xFFFFFFFF, k >> 32, v] for k, v in E2V.items()], dtype=np.int64) def test_is_intrinsic_delaunay() -> None: # vs and fs come from a simple plane from pyvista From 8e3a613faa5d9b07160ce0426757a371e8dced5d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Aug 2026 19:42:31 +0000 Subject: [PATCH 2/7] Clarify marching cubes E2V docs Co-authored-by: alecjacobson <2241689+alecjacobson@users.noreply.github.com> --- src/marching_cubes.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/marching_cubes.cpp b/src/marching_cubes.cpp index 336b17b8..6de13b1c 100644 --- a/src/marching_cubes.cpp +++ b/src/marching_cubes.cpp @@ -69,7 +69,7 @@ points, and generates a mesh defined by vertices and faces @param[out] E2V map from edge key to index into rows of V # unpack keys into (i,j,v) index triplets -EV = np.array([[k & 0xFFFFFFFF, k >> 32, v] for k, v in E2V.items()], dtype=np.int64) +E2V_triplets = np.array([[k & 0xFFFFFFFF, k >> 32, v] for k, v in E2V.items()], dtype=np.int64) )"); m.def( @@ -91,6 +91,6 @@ points, and generates a mesh defined by vertices and faces @param[out] E2V map from edge key to index into rows of V # unpack keys into (i,j,v) index triplets -EV = np.array([[k & 0xFFFFFFFF, k >> 32, v] for k, v in E2V.items()], dtype=np.int64) +E2V_triplets = np.array([[k & 0xFFFFFFFF, k >> 32, v] for k, v in E2V.items()], dtype=np.int64) )"); } From 8bef372dd4f7ba69f7e7943b655cda92894ac6b4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Aug 2026 19:42:59 +0000 Subject: [PATCH 3/7] Assert sparse marching cubes E2V output Co-authored-by: alecjacobson <2241689+alecjacobson@users.noreply.github.com> --- tests/test_all.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_all.py b/tests/test_all.py index 314ef366..843824ce 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -627,6 +627,9 @@ def udf_sphere(Q): unique_S = sdf_sphere(unique_corners) V,F,E2V = igl.marching_cubes(unique_S,unique_corners,J,0.0) EV = np.array([[k & 0xFFFFFFFF, k >> 32, v] for k, v in E2V.items()], dtype=np.int64) + assert EV.shape[1] == 3 + assert np.all(EV[:,2] >= 0) + assert np.all(EV[:,2] < V.shape[0]) def test_is_intrinsic_delaunay() -> None: # vs and fs come from a simple plane from pyvista From d2fb8d4095197b357ad46a9db2488167fcef8676 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Aug 2026 19:43:26 +0000 Subject: [PATCH 4/7] Handle empty marching cubes E2V maps Co-authored-by: alecjacobson <2241689+alecjacobson@users.noreply.github.com> --- tests/test_all.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_all.py b/tests/test_all.py index 843824ce..f1d2496c 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -424,7 +424,7 @@ def test_implicit(): S = np.sqrt(((GV - np.array([0.5,0.5,0.5],dtype=np.float64))**2).sum(axis=1))-0.25; V,F,E2V = igl.marching_cubes(S,GV,res[0],res[1],res[2]) # unpack keys into (i,j,v) index triplets - EV = np.array([[k & 0xFFFFFFFF, k >> 32, v] for k, v in E2V.items()], dtype=np.int64) + EV = np.array([[k & 0xFFFFFFFF, k >> 32, v] for k, v in E2V.items()], dtype=np.int64).reshape((-1,3)) h = igl.avg_edge_length(V,F) m0,m1,m2 = igl.moments(V,F) @@ -626,7 +626,7 @@ def udf_sphere(Q): unique_ijk, J, unique_corners = igl.unique_sparse_voxel_corners(origin,h0,max_depth,ijk) unique_S = sdf_sphere(unique_corners) V,F,E2V = igl.marching_cubes(unique_S,unique_corners,J,0.0) - EV = np.array([[k & 0xFFFFFFFF, k >> 32, v] for k, v in E2V.items()], dtype=np.int64) + EV = np.array([[k & 0xFFFFFFFF, k >> 32, v] for k, v in E2V.items()], dtype=np.int64).reshape((-1,3)) assert EV.shape[1] == 3 assert np.all(EV[:,2] >= 0) assert np.all(EV[:,2] < V.shape[0]) From 3f1e7c7f73c5e84c7995c0c5e124193e19f319f8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Aug 2026 19:43:59 +0000 Subject: [PATCH 5/7] Tighten sparse marching cubes E2V test Co-authored-by: alecjacobson <2241689+alecjacobson@users.noreply.github.com> --- tests/test_all.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_all.py b/tests/test_all.py index f1d2496c..1eeff22c 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -627,7 +627,7 @@ def udf_sphere(Q): unique_S = sdf_sphere(unique_corners) V,F,E2V = igl.marching_cubes(unique_S,unique_corners,J,0.0) EV = np.array([[k & 0xFFFFFFFF, k >> 32, v] for k, v in E2V.items()], dtype=np.int64).reshape((-1,3)) - assert EV.shape[1] == 3 + assert len(E2V) == EV.shape[0] assert np.all(EV[:,2] >= 0) assert np.all(EV[:,2] < V.shape[0]) From 2fbb8828a30fe677d6e47b68b324d1ef0f5b17bf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Aug 2026 19:44:38 +0000 Subject: [PATCH 6/7] Handle empty E2V unpacking in tests Co-authored-by: alecjacobson <2241689+alecjacobson@users.noreply.github.com> --- tests/test_all.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_all.py b/tests/test_all.py index 1eeff22c..1fd0c2e3 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -424,7 +424,8 @@ def test_implicit(): S = np.sqrt(((GV - np.array([0.5,0.5,0.5],dtype=np.float64))**2).sum(axis=1))-0.25; V,F,E2V = igl.marching_cubes(S,GV,res[0],res[1],res[2]) # unpack keys into (i,j,v) index triplets - EV = np.array([[k & 0xFFFFFFFF, k >> 32, v] for k, v in E2V.items()], dtype=np.int64).reshape((-1,3)) + EV_list = [[k & 0xFFFFFFFF, k >> 32, v] for k, v in E2V.items()] + EV = np.array(EV_list, dtype=np.int64) if EV_list else np.empty((0,3), dtype=np.int64) h = igl.avg_edge_length(V,F) m0,m1,m2 = igl.moments(V,F) @@ -626,7 +627,8 @@ def udf_sphere(Q): unique_ijk, J, unique_corners = igl.unique_sparse_voxel_corners(origin,h0,max_depth,ijk) unique_S = sdf_sphere(unique_corners) V,F,E2V = igl.marching_cubes(unique_S,unique_corners,J,0.0) - EV = np.array([[k & 0xFFFFFFFF, k >> 32, v] for k, v in E2V.items()], dtype=np.int64).reshape((-1,3)) + EV_list = [[k & 0xFFFFFFFF, k >> 32, v] for k, v in E2V.items()] + EV = np.array(EV_list, dtype=np.int64) if EV_list else np.empty((0,3), dtype=np.int64) assert len(E2V) == EV.shape[0] assert np.all(EV[:,2] >= 0) assert np.all(EV[:,2] < V.shape[0]) From 88b87d36bcf0ae0860b416bc79309584cc099585 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Aug 2026 19:45:10 +0000 Subject: [PATCH 7/7] Assert sparse marching cubes output is nonempty Co-authored-by: alecjacobson <2241689+alecjacobson@users.noreply.github.com> --- tests/test_all.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_all.py b/tests/test_all.py index 1fd0c2e3..232946ab 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -627,6 +627,8 @@ def udf_sphere(Q): unique_ijk, J, unique_corners = igl.unique_sparse_voxel_corners(origin,h0,max_depth,ijk) unique_S = sdf_sphere(unique_corners) V,F,E2V = igl.marching_cubes(unique_S,unique_corners,J,0.0) + assert V.shape[0] > 0 + assert F.shape[0] > 0 EV_list = [[k & 0xFFFFFFFF, k >> 32, v] for k, v in E2V.items()] EV = np.array(EV_list, dtype=np.int64) if EV_list else np.empty((0,3), dtype=np.int64) assert len(E2V) == EV.shape[0]