diff --git a/cmake/LibiglDownloadExternal.cmake b/cmake/LibiglDownloadExternal.cmake index 6be958936..947a4e49e 100644 --- a/cmake/LibiglDownloadExternal.cmake +++ b/cmake/LibiglDownloadExternal.cmake @@ -139,8 +139,8 @@ endfunction() ## Triangle function(igl_download_triangle) igl_download_project(triangle - GIT_REPOSITORY https://github.com/jdumas/triangle.git - GIT_TAG 2cd0672ff1f67f9f6bb8e556e84901293e637b76 + GIT_REPOSITORY https://github.com/libigl/triangle.git + GIT_TAG d284c4a843efac043c310f5fa640b17cf7d96170 ) endfunction() @@ -155,8 +155,8 @@ endfunction() ## Predicates function(igl_download_predicates) igl_download_project(predicates - GIT_REPOSITORY https://github.com/libigl/libigl-predicates - GIT_TAG ce494af8c90c2cc699146b61c33de102fa96635b + GIT_REPOSITORY https://github.com/libigl/libigl-predicates.git + GIT_TAG 4c57c1d3f31646b010d1d58bfbe201e75c2b2ad8 ) endfunction() diff --git a/include/igl/AABB.cpp b/include/igl/AABB.cpp index f0aee73ff..1ba273a1e 100644 --- a/include/igl/AABB.cpp +++ b/include/igl/AABB.cpp @@ -1073,6 +1073,9 @@ template void igl::AABB, 2>::init, 3>::squared_distance >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::Matrix const&, double, int&, Eigen::PlainObjectBase >&) const; template bool igl::AABB, 3>::intersect_ray >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::Matrix const&, Eigen::Matrix const&, igl::Hit&) const; template void igl::AABB, 3>::squared_distance, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&) const; +template void igl::AABB, 3>::squared_distance, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&) const; +template void igl::AABB, 2>::squared_distance, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&) const; +template void igl::AABB, 3>::squared_distance, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&) const; #ifdef WIN32 template void igl::AABB,2>::squared_distance,class Eigen::Matrix,class Eigen::Matrix,class Eigen::Matrix<__int64,-1,1,0,-1,1>,class Eigen::Matrix >(class Eigen::MatrixBase > const &,class Eigen::MatrixBase > const &,class Eigen::MatrixBase > const &,class Eigen::PlainObjectBase > &,class Eigen::PlainObjectBase > &,class Eigen::PlainObjectBase > &)const; template void igl::AABB,3>::squared_distance,class Eigen::Matrix,class Eigen::Matrix,class Eigen::Matrix<__int64,-1,1,0,-1,1>,class Eigen::Matrix >(class Eigen::MatrixBase > const &,class Eigen::MatrixBase > const &,class Eigen::MatrixBase > const &,class Eigen::PlainObjectBase > &,class Eigen::PlainObjectBase > &,class Eigen::PlainObjectBase > &)const; diff --git a/include/igl/adjacency_list.cpp b/include/igl/adjacency_list.cpp index d1d43e0c7..fa6579e3b 100644 --- a/include/igl/adjacency_list.cpp +++ b/include/igl/adjacency_list.cpp @@ -132,8 +132,18 @@ IGL_INLINE void igl::adjacency_list( const std::vector > & F, std::vector >& A) { - A.clear(); - A.resize(F.maxCoeff()+1); + A.clear(); + + // Find maxCoeff + Index maxCoeff = 0; + for(const auto &vec : F) + { + for(int coeff : vec) + { + maxCoeff = std::max(coeff, maxCoeff); + } + } + A.resize(maxCoeff + 1); // Loop over faces for(int i = 0;i d - int s = F(i,j); - int d = F(i,(j+1)%F[i].size()); + int s = F[i][j]; + int d = F[i][(j+1)%F[i].size()]; A.at(s).push_back(d); A.at(d).push_back(s); } @@ -166,4 +176,5 @@ template void igl::adjacency_list, int>(Eige template void igl::adjacency_list, int>(Eigen::MatrixBase > const&, std::vector >, std::allocator > > >&, bool); template void igl::adjacency_list, int>(Eigen::MatrixBase > const&, std::vector >, std::allocator > > >&, bool); template void igl::adjacency_list, unsigned int>(class Eigen::MatrixBase > const &, class std::vector >, class std::allocator > > > &, bool); +template void igl::adjacency_list(std::vector >, std::allocator > > > const&, std::vector >, std::allocator > > >&); #endif diff --git a/include/igl/adjacency_list.h b/include/igl/adjacency_list.h index e674f0e2d..e9040da8b 100644 --- a/include/igl/adjacency_list.h +++ b/include/igl/adjacency_list.h @@ -31,7 +31,7 @@ namespace igl // See also: edges, cotmatrix, diag template IGL_INLINE void adjacency_list( - const Eigen::MatrixBase & F, + const Eigen::MatrixBase & F, std::vector >& A, bool sorted = false); diff --git a/include/igl/cat.cpp b/include/igl/cat.cpp index effa9e1b6..08c9f616b 100644 --- a/include/igl/cat.cpp +++ b/include/igl/cat.cpp @@ -251,6 +251,65 @@ IGL_INLINE void igl::cat(const std::vector > & A, Mat & C) } } +template +IGL_INLINE void igl::cat(const int dim, const std::vector & A, Eigen::PlainObjectBase & C) +{ + assert(dim == 1 || dim == 2); + using namespace Eigen; + + const int num_mat = A.size(); + if(num_mat == 0) + { + C.resize(0,0); + return; + } + + if(dim == 1) + { + const int A_cols = A[0].cols(); + + int tot_rows = 0; + for(const auto & m : A) + { + tot_rows += m.rows(); + } + + C.resize(tot_rows, A_cols); + + int cur_row = 0; + for(int i = 0; i < num_mat; i++) + { + assert(A_cols == A[i].cols()); + C.block(cur_row,0,A[i].rows(),A_cols) = A[i]; + cur_row += A[i].rows(); + } + } + else if(dim == 2) + { + const int A_rows = A[0].rows(); + + int tot_cols = 0; + for(const auto & m : A) + { + tot_cols += m.cols(); + } + + C.resize(A_rows,tot_cols); + + int cur_col = 0; + for(int i = 0; i < num_mat; i++) + { + assert(A_rows == A[i].rows()); + C.block(0,cur_col,A_rows,A[i].cols()) = A[i]; + cur_col += A[i].cols(); + } + } + else + { + fprintf(stderr,"cat.h: Error: Unsupported dimension %d\n",dim); + } +} + #ifdef IGL_STATIC_LIBRARY // Explicit template instantiation // generated by autoexplicit.sh @@ -265,4 +324,13 @@ template Eigen::Matrix igl::cat, Eigen::Matrix >(int, Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::Matrix&); template void igl::cat, Eigen::Matrix >(int, Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::Matrix&); template void igl::cat, Eigen::Matrix >(int, Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::Matrix&); +template void igl::cat, Eigen::Matrix >(int, std::vector, std::allocator > > const&, Eigen::PlainObjectBase >&); +template void igl::cat, Eigen::Matrix >(int, std::vector, std::allocator > > const&, Eigen::PlainObjectBase >&); +template void igl::cat, Eigen::Matrix >(int, std::vector, std::allocator > > const&, Eigen::PlainObjectBase >&); +template void igl::cat, Eigen::Matrix >(int, std::vector, std::allocator > > const&, Eigen::PlainObjectBase >&); +template void igl::cat, Eigen::Matrix >(int, std::vector, std::allocator > > const&, Eigen::PlainObjectBase >&); +template void igl::cat, Eigen::Matrix >(int, std::vector, std::allocator > > const&, Eigen::PlainObjectBase >&); +template void igl::cat, Eigen::Matrix >(int, std::vector, std::allocator > > const&, Eigen::PlainObjectBase >&); +template void igl::cat, Eigen::Matrix >(int, std::vector, std::allocator > > const&, Eigen::PlainObjectBase >&); +template void igl::cat, Eigen::Matrix >(int, std::vector, std::allocator > > const&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/cat.h b/include/igl/cat.h index 615bda130..02bc34fda 100644 --- a/include/igl/cat.h +++ b/include/igl/cat.h @@ -62,6 +62,16 @@ namespace igl // C template IGL_INLINE void cat(const std::vector > & A, Mat & C); + + // Concatenate a std::vector of matrices along the specified dimension + // + // Inputs: + // dim dimension along which to concatenate, 1 or 2 + // A std::vector of eigen matrices. Must have identical # cols if dim == 1 or rows if dim == 2 + // Outputs: + // C output matrix + template + IGL_INLINE void cat(const int dim, const std::vector & A, Eigen::PlainObjectBase & C); } #ifndef IGL_STATIC_LIBRARY diff --git a/include/igl/colon.cpp b/include/igl/colon.cpp index a10c2982e..0bc2112f6 100644 --- a/include/igl/colon.cpp +++ b/include/igl/colon.cpp @@ -59,8 +59,10 @@ template void igl::colon(int, double, double, Eigen template void igl::colon(double, double, Eigen::Matrix&); template void igl::colon(double, double, double, Eigen::Matrix&); template void igl::colon(int, int, Eigen::Matrix&); +template void igl::colon(int, long, Eigen::Matrix&); #ifdef WIN32 template void igl::colon(int, long long, class Eigen::Matrix &); template void igl::colon(int, __int64, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1> &); +template void igl::colon(int,__int64,class Eigen::Matrix &); #endif #endif diff --git a/include/igl/matrix_to_list.cpp b/include/igl/matrix_to_list.cpp index 1c30dff91..1cee22daf 100644 --- a/include/igl/matrix_to_list.cpp +++ b/include/igl/matrix_to_list.cpp @@ -76,4 +76,6 @@ template void igl::matrix_to_list >(Eigen::D template void igl::matrix_to_list >(Eigen::DenseBase > const&, std::vector::Scalar, std::allocator::Scalar> >&); template void igl::matrix_to_list >(Eigen::DenseBase > const&, std::vector::Scalar, std::allocator::Scalar> >&); template std::vector::Scalar, std::allocator::Scalar> > igl::matrix_to_list >(Eigen::DenseBase > const&); +template void igl::matrix_to_list, 1, -1, false> >(Eigen::DenseBase, 1, -1, false> > const&, std::vector, 1, -1, false>::Scalar, std::allocator, 1, -1, false>::Scalar> >&); +template std::vector, 1, -1, false>::Scalar, std::allocator, 1, -1, false>::Scalar> > igl::matrix_to_list, 1, -1, false> >(Eigen::DenseBase, 1, -1, false> > const&); #endif diff --git a/include/igl/octree.cpp b/include/igl/octree.cpp index 4d126bd8e..6bddf0243 100644 --- a/include/igl/octree.cpp +++ b/include/igl/octree.cpp @@ -106,7 +106,7 @@ namespace igl { for(ChildrenType i = 0; i < 8; i++){ children.emplace_back(neg_ones); point_indices.emplace_back(std::vector()); - centers.emplace_back(translate_center(curr_center,h,i)); + centers.emplace_back(translate_center(curr_center,h/2,i)); widths.emplace_back(h); } diff --git a/include/igl/point_mesh_squared_distance.cpp b/include/igl/point_mesh_squared_distance.cpp index 91241d4d9..67ee634a4 100644 --- a/include/igl/point_mesh_squared_distance.cpp +++ b/include/igl/point_mesh_squared_distance.cpp @@ -51,6 +51,7 @@ IGL_INLINE void igl::point_mesh_squared_distance( template void igl::point_mesh_squared_distance, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::Matrix const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::point_mesh_squared_distance, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::Matrix const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::point_mesh_squared_distance, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::Matrix const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::point_mesh_squared_distance, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::Matrix const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #ifdef WIN32 template void igl::point_mesh_squared_distance,class Eigen::Matrix,class Eigen::Matrix,class Eigen::Matrix<__int64,-1,1,0,-1,1>,class Eigen::Matrix >(class Eigen::PlainObjectBase > const &,class Eigen::PlainObjectBase > const &,class Eigen::Matrix const &,class Eigen::PlainObjectBase > &,class Eigen::PlainObjectBase > &,class Eigen::PlainObjectBase > &); #endif diff --git a/include/igl/predicates/predicates.cpp b/include/igl/predicates/predicates.cpp index 1d2061c60..0c8e00dee 100644 --- a/include/igl/predicates/predicates.cpp +++ b/include/igl/predicates/predicates.cpp @@ -27,6 +27,14 @@ using REAL = IGL_PREDICATES_REAL; "Shewchuk's exact predicates only support float and double") #endif +IGL_INLINE void exactinit() { + static bool initialized = false; + if (! initialized) { + ::exactinit(); + initialized = true; + } +} + template IGL_INLINE Orientation orient2d( const Eigen::MatrixBase& pa, diff --git a/include/igl/predicates/predicates.h b/include/igl/predicates/predicates.h index 508a8314f..bc3be1e6d 100644 --- a/include/igl/predicates/predicates.h +++ b/include/igl/predicates/predicates.h @@ -20,6 +20,10 @@ namespace igl { COLLINEAR=0, COPLANAR=0, COCIRCULAR=0, COSPHERICAL=0, DEGENERATE=0 }; + // Initialize internal variable used by predciates. Must be called before + // using exact predicates. + IGL_INLINE void exactinit(); + // Compute the orientation of the triangle formed by pa, pb, pc. // // Input: diff --git a/include/igl/remove_unreferenced.cpp b/include/igl/remove_unreferenced.cpp index 0f261a0ce..af2f81dc3 100644 --- a/include/igl/remove_unreferenced.cpp +++ b/include/igl/remove_unreferenced.cpp @@ -121,4 +121,5 @@ template void igl::remove_unreferenced, E template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); +template void igl::remove_unreferenced, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/slice.cpp b/include/igl/slice.cpp index adee8c8be..e2b7a8060 100644 --- a/include/igl/slice.cpp +++ b/include/igl/slice.cpp @@ -363,6 +363,9 @@ template void igl::slice(Eigen::SparseMatrix, Eigen::Array, Eigen::SparseMatrix >(Eigen::SparseMatrix const&, Eigen::DenseBase > const&, int, Eigen::SparseMatrix&); template void igl::slice, Eigen::Block const, -1, 1, true>, Eigen::Matrix >(Eigen::Matrix const&, Eigen::DenseBase const, -1, 1, true> > const&, int, Eigen::Matrix&); template void igl::slice, Eigen::Block const, -1, 1, true>, Eigen::Matrix >(Eigen::Matrix const&, Eigen::DenseBase const, -1, 1, true> > const&, int, Eigen::Matrix&); +template void igl::slice >, Eigen::Matrix, Eigen::PlainObjectBase > >(Eigen::MatrixBase > const&, Eigen::DenseBase > const&, int, Eigen::PlainObjectBase >&); +template void igl::slice, Eigen::Matrix, Eigen::Matrix >(Eigen::Matrix const&, Eigen::DenseBase > const&, int, Eigen::Matrix&); +template void igl::slice, Eigen::Block, -1, 1, true>, Eigen::Matrix >(Eigen::Matrix const&, Eigen::DenseBase, -1, 1, true> > const&, int, Eigen::Matrix&); #ifdef WIN32 template void igl::slice, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>, class Eigen::PlainObjectBase>>(class Eigen::Matrix<__int64, -1, 1, 0, -1, 1> const &, class Eigen::DenseBase> const &, int, class Eigen::PlainObjectBase> &); template void igl::slice>, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>, class Eigen::PlainObjectBase>>(class Eigen::PlainObjectBase> const &, class Eigen::DenseBase> const &, int, class Eigen::PlainObjectBase> &); diff --git a/include/igl/slice_mask.cpp b/include/igl/slice_mask.cpp index 63cb82045..b0327556f 100644 --- a/include/igl/slice_mask.cpp +++ b/include/igl/slice_mask.cpp @@ -165,4 +165,5 @@ template void igl::slice_mask >(Eigen:: template void igl::slice_mask >(Eigen::DenseBase > const&, Eigen::Array const&, int, Eigen::PlainObjectBase >&); template void igl::slice_mask >(Eigen::DenseBase > const&, Eigen::Array const&, Eigen::Array const&, Eigen::PlainObjectBase >&); template void igl::slice_mask >(Eigen::DenseBase > const&, Eigen::Array const&, int, Eigen::PlainObjectBase >&); +template void igl::slice_mask, Eigen::Matrix >(Eigen::DenseBase > const&, Eigen::Array const&, int, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/snap_points.cpp b/include/igl/snap_points.cpp index 1fc136f4c..938c2251f 100644 --- a/include/igl/snap_points.cpp +++ b/include/igl/snap_points.cpp @@ -85,5 +85,6 @@ IGL_INLINE void igl::snap_points( // Explicit template instantiation template void igl::snap_points, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&, Eigen::PlainObjectBase >&); template void igl::snap_points, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); +template void igl::snap_points, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase >&); #endif diff --git a/include/igl/writeOBJ.cpp b/include/igl/writeOBJ.cpp index 286254174..0848dbd4a 100644 --- a/include/igl/writeOBJ.cpp +++ b/include/igl/writeOBJ.cpp @@ -118,6 +118,39 @@ IGL_INLINE bool igl::writeOBJ( return true; } +template +IGL_INLINE bool igl::writeOBJ( + const std::string &str, + const Eigen::MatrixBase& V, + const std::vector >& F) +{ + using namespace std; + using namespace Eigen; + assert(V.cols() == 3 && "V should have 3 columns"); + ofstream s(str); + if(!s.is_open()) + { + fprintf(stderr,"IOError: writeOBJ() could not open %s\n",str.c_str()); + return false; + } + s< #include +#include namespace igl { @@ -50,6 +51,18 @@ namespace igl const Eigen::MatrixBase& V, const Eigen::MatrixBase& F); + // Write a mesh of mixed tris and quads to an ascii obj file + // Inputs: + // str path to outputfile + // V #V by 3 mesh vertex positions + // F #F std::vector of std::vector of size 3 or 4 mesh indices into V + // Returns true on success, false on error + template + IGL_INLINE bool writeOBJ( + const std::string &str, + const Eigen::MatrixBase& V, + const std::vector >& F); + } #ifndef IGL_STATIC_LIBRARY diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4ea221c22..8a0af135f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -81,7 +81,7 @@ if(LIBIGL_WITH_PREDICATES) file(GLOB TEST_INC_FILES ./include/igl/predicates/*.h ./include/igl/predicates/*.inl) target_sources(libigl_tests PRIVATE ${TEST_SRC_FILES} ${TEST_INC_FILES}) - target_link_libraries(libigl_tests PUBLIC igl::predicates) + target_link_libraries(libigl_tests PUBLIC igl::predicates igl::triangle) endif() file(GLOB TEST_SRC_FILES ./include/igl/*.cpp) diff --git a/tests/include/igl/cat.cpp b/tests/include/igl/cat.cpp new file mode 100644 index 000000000..094b6dc9e --- /dev/null +++ b/tests/include/igl/cat.cpp @@ -0,0 +1,43 @@ +#include +#include + +#include + +TEST_CASE("cat: rows", "[igl]") +{ + std::vector rows = { + Eigen::RowVector3i(1, 2, 3), + Eigen::RowVector3i(4, 5, 6), + Eigen::RowVector3i(7, 8, 9) + }; + + Eigen::MatrixXi actual; + igl::cat(1,rows,actual); + + Eigen::Matrix3i expected; + expected << 1, 2, 3, + 4, 5, 6, + 7, 8, 9; + + test_common::assert_eq(actual,expected); +} + +TEST_CASE("cat: cols", "[igl]") +{ + std::vector cols = { + Eigen::Vector3i(1, 4, 7), + Eigen::Vector3i(2, 5, 8), + Eigen::Vector3i(3, 6, 9) + }; + + Eigen::MatrixXi actual; + igl::cat(2,cols,actual); + + Eigen::Matrix3i expected; + expected << 1, 2, 3, + 4, 5, 6, + 7, 8, 9; + + test_common::assert_eq(actual,expected); +} + diff --git a/tests/include/igl/predicates/predicates.cpp b/tests/include/igl/predicates/predicates.cpp index 2648e4f69..dae4edb52 100644 --- a/tests/include/igl/predicates/predicates.cpp +++ b/tests/include/igl/predicates/predicates.cpp @@ -1,10 +1,12 @@ #include #include #include +#include TEST_CASE("predicates", "[igl][predicates]") { using namespace igl::predicates; using Scalar = double; + igl::predicates::exactinit(); SECTION("2D") { using Point = Eigen::Matrix; @@ -51,4 +53,25 @@ TEST_CASE("predicates", "[igl][predicates]") { REQUIRE(insphere(b, c, e, d, (-f).eval()) == Orientation::OUTSIDE); REQUIRE(insphere(f, b, d, c, e) == Orientation::INSIDE); } + + SECTION("Predicate and triangle") { + Eigen::Matrix vertices(4, 2); + Eigen::Matrix holes; + Eigen::Matrix edges; + vertices << 0.0, 0.0, + 1.0, 0.0, + 0.0, 1.0, + 1.0, 1.0; + + Eigen::Matrix out_vertices; + Eigen::Matrix out_faces; + + // Run constrained Delaunay. + igl::triangle::triangulate(vertices, edges, holes, "QcYY", + out_vertices, out_faces); + REQUIRE(out_vertices.rows() == 4); + REQUIRE(out_vertices.cols() == 2); + REQUIRE(out_faces.rows() == 2); + REQUIRE(out_faces.cols() == 3); + } }