Forráskód Böngészése

explicit instances

Former-commit-id: f0daf44089c37805f58f19342a47ab0dcc6b8b2e
Alec Jacobson (jalec 12 éve
szülő
commit
f911a43b02

+ 22 - 12
include/igl/boundary_faces.cpp

@@ -31,7 +31,7 @@ IGL_INLINE void igl::boundary_faces(
   // Gather faces, loop over tets
   for(int i = 0; i< (int)T.size();i++)
   {
-    assert(T[i].size() == simplex_size);
+    assert((int)T[i].size() == simplex_size);
     switch(simplex_size)
     {
       case 4:
@@ -53,33 +53,42 @@ IGL_INLINE void igl::boundary_faces(
         allF[i*simplex_size+3][2] = T[i][2];
         break;
       case 3:
-        allF[i*simplex_size+0][0] = T[i][0];
-        allF[i*simplex_size+0][1] = T[i][1];
-        allF[i*simplex_size+1][0] = T[i][1];
-        allF[i*simplex_size+1][1] = T[i][2];
-        allF[i*simplex_size+2][0] = T[i][2];
-        allF[i*simplex_size+2][1] = T[i][0];
+        allF[i*simplex_size+0][0] = T[i][1];
+        allF[i*simplex_size+0][1] = T[i][2];
+        allF[i*simplex_size+1][0] = T[i][2];
+        allF[i*simplex_size+1][1] = T[i][0];
+        allF[i*simplex_size+2][0] = T[i][0];
+        allF[i*simplex_size+2][1] = T[i][1];
         break;
     }
   }
+
   // Counts
   vector<int> C;
   face_occurences(allF,C);
 
   // Q: Why not just count the number of ones?
+  // A: because we are including non-manifold edges as boundary edges
   int twos = (int) count(C.begin(),C.end(),2);
+  //int ones = (int) count(C.begin(),C.end(),1);
   // Resize output to fit number of ones
   F.resize(allF.size() - twos);
+  //F.resize(ones);
   int k = 0;
   for(int i = 0;i< (int)allF.size();i++)
   {
-    if(C[i] == 1)
+    if(C[i] != 2)
     {
       assert(k<(int)F.size());
       F[k] = allF[i];
       k++;
     }
   }
+  assert(k==F.size());
+  //if(k != F.size())
+  //{
+  //  printf("%d =? %d\n",k,F.size());
+  //}
 
 }
 
@@ -104,11 +113,11 @@ IGL_INLINE void igl::boundary_faces(
   list_to_matrix(vF,F);
 }
 
-template <typename DerivedT, typename DerivedF>
-IGL_INLINE Eigen::PlainObjectBase<DerivedF> igl::boundary_faces(
+template <typename DerivedT, typename Ret>
+Ret igl::boundary_faces(
   const Eigen::PlainObjectBase<DerivedT>& T)
 {
-  Eigen::Matrix<typename DerivedF::Scalar, Eigen::Dynamic, Eigen::Dynamic> F;
+  Ret F; 
   igl::boundary_faces(T,F);
   return F;
 }
@@ -119,6 +128,7 @@ IGL_INLINE Eigen::PlainObjectBase<DerivedF> igl::boundary_faces(
 // Explicit template specialization
 template void igl::boundary_faces<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
 template void igl::boundary_faces<int, int>(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&);
-template Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > igl::boundary_faces(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
+//template Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > igl::boundary_faces(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
+template Eigen::Matrix<int, -1, -1, 0, -1, -1> igl::boundary_faces<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
 #endif
 

+ 2 - 2
include/igl/boundary_faces.h

@@ -36,8 +36,8 @@ namespace igl
     const Eigen::PlainObjectBase<DerivedT>& T,
     Eigen::PlainObjectBase<DerivedF>& F);
   // Same as above but returns F
-  template <typename DerivedT, typename DerivedF>
-  IGL_INLINE Eigen::PlainObjectBase<DerivedF> boundary_faces(
+  template <typename DerivedT, typename Ret>
+  Ret boundary_faces(
     const Eigen::PlainObjectBase<DerivedT>& T);
 #endif
 }

+ 2 - 1
include/igl/list_to_matrix.cpp

@@ -27,7 +27,8 @@ IGL_INLINE bool igl::list_to_matrix(const std::vector<std::vector<T > > & V,Mat
   if(n != igl::max_size(V))
   {
     fprintf(stderr,"Error: list_to_matrix()"
-      " list elements are not all the same size\n");
+      " list elements are not all the same size: (min: %d, max: %d)\n",
+      n,igl::max_size(V));
     return false;
   }
   assert(n != -1);

+ 11 - 0
include/igl/mat_min.cpp

@@ -33,6 +33,17 @@ IGL_INLINE void igl::mat_min(
   }
 }
 
+//template <typename T>
+//IGL_INLINE Eigen::Matrix<T,Eigen::Dynamic,1> igl::mat_min(
+//  const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & X,
+//  const int dim)
+//{
+//  Eigen::Matrix<T,Eigen::Dynamic,1> Y;
+//  Eigen::Matrix<int,Eigen::Dynamic,1> I;
+//  mat_min(X,dim,Y,I);
+//  return Y;
+//}
+
 #ifndef IGL_HEADER_ONLY
 // Explicit template specialization
 // generated by autoexplicit.sh

+ 6 - 0
include/igl/mat_min.h

@@ -30,6 +30,12 @@ namespace igl
     const int dim,
     Eigen::Matrix<T,Eigen::Dynamic,1> & Y,
     Eigen::Matrix<int,Eigen::Dynamic,1> & I);
+  // Use Y = X.colwise().minCoeff() instead
+  //// In-line wrapper
+  //template <typename T>
+  //IGL_INLINE Eigen::Matrix<T,Eigen::Dynamic,1> mat_min(
+  //  const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic> & X,
+  //  const int dim);
 }
 
 #ifdef IGL_HEADER_ONLY