Skip to content

Commit 80a5733

Browse files
authored
Merge branch 'libigl:main' into sample-with-seed
2 parents b395f31 + ebf40a9 commit 80a5733

19 files changed

+405
-18
lines changed

.github/workflows/wheels.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ jobs:
4242
- os: macos-13
4343
pybuilds: cp38
4444

45+
name: >
46+
${{ matrix.pybuilds }} ${{ matrix.os }} ${{ matrix.arch }}
47+
4548
steps:
4649
- uses: actions/checkout@v4
4750
- uses: actions/setup-python@v5

CMakeLists.txt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15")
1414
# <20 for embree
1515
set(CMAKE_CXX_STANDARD 17)
1616

17-
if (CMAKE_VERSION VERSION_LESS 3.18)
18-
set(DEV_MODULE Development)
19-
else()
20-
set(DEV_MODULE Development.Module)
21-
endif()
22-
23-
find_package(Python 3.8 COMPONENTS Interpreter ${DEV_MODULE} REQUIRED)
17+
find_package(Python 3.8
18+
REQUIRED COMPONENTS Interpreter Development.Module
19+
OPTIONAL_COMPONENTS Development.SABIModule)
2420

2521
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
2622
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
@@ -36,7 +32,7 @@ include(FetchContent)
3632
FetchContent_Declare(
3733
nanobind
3834
GIT_REPOSITORY https://github.com/wjakob/nanobind.git
39-
GIT_TAG v2.2.0
35+
GIT_TAG v2.7.0
4036
)
4137
FetchContent_MakeAvailable(nanobind)
4238

@@ -49,7 +45,7 @@ option(LIBIGL_RESTRICTED_TRIANGLE "Build target igl_restricted::triangle" ON)
4945
FetchContent_Declare(
5046
libigl
5147
GIT_REPOSITORY https://github.com/libigl/libigl.git
52-
GIT_TAG 788871103938ce92112714d11ea491e8e6b4d972
48+
GIT_TAG cf9ed7f492209590c42dc7247281dfdfb6618487
5349
)
5450
FetchContent_MakeAvailable(libigl)
5551

@@ -125,7 +121,10 @@ function(pyigl_include prefix name)
125121
file(WRITE "${generated_dir}/BINDING_INVOCATIONS.in" "${BINDING_INVOCATIONS}")
126122

127123
set(target_name "pyigl${prefix_lc}_${name}")
128-
nanobind_add_module(${target_name} ${sources})
124+
nanobind_add_module(
125+
${target_name}
126+
STABLE_ABI
127+
${sources})
129128

130129
# important for scikit-build
131130
install(TARGETS ${target_name} LIBRARY DESTINATION "igl/${subpath}")

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# libigl Python Bindings
22
[![PyPI version](https://badge.fury.io/py/libigl.svg)](https://pypi.org/project/libigl/)
3-
[![buildwheels](https://github.com/libigl/libigl-python-bindings/actions/workflows/wheels.yml/badge.svg)](https://github.com/libigl/libigl-python-bindings/actions/workflows/wheels.yml?query=branch%3Amain)
43

54
This repository contains the source code for the python bindings for the C++
65
[libigl](https://github.com/libigl/libigl) library written using
@@ -45,9 +44,11 @@ According to the [scikit-build-core documentation](https://scikit-build-core.rea
4544
2. Then use this very long command:
4645

4746
```
48-
python -m pip install --no-build-isolation --config-settings=editable.rebuild=true -Cbuild-dir=build -ve.
47+
CMAKE_BUILD_PARALLEL_LEVEL=10 python -m pip install --no-build-isolation --config-settings=editable.rebuild=true -Cbuild-dir=build -ve.
4948
```
5049

50+
The `CMAKE_BUILD_PARALLEL_LEVEL=10` will invoke with 10 parallel build threads.
51+
5152
### Adding a missing binding
5253

5354
Bindings are fairly mechanical to write. For example, suppose we didn't have a

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

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ build-backend = "scikit_build_core.build"
1414

1515
[project]
1616
name = "libigl"
17-
version = "2.5.4dev"
17+
version = "2.6.1.dev0"
1818
description = "libigl: A simple C++ geometry processing library"
1919
readme = "README.md"
2020
requires-python = ">=3.8"
@@ -42,6 +42,7 @@ build-dir = "build/{wheel_tag}"
4242
# Build stable ABI wheels for CPython 3.12+
4343
wheel.py-api = "cp312"
4444

45+
4546
[tool.scikit-build.cmake]
4647
build-type = "Release"
4748

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include "default_types.h"
2+
#include <igl/oriented_bounding_box.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+
10+
11+
void bind_OrientedBoundingBoxMinimizeType(nb::module_ &m)
12+
{
13+
nb::enum_<igl::OrientedBoundingBoxMinimizeType>(m, "OrientedBoundingBoxMinimizeType")
14+
.value("ORIENTED_BOUNDING_BOX_MINIMIZE_VOLUME", igl::ORIENTED_BOUNDING_BOX_MINIMIZE_VOLUME)
15+
.value("ORIENTED_BOUNDING_BOX_MINIMIZE_SURFACE_AREA", igl::ORIENTED_BOUNDING_BOX_MINIMIZE_SURFACE_AREA)
16+
.value("ORIENTED_BOUNDING_BOX_MINIMIZE_DIAGONAL_LENGTH", igl::ORIENTED_BOUNDING_BOX_MINIMIZE_DIAGONAL_LENGTH)
17+
.export_values()
18+
;
19+
}
20+

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+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include "default_types.h"
2+
#include <igl/copyleft/cgal/oriented_bounding_box.h>
3+
#include <nanobind/nanobind.h>
4+
#include <nanobind/ndarray.h>
5+
#include <nanobind/eigen/dense.h>
6+
#include <nanobind/stl/tuple.h>
7+
8+
namespace nb = nanobind;
9+
using namespace nb::literals;
10+
11+
namespace pyigl
12+
{
13+
auto oriented_bounding_box(
14+
const nb::DRef<const Eigen::MatrixXN> &P)
15+
{
16+
Eigen::MatrixXN R;
17+
igl::copyleft::cgal::oriented_bounding_box(P, R);
18+
return R;
19+
}
20+
}
21+
22+
// Bind the wrapper to the Python module
23+
void bind_oriented_bounding_box(nb::module_ &m)
24+
{
25+
m.def(
26+
"oriented_bounding_box",
27+
&pyigl::oriented_bounding_box,
28+
"P"_a,
29+
R"(Given a set of points compute the rotation transformation of them such
30+
that their axis-aligned bounding box is as small as possible.
31+
32+
igl::oriented_bounding_box is often faster and better
33+
34+
@param[in] P #P by 3 list of point locations
35+
@param[out] R rotation matrix
36+
)");
37+
38+
}
39+
40+

src/copyleft/cgal/remesh_self_intersections.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ void bind_remesh_self_intersections(nb::module_ &m)
6161
- VV: remeshed vertex positions
6262
- FF: remeshed face indices
6363
- IF: intersecting face pairs
64-
- J: birth triangle indices)");
65-
64+
- J: birth triangle indices
65+
- IM if stitch_all = true #VV list from 0 to #VV-1
66+
elseif stitch_all = false #VV list of indices into VV of unique vertices.
67+
)");
6668
}
6769

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] F #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+
}

0 commit comments

Comments
 (0)