Bläddra i källkod

fixed bug (comment out code) in signed distance

Former-commit-id: 6e1b4148b317b0873ede3668682dbb989f773233
Alec Jacobson 10 år sedan
förälder
incheckning
22dbbb7ca0
2 ändrade filer med 48 tillägg och 48 borttagningar
  1. 47 47
      include/igl/cgal/signed_distance.cpp
  2. 1 1
      include/igl/unique_simplices.cpp

+ 47 - 47
include/igl/cgal/signed_distance.cpp

@@ -168,53 +168,53 @@ IGL_INLINE void igl::signed_distance_pseudonormal(
   typedef typename Tree::Point_and_primitive_id Point_and_primitive_id;
 
   pp = tree.closest_point_and_primitive(q);
-  //Point_3 & p = pp.first;
-  //const auto & qp = q-p;
-  //sqrd = qp.squared_length();
-  //Vector3d v(qp.x(),qp.y(),qp.z());
-  //const int f = pp.second - T.begin();
-  //const Triangle_3 & t = *pp.second;
-  //// barycentric coordinates
-  //const auto & area = [&p,&t](const int i, const int j)->FT
-  //{
-  //  return sqrt(Triangle_3(p,t.vertex(i),t.vertex(j)).squared_area());
-  //};
-  //Vector3d b(area(1,2),area(2,0),area(0,1));
-  //b /= b.sum();
-  //// Determine which normal to use
-  //const double epsilon = 1e-12;
-  //const int type = (b.array()<=epsilon).cast<int>().sum();
-  //switch(type)
-  //{
-  //  case 2:
-  //    // Find vertex
-  //    for(int c = 0;c<3;c++)
-  //    {
-  //      if(b(c)>epsilon)
-  //      {
-  //        n = VN.row(F(f,c));
-  //        break;
-  //      }
-  //    }
-  //    break;
-  //  case 1:
-  //    // Find edge
-  //    for(int c = 0;c<3;c++)
-  //    {
-  //      if(b(c)<=epsilon)
-  //      {
-  //        n = EN.row(EMAP(F.rows()*c+f));
-  //        break;
-  //      }
-  //    }
-  //    break;
-  //  default:
-  //    assert(false && "all barycentric coords zero.");
-  //  case 0:
-  //    n = FN.row(f);
-  //    break;
-  //}
-  //s = (v.dot(n) >= 0 ? 1. : -1.);
+  Point_3 & p = pp.first;
+  const auto & qp = q-p;
+  sqrd = qp.squared_length();
+  Vector3d v(qp.x(),qp.y(),qp.z());
+  const int f = pp.second - T.begin();
+  const Triangle_3 & t = *pp.second;
+  // barycentric coordinates
+  const auto & area = [&p,&t](const int i, const int j)->FT
+  {
+    return sqrt(Triangle_3(p,t.vertex(i),t.vertex(j)).squared_area());
+  };
+  Vector3d b(area(1,2),area(2,0),area(0,1));
+  b /= b.sum();
+  // Determine which normal to use
+  const double epsilon = 1e-12;
+  const int type = (b.array()<=epsilon).cast<int>().sum();
+  switch(type)
+  {
+    case 2:
+      // Find vertex
+      for(int c = 0;c<3;c++)
+      {
+        if(b(c)>epsilon)
+        {
+          n = VN.row(F(f,c));
+          break;
+        }
+      }
+      break;
+    case 1:
+      // Find edge
+      for(int c = 0;c<3;c++)
+      {
+        if(b(c)<=epsilon)
+        {
+          n = EN.row(EMAP(F.rows()*c+f));
+          break;
+        }
+      }
+      break;
+    default:
+      assert(false && "all barycentric coords zero.");
+    case 0:
+      n = FN.row(f);
+      break;
+  }
+  s = (v.dot(n) >= 0 ? 1. : -1.);
 }
 
 template <typename Kernel>

+ 1 - 1
include/igl/unique_simplices.cpp

@@ -38,7 +38,7 @@ IGL_INLINE void igl::unique_simplices(
   #endif
   #pragma omp parallel for if (mff>IGL_OMP_MIN_VALUE)
   // Copy into output
-  for(int i = 0;i<mff;i++)
+  for(size_t i = 0;i<mff;i++)
   {
     FF.row(i) = F.row(IA(i));
   }