Browse Source

Merge pull request #1337 from libigl/alecjacobson-patch-1

Bug fix in marching_tets
Alec Jacobson 6 years ago
parent
commit
b856e042e2
1 changed files with 4 additions and 3 deletions
  1. 4 3
      include/igl/marching_tets.cpp

+ 4 - 3
include/igl/marching_tets.cpp

@@ -147,10 +147,13 @@ void igl::marching_tets(
 
   for (int f = 0; f < faces.size(); f++)
   {
+    const int ti = faces[f].second;
+    assert(ti>=0);
+    assert(ti<TT.rows());
+    J(f) = ti;
     for (int v = 0; v < 3; v++)
     {
       const int vi = faces[f].first[v];
-      const int ti = faces[f].second;
       const pair<int32_t, int32_t> edge = edge_table[vi];
       const int64_t key = make_edge_key(edge);
       auto it = emap.find(key);
@@ -173,7 +176,6 @@ void igl::marching_tets(
         const typename DerivedTV::Scalar v_w = static_cast<typename DerivedTV::Scalar>(w);
         outV.row(num_unique) = (1-v_w)*v1 + v_w*v2;
         outF(f, v) = num_unique;
-        J[f] = ti;
 
         emap.emplace(key, num_unique);
         num_unique += 1;
@@ -183,7 +185,6 @@ void igl::marching_tets(
     }
   }
   outV.conservativeResize(num_unique, 3);
-  J.conservativeResize(num_unique, 1);
   BC.resize(num_unique, TV.rows());
   BC.setFromTriplets(bc_triplets.begin(), bc_triplets.end());
 }