Эх сурвалжийг харах

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

Former-commit-id: 39465f11242196a58cd64de580c4224984a565b9
Daniele Panozzo 9 жил өмнө
parent
commit
6425baba15

+ 2 - 2
include/igl/AABB.h

@@ -190,7 +190,7 @@ public:
           const RowVectorDIMS & p,
           int & i,
           RowVectorDIMS & c) const;
-private:
+//private:
       inline Scalar squared_distance(
           const Eigen::PlainObjectBase<DerivedV> & V,
           const Eigen::MatrixXi & Ele, 
@@ -369,7 +369,7 @@ inline void igl::AABB<DerivedV,DIM>::init(
   using namespace Eigen;
   using namespace std;
   assert(DIM == V.cols() && "V.cols() should matched declared dimension");
-  const Scalar inf = numeric_limits<Scalar>::infinity();
+  //const Scalar inf = numeric_limits<Scalar>::infinity();
   m_box = AlignedBox<Scalar,DIM>();
   // Compute bounding box
   for(int i = 0;i<I.rows();i++)

+ 4 - 1
include/igl/boolean/string_to_mesh_boolean_type.cpp

@@ -42,7 +42,10 @@ IGL_INLINE igl::boolean::MeshBooleanType igl::boolean::string_to_mesh_boolean_ty
   const std::string & s)
 {
   MeshBooleanType type;
-  const bool ret = string_to_mesh_boolean_type(s,type);
+#ifndef NDEBUG
+  const bool ret = 
+#endif
+    string_to_mesh_boolean_type(s,type);
   assert(ret && "Unknown MeshBooleanType name");
   return type;
 }

+ 3 - 2
include/igl/doublearea.cpp

@@ -116,10 +116,11 @@ IGL_INLINE void igl::doublearea(
 {
   using namespace Eigen;
   using namespace std;
+  typedef typename Derivedl::Index Index;
   // Only support triangles
   assert(ul.cols() == 3);
   // Number of triangles
-  const size_t m = ul.rows();
+  const Index m = ul.rows();
   Eigen::PlainObjectBase<Derivedl> l;
   MatrixXi _;
   sort(ul,2,false,l,_);
@@ -133,7 +134,7 @@ IGL_INLINE void igl::doublearea(
   #  define IGL_OMP_MIN_VALUE 1000
   #endif
   #pragma omp parallel for if (m>IGL_OMP_MIN_VALUE)
-  for(long long i = 0;i<m;i++)
+  for(Index i = 0;i<m;i++)
   {
     //// Heron's formula for area
     //const typename Derivedl::Scalar arg =

+ 1 - 1
include/igl/exterior_edges.cpp

@@ -86,7 +86,7 @@ IGL_INLINE void igl::exterior_edges(
       }
       // Append edge for every repeated entry
       const int abs_count = abs(count);
-      for(size_t k = 0;k<abs_count;k++)
+      for(int k = 0;k<abs_count;k++)
       {
         E(e,0) = i;
         E(e,1) = j;

+ 3 - 2
include/igl/internal_angles.cpp

@@ -64,8 +64,9 @@ IGL_INLINE void igl::internal_angles(
   const Eigen::PlainObjectBase<DerivedL>& L,
   Eigen::PlainObjectBase<DerivedK> & K)
 {
+  typedef typename DerivedL::Index Index;
   assert(L.cols() == 3 && "Edge-lengths should come from triangles");
-  const size_t m = L.rows();
+  const Index m = L.rows();
   K.resize(m,3);
   //for(int d = 0;d<3;d++)
   //{
@@ -79,7 +80,7 @@ IGL_INLINE void igl::internal_angles(
   #  define IGL_OMP_MIN_VALUE 1000
   #endif
   #pragma omp parallel for if (m>IGL_OMP_MIN_VALUE)
-  for(long long f = 0;f<m;f++)
+  for(Index f = 0;f<m;f++)
   {
     for(size_t d = 0;d<3;d++)
     {

+ 139 - 126
include/igl/outer_element.cpp

@@ -21,53 +21,60 @@ IGL_INLINE void igl::outer_vertex(
         const Eigen::PlainObjectBase<DerivedF> & F,
         const Eigen::PlainObjectBase<DerivedI> & I,
         IndexType & v_index,
-        Eigen::PlainObjectBase<DerivedA> & A) {
-    // Algorithm: 
-    //    Find an outer vertex (i.e. vertex reachable from infinity)
-    //    Return the vertex with the largest X value.
-    //    If there is a tie, pick the one with largest Y value.
-    //    If there is still a tie, pick the one with the largest Z value.
-    //    If there is still a tie, then there are duplicated vertices within the
-    //    mesh, which violates the precondition.
-    const size_t INVALID = std::numeric_limits<size_t>::max();
-    const size_t num_selected_faces = I.rows();
-    std::vector<size_t> candidate_faces;
-    size_t outer_vid = INVALID;
-    typename DerivedV::Scalar outer_val = 0;
-    for (size_t i=0; i<num_selected_faces; i++) {
-        size_t f = I(i);
-        for (size_t j=0; j<3; j++) {
-            auto v = F(f, j);
-            auto vx = V(v, 0);
-            if (outer_vid == INVALID || vx > outer_val) {
-                outer_val = vx;
-                outer_vid = v;
-                candidate_faces = {f};
-            } else if (v == outer_vid) {
-                candidate_faces.push_back(f);
-            } else if (vx == outer_val) {
-                // Break tie.
-                auto vy = V(v,1);
-                auto vz = V(v, 2);
-                auto outer_y = V(outer_vid, 1);
-                auto outer_z = V(outer_vid, 2);
-                assert(!(vy == outer_y && vz == outer_z));
-                bool replace = (vy > outer_y) ||
-                    ((vy == outer_y) && (vz > outer_z));
-                if (replace) {
-                    outer_val = vx;
-                    outer_vid = v;
-                    candidate_faces = {f};
-                }
-            }
+        Eigen::PlainObjectBase<DerivedA> & A)
+{
+  // Algorithm: 
+  //    Find an outer vertex (i.e. vertex reachable from infinity)
+  //    Return the vertex with the largest X value.
+  //    If there is a tie, pick the one with largest Y value.
+  //    If there is still a tie, pick the one with the largest Z value.
+  //    If there is still a tie, then there are duplicated vertices within the
+  //    mesh, which violates the precondition.
+  const size_t INVALID = std::numeric_limits<size_t>::max();
+  const size_t num_selected_faces = I.rows();
+  std::vector<size_t> candidate_faces;
+  size_t outer_vid = INVALID;
+  typename DerivedV::Scalar outer_val = 0;
+  for (size_t i=0; i<num_selected_faces; i++)
+  {
+    size_t f = I(i);
+    for (size_t j=0; j<3; j++)
+    {
+      auto v = F(f, j);
+      auto vx = V(v, 0);
+      if (outer_vid == INVALID || vx > outer_val)
+      {
+        outer_val = vx;
+        outer_vid = v;
+        candidate_faces = {f};
+      } else if (v == outer_vid)
+      {
+        candidate_faces.push_back(f);
+      } else if (vx == outer_val)
+      {
+        // Break tie.
+        auto vy = V(v,1);
+        auto vz = V(v, 2);
+        auto outer_y = V(outer_vid, 1);
+        auto outer_z = V(outer_vid, 2);
+        assert(!(vy == outer_y && vz == outer_z));
+        bool replace = (vy > outer_y) ||
+          ((vy == outer_y) && (vz > outer_z));
+        if (replace)
+        {
+          outer_val = vx;
+          outer_vid = v;
+          candidate_faces = {f};
         }
+      }
     }
+  }
 
-    assert(outer_vid != INVALID);
-    assert(candidate_faces.size() > 0);
-    v_index = outer_vid;
-    A.resize(candidate_faces.size());
-    std::copy(candidate_faces.begin(), candidate_faces.end(), A.data());
+  assert(outer_vid != INVALID);
+  assert(candidate_faces.size() > 0);
+  v_index = outer_vid;
+  A.resize(candidate_faces.size());
+  std::copy(candidate_faces.begin(), candidate_faces.end(), A.data());
 }
 
 template<
@@ -78,88 +85,94 @@ template<
     typename DerivedA
     >
 IGL_INLINE void igl::outer_edge(
-        const Eigen::PlainObjectBase<DerivedV> & V,
-        const Eigen::PlainObjectBase<DerivedF> & F,
-        const Eigen::PlainObjectBase<DerivedI> & I,
-        IndexType & v1,
-        IndexType & v2,
-        Eigen::PlainObjectBase<DerivedA> & A) {
-    // Algorithm:
-    //    Find an outer vertex first.
-    //    Find the incident edge with largest slope when projected onto XY plane.
-    //    If there is still a tie, break it using the projected slope onto ZX plane.
-    //    If there is still a tie, then there are multiple overlapping edges,
-    //    which violates the precondition.
-    typedef typename DerivedV::Scalar Scalar;
-    typedef typename DerivedV::Index Index;
-    typedef typename Eigen::Matrix<Scalar, 3, 1> ScalarArray3;
-    typedef typename Eigen::Matrix<typename DerivedF::Scalar, 3, 1> IndexArray3;
-    const size_t INVALID = std::numeric_limits<size_t>::max();
-
-    Index outer_vid;
-    Eigen::Matrix<Index,Eigen::Dynamic,1> candidate_faces;
-    outer_vertex(V, F, I, outer_vid, candidate_faces);
-    const ScalarArray3& outer_v = V.row(outer_vid);
-    assert(candidate_faces.size() > 0);
-
-    auto get_vertex_index = [&](const IndexArray3& f, Index vid) -> Index 
-    {
-        if (f[0] == vid) return 0;
-        if (f[1] == vid) return 1;
-        if (f[2] == vid) return 2;
-        assert(false);
-        return -1;
-    };
-
-    Scalar outer_slope_YX = 0;
-    Scalar outer_slope_ZX = 0;
-    size_t outer_opp_vid = INVALID;
-    bool infinite_slope_detected = false;
-    std::vector<Index> incident_faces;
-    auto check_and_update_outer_edge = [&](Index opp_vid, Index fid) {
-        if (opp_vid == outer_opp_vid) {
-            incident_faces.push_back(fid);
-            return;
-        }
-
-        const ScalarArray3 opp_v = V.row(opp_vid);
-        if (!infinite_slope_detected && outer_v[0] != opp_v[0]) {
-            // Finite slope
-            const ScalarArray3 diff = opp_v - outer_v;
-            const Scalar slope_YX = diff[1] / diff[0];
-            const Scalar slope_ZX = diff[2] / diff[0];
-            if (outer_opp_vid == INVALID ||
-                    slope_YX > outer_slope_YX ||
-                    (slope_YX == outer_slope_YX &&
-                     slope_ZX > outer_slope_ZX)) {
-                outer_opp_vid = opp_vid;
-                outer_slope_YX = slope_YX;
-                outer_slope_ZX = slope_ZX;
-                incident_faces = {fid};
-            }
-        } else if (!infinite_slope_detected) {
-            // Infinite slope
-            outer_opp_vid = opp_vid;
-            infinite_slope_detected = true;
-            incident_faces = {fid};
-        }
-    };
-
-    const auto num_candidate_faces = candidate_faces.size();
-    for (size_t i=0; i<num_candidate_faces; i++) {
-        const Index fid = candidate_faces(i);
-        const IndexArray3& f = F.row(fid);
-        size_t id = get_vertex_index(f, outer_vid);
-        Index next_vid = f((id+1)%3);
-        Index prev_vid = f((id+2)%3);
-        check_and_update_outer_edge(next_vid, fid);
-        check_and_update_outer_edge(prev_vid, fid);
-    }
-
-    v1 = outer_vid;
-    v2 = outer_opp_vid;
-    A.resize(incident_faces.size());
-    std::copy(incident_faces.begin(), incident_faces.end(), A.data());
+       const Eigen::PlainObjectBase<DerivedV> & V,
+       const Eigen::PlainObjectBase<DerivedF> & F,
+       const Eigen::PlainObjectBase<DerivedI> & I,
+       IndexType & v1,
+       IndexType & v2,
+       Eigen::PlainObjectBase<DerivedA> & A) {
+   // Algorithm:
+   //    Find an outer vertex first.
+   //    Find the incident edge with largest slope when projected onto XY
+   //      plane.
+   //    If there is still a tie, break it using the projected slope onto ZX
+   //      plane.
+   //    If there is still a tie, then there are multiple overlapping edges,
+   //      which violates the precondition.
+   typedef typename DerivedV::Scalar Scalar;
+   typedef typename DerivedV::Index Index;
+   typedef typename Eigen::Matrix<Scalar, 3, 1> ScalarArray3;
+   typedef typename Eigen::Matrix<typename DerivedF::Scalar, 3, 1> IndexArray3;
+   const size_t INVALID = std::numeric_limits<size_t>::max();
+
+   Index outer_vid;
+   Eigen::Matrix<Index,Eigen::Dynamic,1> candidate_faces;
+   outer_vertex(V, F, I, outer_vid, candidate_faces);
+   const ScalarArray3& outer_v = V.row(outer_vid);
+   assert(candidate_faces.size() > 0);
+
+   auto get_vertex_index = [&](const IndexArray3& f, Index vid) -> Index 
+   {
+     if (f[0] == vid) return 0;
+     if (f[1] == vid) return 1;
+     if (f[2] == vid) return 2;
+     assert(false);
+     return -1;
+   };
+
+   Scalar outer_slope_YX = 0;
+   Scalar outer_slope_ZX = 0;
+   size_t outer_opp_vid = INVALID;
+   bool infinite_slope_detected = false;
+   std::vector<Index> incident_faces;
+   auto check_and_update_outer_edge = [&](Index opp_vid, Index fid) {
+     if (opp_vid == outer_opp_vid)
+     {
+       incident_faces.push_back(fid);
+       return;
+     }
+
+     const ScalarArray3 opp_v = V.row(opp_vid);
+     if (!infinite_slope_detected && outer_v[0] != opp_v[0]) 
+     {
+       // Finite slope
+       const ScalarArray3 diff = opp_v - outer_v;
+       const Scalar slope_YX = diff[1] / diff[0];
+       const Scalar slope_ZX = diff[2] / diff[0];
+       if (outer_opp_vid == INVALID ||
+               slope_YX > outer_slope_YX ||
+               (slope_YX == outer_slope_YX &&
+                slope_ZX > outer_slope_ZX)) {
+           outer_opp_vid = opp_vid;
+           outer_slope_YX = slope_YX;
+           outer_slope_ZX = slope_ZX;
+           incident_faces = {fid};
+       }
+     } else if (!infinite_slope_detected)
+     {
+       // Infinite slope
+       outer_opp_vid = opp_vid;
+       infinite_slope_detected = true;
+       incident_faces = {fid};
+     }
+   };
+
+   const size_t num_candidate_faces = candidate_faces.size();
+   for (size_t i=0; i<num_candidate_faces; i++) 
+   {
+     const Index fid = candidate_faces(i);
+     const IndexArray3& f = F.row(fid);
+     size_t id = get_vertex_index(f, outer_vid);
+     Index next_vid = f((id+1)%3);
+     Index prev_vid = f((id+2)%3);
+     check_and_update_outer_edge(next_vid, fid);
+     check_and_update_outer_edge(prev_vid, fid);
+   }
+
+   v1 = outer_vid;
+   v2 = outer_opp_vid;
+   A.resize(incident_faces.size());
+   std::copy(incident_faces.begin(), incident_faces.end(), A.data());
 }
 
 template<

+ 0 - 3
include/igl/per_face_normals.cpp

@@ -54,9 +54,6 @@ IGL_INLINE void igl::per_face_normals_stable(
   Eigen::PlainObjectBase<DerivedN> & N)
 {
   using namespace Eigen;
-  typedef Matrix<typename DerivedN::Scalar,DerivedN::RowsAtCompileTime,3> MatrixN3;
-  typedef Matrix<typename DerivedV::Scalar,DerivedF::RowsAtCompileTime,3> MatrixV3;
-  typedef Matrix<typename DerivedV::Scalar,3,3> MatrixV33;
   typedef Matrix<typename DerivedV::Scalar,1,3> RowVectorV3;
   typedef typename DerivedV::Scalar Scalar;