Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/is_intrinsic_delaunay.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "default_types.h"
#include <igl/is_intrinsic_delaunay.h>
#include <nanobind/nanobind.h>
#include <nanobind/ndarray.h>
#include <nanobind/eigen/dense.h>

namespace nb = nanobind;
using namespace nb::literals;
namespace pyigl
{
auto is_intrinsic_delaunay(
const nb::DRef<const Eigen::MatrixXN> &l,
const nb::DRef<const Eigen::MatrixXI> &F)
{
Eigen::Matrix<unsigned char, Eigen::Dynamic, Eigen::Dynamic> D;
igl::is_intrinsic_delaunay(l, F, D);
return D;
}
}

void bind_is_intrinsic_delaunay(nb::module_ &m)
{
m.def("is_intrinsic_delaunay", &pyigl::is_intrinsic_delaunay,
"l"_a,
"F"_a,
R"(Determine if each edge in the mesh (V,F) is Delaunay.
@param[in] l #l by dim list of edge lengths
@param[in] F #F by 3 list of triangles indices
@param[out] D D #F by 3 list of bools revealing whether edges corresponding
23 31 12 are locally Delaunay. Boundary edges are by definition Delaunay.
Non-Manifold edges are by definition not Delaunay.
)");
}
61 changes: 61 additions & 0 deletions tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,3 +600,64 @@ 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 = igl.marching_cubes(unique_S,unique_corners,J,0.0)

def test_is_intrinsic_delaunay() -> None:
# vs and fs come from a simple plane from pyvista
# mesh = pv.Plane(i_resolution=3, j_resolution=2, i_size=2).triangulate()
# fs = mesh._connectivity_array.reshape(-1, 3).astype(np.int32)
# vs = mesh.points.astype(np.float64)

fs = np.array(
[
[0, 1, 4],
[1, 5, 4],
[1, 2, 5],
[2, 6, 5],
[2, 3, 6],
[3, 7, 6],
[4, 5, 8],
[5, 9, 8],
[5, 6, 9],
[6, 10, 9],
[6, 7, 10],
[7, 11, 10],
]
)

vs = np.array(
[
[-1.0, -0.5, 0.0],
[-0.33333334, -0.5, 0.0],
[0.33333334, -0.5, 0.0],
[1.0, -0.5, 0.0],
[-1.0, 0.0, 0.0],
[-0.33333334, 0.0, 0.0],
[0.33333334, 0.0, 0.0],
[1.0, 0.0, 0.0],
[-1.0, 0.5, 0.0],
[-0.33333334, 0.5, 0.0],
[0.33333334, 0.5, 0.0],
[1.0, 0.5, 0.0],
]
)

lin = igl.edge_lengths(vs, fs)
mask = igl.is_intrinsic_delaunay(lin, fs).astype(bool)

expected_mask = np.array(
[
[0, 1, 1],
[1, 0, 1],
[1, 1, 1],
[1, 1, 1],
[0, 1, 1],
[1, 0, 1],
[0, 1, 1],
[1, 0, 1],
[1, 1, 1],
[1, 1, 1],
[0, 1, 1],
[1, 0, 1],
]
)
assert np.array_equal(mask, expected_mask)
Loading