Skip to content
Merged
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ option(LIBIGL_RESTRICTED_TRIANGLE "Build target igl_restricted::triangle" ON)
FetchContent_Declare(
libigl
GIT_REPOSITORY https://github.com/libigl/libigl.git
GIT_TAG v2.6.0
GIT_TAG cf9ed7f492209590c42dc7247281dfdfb6618487
)
FetchContent_MakeAvailable(libigl)

Expand Down
20 changes: 20 additions & 0 deletions src/OrientedBoundingBoxMinimizeType.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "default_types.h"
#include <igl/oriented_bounding_box.h>
#include <nanobind/nanobind.h>
#include <nanobind/ndarray.h>
#include <nanobind/eigen/dense.h>

namespace nb = nanobind;
using namespace nb::literals;


void bind_OrientedBoundingBoxMinimizeType(nb::module_ &m)
{
nb::enum_<igl::OrientedBoundingBoxMinimizeType>(m, "OrientedBoundingBoxMinimizeType")
.value("ORIENTED_BOUNDING_BOX_MINIMIZE_VOLUME", igl::ORIENTED_BOUNDING_BOX_MINIMIZE_VOLUME)
.value("ORIENTED_BOUNDING_BOX_MINIMIZE_SURFACE_AREA", igl::ORIENTED_BOUNDING_BOX_MINIMIZE_SURFACE_AREA)
.value("ORIENTED_BOUNDING_BOX_MINIMIZE_DIAGONAL_LENGTH", igl::ORIENTED_BOUNDING_BOX_MINIMIZE_DIAGONAL_LENGTH)
.export_values()
;
}

40 changes: 40 additions & 0 deletions src/copyleft/cgal/oriented_bounding_box.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "default_types.h"
#include <igl/copyleft/cgal/oriented_bounding_box.h>
#include <nanobind/nanobind.h>
#include <nanobind/ndarray.h>
#include <nanobind/eigen/dense.h>
#include <nanobind/stl/tuple.h>

namespace nb = nanobind;
using namespace nb::literals;

namespace pyigl
{
auto oriented_bounding_box(
const nb::DRef<const Eigen::MatrixXN> &P)
{
Eigen::MatrixXN R;
igl::copyleft::cgal::oriented_bounding_box(P, R);
return R;
}
}

// Bind the wrapper to the Python module
void bind_oriented_bounding_box(nb::module_ &m)
{
m.def(
"oriented_bounding_box",
&pyigl::oriented_bounding_box,
"P"_a,
R"(Given a set of points compute the rotation transformation of them such
that their axis-aligned bounding box is as small as possible.

igl::oriented_bounding_box is often faster and better

@param[in] P #P by 3 list of point locations
@param[out] R rotation matrix
)");

}


45 changes: 45 additions & 0 deletions src/oriented_bounding_box.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include "default_types.h"
#include <igl/oriented_bounding_box.h>
#include <nanobind/nanobind.h>
#include <nanobind/ndarray.h>
#include <nanobind/eigen/dense.h>
#include <nanobind/stl/tuple.h>

namespace nb = nanobind;
using namespace nb::literals;

namespace pyigl
{
auto oriented_bounding_box(
const nb::DRef<const Eigen::MatrixXN> &P,
const int n,
const igl::OrientedBoundingBoxMinimizeType minimize_type)
{
Eigen::MatrixXN R;
igl::oriented_bounding_box(P, n, minimize_type, R);
return R;
}
}

// Bind the wrapper to the Python module
void bind_oriented_bounding_box(nb::module_ &m)
{
m.def(
"oriented_bounding_box",
&pyigl::oriented_bounding_box,
"P"_a,
"n"_a=10000,
"minimize_type"_a=igl::ORIENTED_BOUNDING_BOX_MINIMIZE_VOLUME,
R"(Given a set of points compute the rotation transformation of them such
that their axis-aligned bounding box is as small as possible.

Consider passing the points on the convex hull of original list of points.

@param[in] P #P by 3 list of point locations
@param[in] n number of rotations to try
@param[in] minimize_type which quantity to minimize
@param[out] R rotation matrix
)");

}

1 change: 1 addition & 0 deletions src/remove_unreferenced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void bind_remove_unreferenced(nb::module_ &m)
R"(Remove unreferenced vertices from V, updating F accordingly
@param[in] V #V by dim list of mesh vertex positions
@param[in] F #F by ss list of simplices (Values of -1 are quitely skipped)
@param[out] NV #NV by dim list of simplices
@param[out] NF #NF by ss list of simplices
@param[out] I #V by 1 list of indices such that: NF = IM(F) and NT = IM(T)
and V(find(IM<=size(NV,1)),:) = NV
Expand Down
5 changes: 5 additions & 0 deletions tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,8 @@ def test_cgal():
point_indices, CH,CN,W = igl.octree(X)
I = igl.knn(X,X,20,point_indices,CH,CN,W)
A,T = igl.copyleft.cgal.point_areas(X,I,N)

R = igl.copyleft.cgal.oriented_bounding_box(VC)

def test_embree():
# octahedron
Expand Down Expand Up @@ -553,6 +555,9 @@ def test_misc():
theta, cos_theta = igl.dihedral_angles_intrinsic(L,A)
D = igl.all_pairs_distances(V,V,squared=False)
D = igl.all_pairs_distances(V,V,squared=True)
R = igl.oriented_bounding_box(V)
R = igl.oriented_bounding_box(V,n=100,minimize_type=igl.ORIENTED_BOUNDING_BOX_MINIMIZE_SURFACE_AREA)




Loading