Sfoglia il codice sorgente

Merge branch 'master' of github.com:libigl/libigl

Former-commit-id: 8ca831b6311b23a6d17f59778a8a122aa1d4cc64
Alec Jacobson 9 anni fa
parent
commit
c40f5b5035

+ 1 - 3
include/igl/cgal/outer_hull.cpp

@@ -329,9 +329,7 @@ IGL_INLINE void igl::cgal::outer_hull(
   // non-intersecting.
   const auto & has_overlapping_bbox = [](
     const Eigen::PlainObjectBase<DerivedV> & V,
-    const MatrixXV & BC,
     const MatrixXG & A,
-    const MatrixXJ & AJ,
     const MatrixXG & B)->bool
   {
     const auto & bounding_box = [](
@@ -387,7 +385,7 @@ IGL_INLINE void igl::cgal::outer_hull(
       {
         continue;
       }
-      if (has_overlapping_bbox(V, BC, vG[id], vJ[id], vG[oid])) {
+      if (has_overlapping_bbox(V, vG[id], vG[oid])) {
           unresolved.push_back(oid);
       }
     }

+ 15 - 18
include/igl/cgal/points_inside_component.cpp

@@ -58,9 +58,8 @@ namespace igl {
                 return FACE;
             }
 
-            template<typename DerivedV, typename DerivedF, typename DerivedI>
+            template<typename DerivedF, typename DerivedI>
             void extract_adj_faces(
-                    const Eigen::PlainObjectBase<DerivedV>& V,
                     const Eigen::PlainObjectBase<DerivedF>& F,
                     const Eigen::PlainObjectBase<DerivedI>& I,
                     const size_t s, const size_t d,
@@ -68,24 +67,23 @@ namespace igl {
                 const size_t num_faces = I.rows();
                 for (size_t i=0; i<num_faces; i++) {
                     Eigen::Vector3i f = F.row(I(i, 0));
-                    if ((f[0] == s && f[1] == d) ||
-                        (f[1] == s && f[2] == d) ||
-                        (f[2] == s && f[0] == d)) {
+                    if (((size_t)f[0] == s && (size_t)f[1] == d) ||
+                        ((size_t)f[1] == s && (size_t)f[2] == d) ||
+                        ((size_t)f[2] == s && (size_t)f[0] == d)) {
                         adj_faces.push_back((I(i, 0)+1) * -1);
                         continue;
                     }
-                    if ((f[0] == d && f[1] == s) ||
-                        (f[1] == d && f[2] == s) ||
-                        (f[2] == d && f[0] == s)) {
+                    if (((size_t)f[0] == d && (size_t)f[1] == s) ||
+                        ((size_t)f[1] == d && (size_t)f[2] == s) ||
+                        ((size_t)f[2] == d && (size_t)f[0] == s)) {
                         adj_faces.push_back(I(i, 0)+1);
                         continue;
                     }
                 }
             }
 
-            template<typename DerivedV, typename DerivedF, typename DerivedI>
+            template<typename DerivedF, typename DerivedI>
             void extract_adj_vertices(
-                    const Eigen::PlainObjectBase<DerivedV>& V,
                     const Eigen::PlainObjectBase<DerivedF>& F,
                     const Eigen::PlainObjectBase<DerivedI>& I,
                     const size_t v, std::vector<int>& adj_vertices) {
@@ -94,13 +92,13 @@ namespace igl {
                 for (size_t i=0; i<num_faces; i++) {
                     Eigen::Vector3i f = F.row(I(i, 0));
                     assert((f.array() < V.rows()).all());
-                    if (f[0] == v) {
+                    if ((size_t)f[0] == v) {
                         unique_adj_vertices.insert(f[1]);
                         unique_adj_vertices.insert(f[2]);
-                    } else if (f[1] == v) {
+                    } else if ((size_t)f[1] == v) {
                         unique_adj_vertices.insert(f[0]);
                         unique_adj_vertices.insert(f[2]);
-                    } else if (f[2] == v) {
+                    } else if ((size_t)f[2] == v) {
                         unique_adj_vertices.insert(f[0]);
                         unique_adj_vertices.insert(f[1]);
                     }
@@ -151,7 +149,7 @@ namespace igl {
                 // query point is outside.
 
                 std::vector<int> adj_faces;
-                extract_adj_faces(V, F, I, s, d, adj_faces);
+                extract_adj_faces(F, I, s, d, adj_faces);
                 const size_t num_adj_faces = adj_faces.size();
                 assert(num_adj_faces > 0);
 
@@ -183,7 +181,7 @@ namespace igl {
                     const Eigen::PlainObjectBase<DerivedI>& I,
                     const Point_3& query, size_t s) {
                 std::vector<int> adj_vertices;
-                extract_adj_vertices(V, F, I, s, adj_vertices);
+                extract_adj_vertices(F, I, s, adj_vertices);
                 const size_t num_adj_vertices = adj_vertices.size();
 
                 std::vector<Point_3> adj_points;
@@ -226,7 +224,6 @@ namespace igl {
                 for (size_t i=0; i<num_adj_vertices; i++) {
                     const size_t vi = adj_vertices[i];
                     for (size_t j=i+1; j<num_adj_vertices; j++) {
-                        const size_t vj = adj_vertices[j];
                         Plane_3 separator(p, adj_points[i], adj_points[j]);
                         if (separator.is_degenerate()) {
                             throw "Input mesh contains degenerated faces";
@@ -237,9 +234,9 @@ namespace igl {
                             break;
                         }
                     }
-                    if (d < V.rows()) break;
+                    if (d < (size_t)V.rows()) break;
                 }
-                if (d > V.rows()) {
+                if (d > (size_t)V.rows()) {
                     // All adj faces are coplanar, use the first edge.
                     d = adj_vertices[0];
                 }

+ 3 - 3
include/igl/marching_cubes.cpp

@@ -27,9 +27,9 @@
 #include "marching_cubes_tables.h"
 #include <map>
 
-extern int edgeTable[256];
-extern int triTable[256][2][17];
-extern int polyTable[8][16];
+extern const int edgeTable[256];
+extern const int triTable[256][2][17];
+extern const int polyTable[8][16];
 
 class EdgeKey 
 {

+ 3 - 3
include/igl/marching_cubes_tables.h

@@ -33,7 +33,7 @@
 //int triTable[256][2][17];
 //int polyTable[8][16];
 
-int edgeTable[256]=
+const int edgeTable[256]=
 {
   0x0  , 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,
   0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,
@@ -73,7 +73,7 @@ int edgeTable[256]=
 //-----------------------------------------------------------------------------
 
 
-int triTable[256][2][17] =
+const int triTable[256][2][17] =
 {{{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
   { 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}},
   
@@ -896,7 +896,7 @@ int triTable[256][2][17] =
 //-----------------------------------------------------------------------------
 
 
-int polyTable[8][16] =
+const int polyTable[8][16] =
 {
   {-1},
   {-1},

+ 53 - 1
include/igl/random_quaternion.cpp

@@ -10,11 +10,12 @@
 template <typename Scalar>
 IGL_INLINE Eigen::Quaternion<Scalar> igl::random_quaternion()
 {
-  // http://mathproofs.blogspot.com/2005/05/uniformly-distributed-random-unit.html
   const auto & unit_rand = []()->Scalar
   {
     return ((Scalar)rand() / (Scalar)RAND_MAX);
   };
+#ifdef false
+  // http://mathproofs.blogspot.com/2005/05/uniformly-distributed-random-unit.html
   const Scalar t0 = 2.*M_PI*unit_rand();
   const Scalar t1 = acos(1.-2.*unit_rand());
   const Scalar t2 = 0.5*(M_PI*unit_rand() + acos(unit_rand()));
@@ -23,6 +24,57 @@ IGL_INLINE Eigen::Quaternion<Scalar> igl::random_quaternion()
     1.*cos(t0)*sin(t1)*sin(t2),
     1.*cos(t1)*sin(t2),
     1.*cos(t2));
+#elif false
+  // "Uniform Random Rotations" [Shoemake 1992] method 1
+  const auto & uurand = [&unit_rand]()->Scalar
+  {
+    return unit_rand()*2.-1.; 
+  };
+  Scalar x = uurand();
+  Scalar y = uurand();
+  Scalar z = uurand();
+  Scalar w = uurand();
+  const auto & hype = [&uurand](Scalar & x, Scalar & y)->Scalar
+  {
+    Scalar s1;
+    while((s1 = x*x + y*y) > 1.0)
+    {
+      x = uurand();
+      y = uurand();
+    }
+    return s1;
+  };
+  Scalar s1 = hype(x,y);
+  Scalar s2 = hype(z,w);
+  Scalar num1 = -2.*log(s1);
+  Scalar num2 = -2.*log(s2);
+  Scalar r = num1 + num2;
+  Scalar root1 = sqrt((num1/s1)/r);
+  Scalar root2 = sqrt((num2/s2)/r);
+  return Eigen::Quaternion<Scalar>(
+    x*root1,
+    y*root1,
+    z*root2,
+    w*root2);
+#else
+  // Shoemake method 2
+  const Scalar x0 = unit_rand();
+  const Scalar x1 = unit_rand();
+  const Scalar x2 = unit_rand();
+  const Scalar r1 = sqrt(1.0 - x0);
+  const Scalar r2 = sqrt(x0);
+  const Scalar t1 = 2.*M_PI*x1;
+  const Scalar t2 = 2.*M_PI*x2;
+  const Scalar c1 = cos(t1);
+  const Scalar s1 = sin(t1);
+  const Scalar c2 = cos(t2);
+  const Scalar s2 = sin(t2);
+  return Eigen::Quaternion<Scalar>(
+    s1*r1,
+    c1*r1,
+    s2*r2,
+    c2*r2);
+#endif
 }
 
 #ifdef IGL_STATIC_LIBRARY