Browse Source

Last change before reorganizing directory structure

Former-commit-id: 8dd2ae4a03e5d622d540cc9a9dc7948b9d073849
jalec 13 years ago
parent
commit
cbfeadfbdb
8 changed files with 64 additions and 7 deletions
  1. 27 2
      list_to_matrix.cpp
  2. 3 0
      list_to_matrix.h
  3. 4 2
      matlab-to-eigen.html
  4. 1 0
      matlab_workspace.cpp
  5. 22 0
      matlab_workspace.h
  6. 1 0
      max_size.cpp
  7. 1 0
      min_size.cpp
  8. 5 3
      on_boundary.cpp

+ 27 - 2
list_to_matrix.cpp

@@ -13,14 +13,14 @@
 template <typename T, class Mat>
 IGL_INLINE bool igl::list_to_matrix(const std::vector<std::vector<T > > & V,Mat & M)
 {
-  // number of columns
+  // number of rows
   int m = V.size();
   if(m == 0)
   {
     fprintf(stderr,"Error: list_to_matrix() list is empty()\n");
     return false;
   }
-  // number of rows
+  // number of columns
   int n = igl::min_size(V);
   if(n != igl::max_size(V))
   {
@@ -45,6 +45,29 @@ IGL_INLINE bool igl::list_to_matrix(const std::vector<std::vector<T > > & V,Mat
   return true;
 }
 
+template <typename T, class Mat>
+IGL_INLINE bool igl::list_to_matrix(const std::vector<T > & V,Mat & M)
+{
+  // number of rows
+  int m = V.size();
+  if(m == 0)
+  {
+    fprintf(stderr,"Error: list_to_matrix() list is empty()\n");
+    return false;
+  }
+  assert(n != -1);
+  // Resize output
+  M.resize(m,1);
+
+  // Loop over rows
+  for(int i = 0;i<m;i++)
+  {
+    M(i) = V[i];
+  }
+
+  return true;
+}
+
 #ifndef IGL_HEADER_ONLY
 // Explicit template specialization
 // generated by autoexplicit.sh
@@ -59,4 +82,6 @@ template bool igl::list_to_matrix<int, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(s
 template bool igl::list_to_matrix<double, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > const&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&);
 // generated by autoexplicit.sh
 template bool igl::list_to_matrix<double, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1>&);
+template bool igl::list_to_matrix<bool, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > >(std::vector<bool, std::allocator<bool> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
+template bool igl::list_to_matrix<bool, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > >(std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
 #endif

+ 3 - 0
list_to_matrix.h

@@ -17,6 +17,9 @@ namespace igl
   // Returns true on success, false on errors
   template <typename T, class Mat>
   IGL_INLINE bool list_to_matrix(const std::vector<std::vector<T > > & V,Mat & M);
+  // Vector wrapper
+  template <typename T, class Mat>
+  IGL_INLINE bool list_to_matrix(const std::vector<T > & V,Mat & M);
 }
 
 #ifdef IGL_HEADER_ONLY

+ 4 - 2
matlab-to-eigen.html

@@ -218,13 +218,15 @@ tr.gotcha2 td
       <tr class=d1>
         <td><pre><code>B = A(I,J)<br>B = A(I,:)</code></pre></td>
         <td><pre><code>igl::slice(A,I,J,B)<br>B = igl::slice(A,I,igl::colon(0,A.cols()-1))</code></pre></td>
-        <td></td>
+        <td>This is only for the case when I and J are lists of indices and
+        not vectors of logicals.</td>
       </tr>
 
       <tr class=d0>
         <td><pre><code>B(I,J) = A<br>B(I,:) = A</code></pre></td>
         <td><pre><code>igl::slice_into(A,I,J,B)<br>B = igl::slice_into(A,I,igl::colon(0,B.cols()-1))</code></pre></td>
-        <td></td>
+        <td>This is only for the case when I and J are lists of indices and
+        not vectors of logicals.</td>
       </tr>
 
       <tr class=d1>

+ 1 - 0
matlab_workspace.cpp

@@ -0,0 +1 @@
+#include "matlab_workspace.h"

+ 22 - 0
matlab_workspace.h

@@ -0,0 +1,22 @@
+#ifndef IGL_WRITE_MATLAB_WORKSPACE
+#define IGL_WRITE_MATLAB_WORKSPACE
+#include "igl_inline.h"
+
+namespace igl
+{
+  // Class which contains data of a matlab workspace which can be written to a
+  // .mat file and loaded from matlab
+  // 
+  // This depends on matlab at compile time (though it shouldn't necessarily
+  // have to) but it does not depend on running the matlab engine at run-time.
+  class matlab_workspace
+  {
+  };
+}
+
+#ifdef IGL_HEADER_ONLY
+#  include "matlab_workspace.cpp"
+#endif
+
+#endif
+

+ 1 - 0
max_size.cpp

@@ -23,4 +23,5 @@ IGL_INLINE int igl::max_size(const std::vector<T> & V)
 template int igl::max_size<std::vector<int, std::allocator<int> > >(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&);
 // generated by autoexplicit.sh
 template int igl::max_size<std::vector<double, std::allocator<double> > >(std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > const&);
+template int igl::max_size<std::vector<bool, std::allocator<bool> > >(std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > > const&);
 #endif

+ 1 - 0
min_size.cpp

@@ -29,4 +29,5 @@ IGL_INLINE int igl::min_size(const std::vector<T> & V)
 template int igl::min_size<std::vector<int, std::allocator<int> > >(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&);
 // generated by autoexplicit.sh
 template int igl::min_size<std::vector<double, std::allocator<double> > >(std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > const&);
+template int igl::min_size<std::vector<bool, std::allocator<bool> > >(std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > > const&);
 #endif

+ 5 - 3
on_boundary.cpp

@@ -2,6 +2,7 @@
 
 // IGL includes
 #include "sort.h"
+#include "face_occurences.h"
 
 // STL includes
 #include <map>
@@ -50,7 +51,7 @@ IGL_INLINE void igl::on_boundary(
       C[i][j] = FC[i*4+j]==1;
       assert(C[i][j] == 2 || C[i][j] == 1);
       // if any are on boundary set to true
-      I[i] |= C[i][j];
+      I[i] = I[i] || C[i][j];
     }
   }
 
@@ -74,8 +75,8 @@ IGL_INLINE void igl::on_boundary(
   // Cop out: use vector of vectors version
   vector<vector<typename Eigen::PlainObjectBase<DerivedT>::Scalar> > vT;
   matrix_to_list(T,vT);
-  vector<vector<typename Eigen::PlainObjectBase<DerivedI>::Scalar> > vI;
-  vector<vector<typename Eigen::PlainObjectBase<DerivedC>::Scalar> > vC;
+  vector<bool> vI;
+  vector<vector<bool> > vC;
   on_boundary(vT,vI,vC);
   list_to_matrix(vI,I);
   list_to_matrix(vC,C);
@@ -85,6 +86,7 @@ IGL_INLINE void igl::on_boundary(
 
 #ifndef IGL_HEADER_ONLY
 // Explicit template specialization
+template void igl::on_boundary<Eigen::Matrix<int, -1, -1, 0, -1, -1>, 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> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
 #endif