Browse Source

Merge pull request #1247 from BruegelN/fix-is_irregular_vertex

Fix igl::is_irregular_vertex()
Jérémie Dumas 6 years ago
parent
commit
ed98693ff8
2 changed files with 16 additions and 1 deletions
  1. 1 1
      include/igl/is_irregular_vertex.cpp
  2. 15 0
      tests/include/igl/is_irregular_vertex.cpp

+ 1 - 1
include/igl/is_irregular_vertex.cpp

@@ -13,7 +13,7 @@
 template <typename DerivedV, typename DerivedF>
 template <typename DerivedV, typename DerivedF>
 IGL_INLINE std::vector<bool> igl::is_irregular_vertex(const Eigen::PlainObjectBase<DerivedV> &V, const Eigen::PlainObjectBase<DerivedF> &F)
 IGL_INLINE std::vector<bool> igl::is_irregular_vertex(const Eigen::PlainObjectBase<DerivedV> &V, const Eigen::PlainObjectBase<DerivedF> &F)
 {
 {
-  Eigen::VectorXi count = Eigen::VectorXi::Zero(F.maxCoeff());
+  Eigen::VectorXi count = Eigen::VectorXi::Zero(F.maxCoeff()+1);
 
 
   for(unsigned i=0; i<F.rows();++i)
   for(unsigned i=0; i<F.rows();++i)
   {
   {

+ 15 - 0
tests/include/igl/is_irregular_vertex.cpp

@@ -0,0 +1,15 @@
+#include <test_common.h>
+#include <igl/is_irregular_vertex.h>
+
+
+TEST_CASE("is_irregular_vertex: simple", "[igl]")
+{
+    Eigen::MatrixXd V;
+    Eigen::MatrixXi F;
+    // Known "bad" mesh (many boundaries + irregular vertices, non-manifold)
+    test_common::load_mesh("truck.obj", V, F);
+    std::vector<bool> vec = igl::is_irregular_vertex(V,F);
+    // some vertices are irregular thus the sum over all vertices should evaluate to true
+    REQUIRE(std::any_of(vec.begin(),vec.end(), [](bool v) { return v; }));
+
+}