-
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.
Merge pull request #167 from libigl/alecjacobson/cgal
CGAL module
- Loading branch information
Showing
10 changed files
with
331 additions
and
15 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 |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "2.5.0dev" | ||
__version__ = "2.5.2dev" |
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,31 @@ | ||
#include <npe.h> | ||
#include <typedefs.h> | ||
|
||
#include <igl/copyleft/cgal/convex_hull.h> | ||
|
||
const char* ds_convex_hull = R"igl_Qu8mg5v7( | ||
Given a set of points (V), compute the convex hull as a triangle mesh (F) | ||
Parameters | ||
---------- | ||
V : #V by 3 list of input points | ||
Returns | ||
------- | ||
F #F by 3 list of triangle indices into V | ||
)igl_Qu8mg5v7"; | ||
|
||
npe_function(convex_hull) | ||
npe_doc(ds_convex_hull) | ||
|
||
npe_arg(v, dense_float, dense_double) | ||
npe_begin_code() | ||
|
||
EigenDenseInt g; | ||
// when https://github.com/libigl/libigl/pull/1989 is merged this copy should | ||
// be removed | ||
Eigen::MatrixXd v_copy = v.template cast<double>(); | ||
igl::copyleft::cgal::convex_hull(v_copy, g); | ||
return npe::move(g); | ||
|
||
npe_end_code() |
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 <npe.h> | ||
#include <typedefs.h> | ||
#include <igl/copyleft/cgal/intersect_other.h> | ||
|
||
|
||
|
||
const char* ds_intersect_other = R"igl_Qu8mg5v7( | ||
INTERSECT_OTHER Given a triangle mesh (VA,FA) and another mesh (VB,FB) find all | ||
pairs of intersecting faces. Note that self-intersections are ignored. | ||
Parameters | ||
---------- | ||
VA : #VA by 3 list of vertex positions of first mesh | ||
FA : #FA by 3 list of triangle indices into VA | ||
VB : #VB by 3 list of vertex positions of second mesh | ||
FB : #FB by 3 list of triangle indices into VB | ||
detect_only : avoid constructing intersections results when possible {false} | ||
first_only : return after detecting the first intersection (if | ||
first_only==true, then detect_only should also be true) {false} | ||
stitch_all : whether to stitch all resulting constructed elements into a | ||
(non-manifold) mesh {false} | ||
slow_and_more_precise_rounding : whether to use slow and more precise | ||
rounding (see assign_scalar) {false} | ||
Returns | ||
------- | ||
IF : #intersecting face pairs by 2 list of intersecting face pairs, indexing F | ||
VVAB : #VVAB by 3 list of vertex positions | ||
FFAB : #FFAB by 3 list of triangle indices into VVAB | ||
JAB : #FFAB list of indices into [FA;FB] denoting birth triangle | ||
IMAB : #VVAB list of indices stitching duplicates (resulting from | ||
mesh intersections) together | ||
See also | ||
-------- | ||
mesh_boolean | ||
)igl_Qu8mg5v7"; | ||
|
||
npe_function(intersect_other) | ||
npe_doc( ds_intersect_other) | ||
|
||
npe_arg(VA, dense_float, dense_double) | ||
npe_arg(FA, dense_int, dense_long, dense_longlong) | ||
npe_arg(VB, npe_matches(VA)) | ||
npe_arg(FB, npe_matches(FA)) | ||
npe_default_arg(detect_only, bool, false) | ||
npe_default_arg(first_only, bool, false) | ||
npe_default_arg(stitch_all, bool, false) | ||
// Awaiting bump in libigl | ||
//npe_default_arg(slow_and_more_precise_rounding, bool, false) | ||
|
||
|
||
npe_begin_code() | ||
Eigen::MatrixXd VAcpy = VA.template cast<double>(); | ||
Eigen::MatrixXi FAcpy = FA.template cast<int>(); | ||
Eigen::MatrixXd VBcpy = VB.template cast<double>(); | ||
Eigen::MatrixXi FBcpy = FB.template cast<int>(); | ||
|
||
Eigen::MatrixXd VVABcpy; | ||
Eigen::MatrixXi FFABcpy; | ||
Eigen::VectorXi JABcpy; | ||
Eigen::VectorXi IMABcpy; | ||
Eigen::MatrixXi IFcpy; | ||
igl::copyleft::cgal::RemeshSelfIntersectionsParam params; | ||
params.detect_only = detect_only; | ||
params.first_only = first_only; | ||
params.stitch_all = stitch_all; | ||
//params.slow_and_more_precise_rounding = slow_and_more_precise_rounding; | ||
igl::copyleft::cgal::intersect_other( | ||
VAcpy,FAcpy,VBcpy,FBcpy,params,IFcpy,VVABcpy,FFABcpy,JABcpy,IMABcpy); | ||
|
||
EigenDenseLike<npe_Matrix_FA> IF = IFcpy.cast<typename decltype(IF )::Scalar>(); | ||
EigenDenseLike<npe_Matrix_VA> VVAB = VVABcpy.cast<typename decltype(VVAB)::Scalar>(); | ||
EigenDenseLike<npe_Matrix_FA> FFAB = FFABcpy.cast<typename decltype(FFAB)::Scalar>(); | ||
EigenDenseLike<npe_Matrix_FA> JAB = JABcpy.cast<typename decltype( JAB)::Scalar>(); | ||
EigenDenseLike<npe_Matrix_FA> IMAB = IMABcpy.cast<typename decltype(IMAB)::Scalar>(); | ||
return std::make_tuple( | ||
npe::move(IF), | ||
npe::move(VVAB), | ||
npe::move(FFAB), | ||
npe::move( JAB), | ||
npe::move(IMAB)); | ||
npe_end_code() | ||
|
||
|
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,63 @@ | ||
#include <npe.h> | ||
#include <typedefs.h> | ||
#include <igl/copyleft/cgal/mesh_boolean.h> | ||
|
||
|
||
const char* ds_mesh_boolean = R"igl_Qu8mg5v7( | ||
MESH_BOOLEAN Compute boolean csg operations on "solid", consistently oriented | ||
meshes. | ||
Parameters | ||
---------- | ||
VA : #VA by 3 list of vertex positions of first mesh | ||
FA : #FA by 3 list of triangle indices into VA | ||
VB : #VB by 3 list of vertex positions of second mesh | ||
FB : #FB by 3 list of triangle indices into VB | ||
Returns | ||
------- | ||
VC : #VC by 3 list of vertex positions of boolean result mesh | ||
FC : #FC by 3 list of triangle indices into VC | ||
J : #FC list of indices into [FA;FA.rows()+FB] revealing "birth" facet | ||
See also | ||
-------- | ||
mesh_boolean_cork, intersect_other, remesh_self_intersections | ||
)igl_Qu8mg5v7"; | ||
|
||
npe_function(mesh_boolean) | ||
npe_doc(ds_mesh_boolean) | ||
|
||
npe_arg(va, dense_float, dense_double) | ||
npe_arg(fa, dense_int, dense_long, dense_longlong) | ||
npe_arg(vb, npe_matches(va)) | ||
npe_arg(fb, npe_matches(fa)) | ||
npe_arg(type, std::string) | ||
|
||
|
||
npe_begin_code() | ||
Eigen::MatrixXd va_copy = va.template cast<double>(); | ||
Eigen::MatrixXd vb_copy = vb.template cast<double>(); | ||
Eigen::MatrixXi fa_copy = fa.template cast<int>(); | ||
Eigen::MatrixXi fb_copy = fb.template cast<int>(); | ||
|
||
Eigen::MatrixXd vc_copy; | ||
Eigen::MatrixXi fc_copy; | ||
Eigen::VectorXi j_copy; | ||
igl::copyleft::cgal::mesh_boolean( | ||
va_copy, | ||
fa_copy, | ||
vb_copy, | ||
fb_copy, | ||
type, | ||
vc_copy, | ||
fc_copy, | ||
j_copy); | ||
|
||
EigenDenseLike<npe_Matrix_va> vc = vc_copy.cast<typename decltype(vc)::Scalar>(); | ||
EigenDenseLike<npe_Matrix_fa> fc = fc_copy.cast<typename decltype(fc)::Scalar>(); | ||
EigenDenseLike<npe_Matrix_fa> j = j_copy.cast<typename decltype( j)::Scalar>(); | ||
return std::make_tuple(npe::move(vc), npe::move(fc), npe::move(j)); | ||
npe_end_code() | ||
|
Oops, something went wrong.