Skip to content

Commit 1b52e2c

Browse files
authored
Merge pull request #265 from arvigj/internal_angles-fix [skip ci]
Add missing bindings functions
2 parents 4f0669e + 3d53da1 commit 1b52e2c

File tree

4 files changed

+101
-3
lines changed

4 files changed

+101
-3
lines changed

priority.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ euler_characteristic.cpp
77
grad_intrinsic.cpp
88
hessian.cpp
99
hessian_energy.cpp
10-
internal_angles.cpp
1110
is_delaunay.cpp
1211
is_intrinsic_delaunay.cpp
1312
is_irregular_vertex.cpp
1413
iterative_closest_point.cpp
1514
lbs_matrix.cpp
16-
map_vertices_to_circle.cpp
1715
marching_tets.cpp
1816
mvc.cpp
1917
offset_surface.cpp
@@ -35,7 +33,6 @@ sparse_voxel_grid.cpp
3533
tet_tet_adjacency.cpp
3634

3735
active_set.cpp
38-
all_pairs_distances.cpp
3936
ambient_occlusion.cpp
4037
arap_linear_block.cpp
4138
arap_rhs.cpp

src/all_pairs_distances.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include "default_types.h"
2+
#include <igl/all_pairs_distances.h>
3+
#include <nanobind/nanobind.h>
4+
#include <nanobind/ndarray.h>
5+
#include <nanobind/eigen/dense.h>
6+
7+
namespace nb = nanobind;
8+
using namespace nb::literals;
9+
namespace pyigl
10+
{
11+
auto all_pairs_distances(
12+
const Eigen::MatrixXd &V,
13+
const Eigen::MatrixXd &U,
14+
const bool squared)
15+
{
16+
Eigen::MatrixXd D;
17+
igl::all_pairs_distances(V, U, squared, D);
18+
return D;
19+
}
20+
}
21+
22+
void bind_all_pairs_distances(nb::module_ &m)
23+
{
24+
m.def("all_pairs_distances", &pyigl::all_pairs_distances,
25+
"V"_a,
26+
"U"_a,
27+
"squared"_a,
28+
R"(Compute distances between each point i in V and point j in U
29+
D = all_pairs_distances(V,U)
30+
@tparam matrix class like MatrixXd
31+
@param[in] V #V by dim list of points
32+
@param[in] U #U by dim list of points
33+
@param[in] squared whether to return squared distances
34+
@param[out] D #V by #U matrix of distances, where D(i,j) gives the distance or
35+
squareed distance between V(i,:) and U(j,:)
36+
)");
37+
}

src/internal_angles.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "default_types.h"
2+
#include <igl/internal_angles.h>
3+
#include <nanobind/nanobind.h>
4+
#include <nanobind/ndarray.h>
5+
#include <nanobind/eigen/dense.h>
6+
7+
namespace nb = nanobind;
8+
using namespace nb::literals;
9+
namespace pyigl
10+
{
11+
auto internal_angles(
12+
const nb::DRef<const Eigen::MatrixXN> &V,
13+
const nb::DRef<const Eigen::MatrixXI> &F)
14+
{
15+
Eigen::MatrixXN K;
16+
igl::internal_angles(V, F, K);
17+
return K;
18+
}
19+
}
20+
21+
void bind_internal_angles(nb::module_ &m)
22+
{
23+
m.def("internal_angles", &pyigl::internal_angles,
24+
"V"_a,
25+
"F"_a,
26+
R"(Compute internal angles for all tets of a given tet mesh (V,T).
27+
@param[in] V #V by dim eigen Matrix of mesh vertex nD positions
28+
@param[in] T #F by poly-size eigen Matrix of face (triangle) indices
29+
@param[out] K #F by poly-size eigen Matrix of internal angles
30+
for triangles, columns correspond to edges [1,2],[2,0],[0,1])");
31+
}

src/map_vertices_to_circle.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include "default_types.h"
2+
#include <igl/map_vertices_to_circle.h>
3+
#include <nanobind/nanobind.h>
4+
#include <nanobind/ndarray.h>
5+
#include <nanobind/eigen/dense.h>
6+
#include <nanobind/stl/vector.h>
7+
8+
namespace nb = nanobind;
9+
using namespace nb::literals;
10+
namespace pyigl
11+
{
12+
auto map_vertices_to_circle(
13+
const Eigen::MatrixXd &V,
14+
const Eigen::VectorXi &bnd)
15+
{
16+
Eigen::MatrixXd UV;
17+
igl::map_vertices_to_circle(V, bnd, UV);
18+
return UV;
19+
}
20+
}
21+
22+
void bind_map_vertices_to_circle(nb::module_ &m)
23+
{
24+
m.def("map_vertices_to_circle", &pyigl::map_vertices_to_circle,
25+
"V"_a,
26+
"bnd"_a,
27+
R"(Map the vertices whose indices are in a given boundary loop (bnd) on the
28+
unit circle with spacing proportional to the original boundary edge
29+
lengths.
30+
@param[in] V #V by dim list of mesh vertex positions
31+
@param[in] b #W list of vertex ids
32+
@param[out] UV #W by 2 list of 2D position on the unit circle for the vertices in b)");
33+
}

0 commit comments

Comments
 (0)