-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d4854a
commit 4c13728
Showing
14 changed files
with
581 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "default_types.h" | ||
#include <igl/copyleft/cgal/convex_hull.h> | ||
#include <nanobind/nanobind.h> | ||
#include <nanobind/eigen/dense.h> | ||
#include <tuple> | ||
|
||
namespace nb = nanobind; | ||
using namespace nb::literals; | ||
|
||
namespace pyigl | ||
{ | ||
// Second overload: convex_hull with only output F | ||
auto convex_hull(const nb::DRef<const Eigen::MatrixXN> &V) | ||
{ | ||
Eigen::MatrixXI F; | ||
igl::copyleft::cgal::convex_hull(V, F); | ||
return F; | ||
} | ||
} | ||
|
||
// Bind the wrapper to the Python module | ||
void bind_convex_hull(nb::module_ &m) | ||
{ | ||
m.def( | ||
"convex_hull", | ||
&pyigl::convex_hull, | ||
"V"_a, | ||
R"(Compute the convex hull of a set of points, returning only the triangular faces of the hull. | ||
@param[in] V #V by 3 matrix of input points | ||
@return F: #F by 3 matrix of triangle indices into V)"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include "default_types.h" | ||
#include <igl/copyleft/cgal/fast_winding_number.h> | ||
#include <nanobind/nanobind.h> | ||
#include <nanobind/eigen/dense.h> | ||
#include <nanobind/stl/tuple.h> | ||
|
||
namespace nb = nanobind; | ||
using namespace nb::literals; | ||
|
||
namespace pyigl | ||
{ | ||
// Overload with `expansion_order` and `beta` | ||
auto fast_winding_number( | ||
const nb::DRef<const Eigen::MatrixXN> &P, | ||
const nb::DRef<const Eigen::MatrixXN> &N, | ||
const nb::DRef<const Eigen::MatrixXN> &Q, | ||
int expansion_order, | ||
double beta) | ||
{ | ||
Eigen::VectorXd WN; | ||
igl::copyleft::cgal::fast_winding_number(P, N, Q, expansion_order, beta, WN); | ||
return WN; | ||
} | ||
} | ||
|
||
// Bind the wrapper to the Python module | ||
void bind_fast_winding_number(nb::module_ &m) | ||
{ | ||
m.def( | ||
"fast_winding_number", | ||
&pyigl::fast_winding_number, | ||
"P"_a, | ||
"N"_a, | ||
"Q"_a, | ||
"expansion_order"_a = 2, | ||
"beta"_a = 2.0, | ||
R"(Evaluate the fast winding number for point data with adjustable accuracy. | ||
@param[in] P #P by 3 list of point locations | ||
@param[in] N #P by 3 list of point normals | ||
@param[in] Q #Q by 3 list of query points for the winding number | ||
@param[in] expansion_order Order of the Taylor expansion (0, 1, or 2) | ||
@param[in] beta Barnes-Hut style accuracy parameter (recommended: 2) | ||
@return Vector of winding number values for each query point)"); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#include "default_types.h" | ||
#include <igl/copyleft/cgal/intersect_other.h> | ||
#include <nanobind/nanobind.h> | ||
#include <nanobind/eigen/dense.h> | ||
#include <nanobind/stl/tuple.h> | ||
|
||
namespace nb = nanobind; | ||
using namespace nb::literals; | ||
|
||
namespace pyigl | ||
{ | ||
// First overload: intersect_other with detailed outputs | ||
auto intersect_other( | ||
const nb::DRef<const Eigen::MatrixXN> &VA, | ||
const nb::DRef<const Eigen::MatrixXI> &FA, | ||
const nb::DRef<const Eigen::MatrixXN> &VB, | ||
const nb::DRef<const Eigen::MatrixXI> &FB, | ||
const bool detect_only, | ||
const bool first_only, | ||
const bool stitch_all, | ||
const bool slow_and_more_precise_rounding, | ||
const int cutoff) | ||
{ | ||
Eigen::MatrixXI IF; | ||
Eigen::MatrixXN VVAB; | ||
Eigen::MatrixXI FFAB; | ||
Eigen::VectorXI JAB; | ||
Eigen::VectorXI IMAB; | ||
|
||
igl::copyleft::cgal::RemeshSelfIntersectionsParam params( | ||
detect_only, first_only, stitch_all, slow_and_more_precise_rounding, cutoff); | ||
const bool success = igl::copyleft::cgal::intersect_other( | ||
VA, FA, VB, FB, params, IF, VVAB, FFAB, JAB, IMAB); | ||
|
||
return std::make_tuple(IF, VVAB, FFAB, JAB, IMAB); | ||
} | ||
|
||
} | ||
|
||
// Bind the wrapper to the Python module | ||
void bind_intersect_other(nb::module_ &m) | ||
{ | ||
// First overload | ||
m.def( | ||
"intersect_other", | ||
&pyigl::intersect_other, | ||
"VA"_a, | ||
"FA"_a, | ||
"VB"_a, | ||
"FB"_a, | ||
"detect_only"_a=false, | ||
"first_only"_a=false, | ||
"stitch_all"_a=false, | ||
"slow_and_more_precise_rounding"_a=false, | ||
"cutoff"_a=1000, | ||
R"(Detect intersecting faces between two triangle meshes, providing detailed output. | ||
@param[in] VA #V by 3 list of vertices for first mesh | ||
@param[in] FA #F by 3 list of faces for first mesh | ||
@param[in] VB #V by 3 list of vertices for second mesh | ||
@param[in] FB #F by 3 list of faces for second mesh | ||
@param[in] detect_only only detect intersections, do not resolve | ||
@param[in] first_only only return first intersection | ||
@param[in] stitch_all stitch all intersections | ||
@param[in] slow_and_more_precise_rounding use slow and more precise rounding | ||
@param[in] cutoff maximum number of intersections to resolve | ||
@return Tuple containing: | ||
- success: bool indicating if the operation succeeded | ||
- IF: # intersecting face pairs | ||
- VVAB: list of intersection vertex positions | ||
- FFAB: list of triangle indices into VVAB | ||
- JAB: list of indices into [FA;FB] denoting the birth triangle | ||
- IMAB: indices stitching duplicates from intersections)"); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#include "default_types.h" | ||
#include <igl/copyleft/cgal/intersect_with_half_space.h> | ||
#include <nanobind/nanobind.h> | ||
#include <nanobind/eigen/dense.h> | ||
#include <nanobind/stl/tuple.h> | ||
|
||
namespace nb = nanobind; | ||
using namespace nb::literals; | ||
|
||
namespace pyigl | ||
{ | ||
// Overload with point and normal | ||
auto intersect_with_half_space_point_normal( | ||
const nb::DRef<const Eigen::MatrixXN> &V, | ||
const nb::DRef<const Eigen::MatrixXI> &F, | ||
const nb::DRef<const Eigen::VectorXN> &p, | ||
const nb::DRef<const Eigen::VectorXN> &n) | ||
{ | ||
Eigen::MatrixXN VC; | ||
Eigen::MatrixXI FC; | ||
Eigen::VectorXI J; | ||
|
||
if(!igl::copyleft::cgal::intersect_with_half_space(V, F, p, n, VC, FC, J)) | ||
{ | ||
throw std::runtime_error("Failed to intersect with half space"); | ||
} | ||
return std::make_tuple(VC, FC, J); | ||
} | ||
|
||
// Overload with plane equation | ||
auto intersect_with_half_space_equation( | ||
const nb::DRef<const Eigen::MatrixXN> &V, | ||
const nb::DRef<const Eigen::MatrixXI> &F, | ||
const nb::DRef<const Eigen::VectorXN> &equ) | ||
{ | ||
Eigen::MatrixXN VC; | ||
Eigen::MatrixXI FC; | ||
Eigen::VectorXI J; | ||
|
||
if(!igl::copyleft::cgal::intersect_with_half_space(V, F, equ, VC, FC, J)) | ||
{ | ||
throw std::runtime_error("Failed to intersect with half space"); | ||
} | ||
return std::make_tuple( VC, FC, J); | ||
} | ||
|
||
} | ||
|
||
// Bind the wrapper to the Python module | ||
void bind_intersect_with_half_space(nb::module_ &m) | ||
{ | ||
m.def( | ||
"intersect_with_half_space", | ||
&pyigl::intersect_with_half_space_point_normal, | ||
"V"_a, | ||
"F"_a, | ||
"p"_a, | ||
"n"_a, | ||
R"(Intersect a PWN mesh with a half-space using a point and normal. | ||
@param[in] V #V by 3 list of mesh vertex positions | ||
@param[in] F #F by 3 list of triangle indices | ||
@param[in] p 3D point on plane | ||
@param[in] n 3D normal vector | ||
@return Tuple containing: | ||
- success: bool, true if successful | ||
- VC: vertices of resulting mesh | ||
- FC: face indices of resulting mesh | ||
- J: birth facet indices)"); | ||
|
||
m.def( | ||
"intersect_with_half_space", | ||
&pyigl::intersect_with_half_space_equation, | ||
"V"_a, | ||
"F"_a, | ||
"equ"_a, | ||
R"(Intersect a PWN mesh with a half-space using the plane equation. | ||
@param[in] V #V by 3 list of mesh vertex positions | ||
@param[in] F #F by 3 list of triangle indices | ||
@param[in] equ Plane equation coefficients (a, b, c, d) | ||
@return Tuple containing: | ||
- success: bool, true if successful | ||
- VC: vertices of resulting mesh | ||
- FC: face indices of resulting mesh | ||
- J: birth facet indices)"); | ||
} |
Oops, something went wrong.