ソースを参照

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

# Conflicts:
#	include/igl/triangle_triangle_adjacency.h


Former-commit-id: 05ce3a720072feb7e70d088497c1576aa2eabdce
Daniele Panozzo 9 年 前
コミット
6f3f5bdabe

+ 8 - 10
include/igl/average_onto_vertices.cpp

@@ -7,15 +7,15 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "average_onto_vertices.h"
 
-template <typename T, typename I>
-IGL_INLINE void igl::average_onto_vertices(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &V,
-            const Eigen::Matrix<I, Eigen::Dynamic, Eigen::Dynamic> &F,
-            const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &S,
-            Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &SV)
+template<typename DerivedV,typename DerivedF,typename DerivedS>
+IGL_INLINE void igl::average_onto_vertices(const Eigen::MatrixBase<DerivedV> &V,
+  const Eigen::MatrixBase<DerivedF> &F,
+  const Eigen::MatrixBase<DerivedS> &S,
+  Eigen::MatrixBase<DerivedS> &SV)
 {
-
-  SV = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>::Zero(V.rows(),S.cols());
-  Eigen::Matrix<T, Eigen::Dynamic, 1> COUNT = Eigen::Matrix<T, Eigen::Dynamic, 1>::Zero(V.rows());
+  SV = DerivedS::Zero(V.rows(),S.cols());
+  Eigen::Matrix<typename DerivedF::Scalar,Eigen::Dynamic,1> COUNT(V.rows());
+  COUNT.setZero();
   for (int i = 0; i <F.rows(); ++i)
   {
     for (int j = 0; j<F.cols(); ++j)
@@ -26,10 +26,8 @@ IGL_INLINE void igl::average_onto_vertices(const Eigen::Matrix<T, Eigen::Dynamic
   }
   for (int i = 0; i <V.rows(); ++i)
     SV.row(i) /= COUNT[i];
-
 };
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template void igl::average_onto_vertices<double, int>(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&);
 #endif

+ 5 - 6
include/igl/average_onto_vertices.h

@@ -21,12 +21,11 @@ namespace igl
   // 
   // Output:
   // SV: scalar field defined on vertices
-  template <typename T, typename I>
-  IGL_INLINE void average_onto_vertices(
-    const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &V,
-    const Eigen::Matrix<I, Eigen::Dynamic, Eigen::Dynamic> &F,
-    const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &S,
-    Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> &SV);
+  template<typename DerivedV,typename DerivedF,typename DerivedS>
+  IGL_INLINE void average_onto_vertices(const Eigen::MatrixBase<DerivedV> &V,
+    const Eigen::MatrixBase<DerivedF> &F,
+    const Eigen::MatrixBase<DerivedS> &S,
+    Eigen::MatrixBase<DerivedS> &SV);
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 2 - 2
include/igl/boundary_loop.cpp

@@ -23,8 +23,8 @@ IGL_INLINE void igl::boundary_loop(
   if(F.rows() == 0)
     return;
 
-  MatrixXd Vdummy(F.maxCoeff()+1,1);
-  MatrixXi TT,TTi;
+  VectorXd Vdummy(F.maxCoeff()+1,1);
+  DerivedF TT,TTi;
   vector<std::vector<int> > VF, VFi;
   triangle_triangle_adjacency(F,TT,TTi);
   vertex_triangle_adjacency(Vdummy,F,VF,VFi);

+ 15 - 6
include/igl/embree/EmbreeIntersector.h

@@ -57,11 +57,13 @@ namespace igl
       // Inputs:
       //   V  #V by 3 list of vertex positions
       //   F  #F by 3 list of Oriented triangles
+      //   isStatic  scene is optimized for static geometry
       // Side effects:
       //   The first time this is ever called the embree engine is initialized.
       inline void init(
         const PointMatrixType& V,
-        const FaceMatrixType& F);
+        const FaceMatrixType& F,
+        bool isStatic = false);
 
       // Initialize with a given mesh.
       //
@@ -69,12 +71,14 @@ namespace igl
       //   V  vector of #V by 3 list of vertex positions for each geometry
       //   F  vector of #F by 3 list of Oriented triangles for each geometry
       //   masks  a 32 bit mask to identify active geometries.
+      //   isStatic  scene is optimized for static geometry
       // Side effects:
       //   The first time this is ever called the embree engine is initialized.
       inline void init(
         const std::vector<const PointMatrixType*>& V,
         const std::vector<const FaceMatrixType*>& F,
-        const std::vector<int>& masks);
+        const std::vector<int>& masks,
+        bool isStatic = false);
 
       // Deinitialize embree datasctructures for current mesh.  Also called on
       // destruction: no need to call if you just want to init() once and
@@ -252,7 +256,8 @@ inline igl::embree::EmbreeIntersector & igl::embree::EmbreeIntersector::operator
 
 inline void igl::embree::EmbreeIntersector::init(
   const PointMatrixType& V,
-  const FaceMatrixType& F)
+  const FaceMatrixType& F,
+  bool isStatic)
 {
   std::vector<const PointMatrixType*> Vtemp;
   std::vector<const FaceMatrixType*> Ftemp;
@@ -260,13 +265,14 @@ inline void igl::embree::EmbreeIntersector::init(
   Vtemp.push_back(&V);
   Ftemp.push_back(&F);
   masks.push_back(0xFFFFFFFF);
-  init(Vtemp,Ftemp,masks);
+  init(Vtemp,Ftemp,masks,isStatic);
 }
 
 inline void igl::embree::EmbreeIntersector::init(
   const std::vector<const PointMatrixType*>& V,
   const std::vector<const FaceMatrixType*>& F,
-  const std::vector<int>& masks)
+  const std::vector<int>& masks,
+  bool isStatic)
 {
 
   if(initialized)
@@ -282,7 +288,10 @@ inline void igl::embree::EmbreeIntersector::init(
   }
 
   // create a scene
-  scene = rtcNewScene(RTC_SCENE_ROBUST | RTC_SCENE_HIGH_QUALITY,RTC_INTERSECT1);
+  RTCSceneFlags flags = RTC_SCENE_ROBUST | RTC_SCENE_HIGH_QUALITY;
+  if(isStatic)
+    flags = flags | RTC_SCENE_STATIC;
+  scene = rtcNewScene(flags,RTC_INTERSECT1);
 
   for(int g=0;g<(int)V.size();g++)
   {

+ 2 - 1
include/igl/is_border_vertex.cpp

@@ -12,7 +12,7 @@
 
 template <typename DerivedV, typename DerivedF>
 IGL_INLINE std::vector<bool> igl::is_border_vertex(
-    const Eigen::PlainObjectBase<DerivedV> &V, 
+    const Eigen::PlainObjectBase<DerivedV> &V,
     const Eigen::PlainObjectBase<DerivedF> &F)
 {
   DerivedF FF;
@@ -35,4 +35,5 @@ IGL_INLINE std::vector<bool> igl::is_border_vertex(
 // Explicit template specialization
 template std::vector<bool, std::allocator<bool> > igl::is_border_vertex<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&);
 template std::vector<bool, std::allocator<bool> > igl::is_border_vertex<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
+template std::vector<bool, std::allocator<bool> > igl::is_border_vertex<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
 #endif

+ 18 - 16
include/igl/lim/lim.cpp

@@ -8,37 +8,39 @@
 #include "lim.h"
 #include <LIMSolverInterface.h>
 
-IGL_INLINE int igl::lim::lim(
+using namespace igl::lim;
+
+IGL_INLINE State lim(
   Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
   const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
   const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
   const Eigen::SparseMatrix<double>& constraintMatrix,
   const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
-  int energyType,
+  Energy energyType,
   double tolerance,
   int maxIteration,
   bool findLocalMinima)
 {
-  return ComputeLIM(
+  return (State)ComputeLIM(
     vertices,
     initialVertices,
     elements,
     constraintMatrix,
     constraintTargets,
-    energyType,
+    (EnergyType)energyType,
     tolerance,
     maxIteration,
     findLocalMinima
     );
 }
 
-IGL_INLINE int igl::lim(
+IGL_INLINE State igl::lim::lim(
   Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
   const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
   const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
   const Eigen::SparseMatrix<double>& constraintMatrix,
   const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
-  int energyType,
+  Energy energyType,
   double tolerance,
   int maxIteration,
   bool findLocalMinima,
@@ -48,13 +50,13 @@ IGL_INLINE int igl::lim(
   double beta,
   double eps)
 {
-  return ComputeLIM(
+  return (State)ComputeLIM(
     vertices,
     initialVertices,
     elements,
     constraintMatrix,
     constraintTargets,
-    energyType,
+    (EnergyType)energyType,
     tolerance,
     maxIteration,
     findLocalMinima,
@@ -66,7 +68,7 @@ IGL_INLINE int igl::lim(
     );
 }
 
-IGL_INLINE int igl::lim(
+IGL_INLINE State igl::lim::lim(
   Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
   const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
   const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
@@ -74,12 +76,12 @@ IGL_INLINE int igl::lim(
   const Eigen::Matrix<double,Eigen::Dynamic,1>& gradients,
   const Eigen::SparseMatrix<double>& constraintMatrix,
   const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
-  int energyType,
+  Energy energyType,
   double tolerance,
   int maxIteration,
   bool findLocalMinima)
 {
-  return ComputeLIM(
+  return (State)ComputeLIM(
     vertices,
     initialVertices,
     elements,
@@ -87,14 +89,14 @@ IGL_INLINE int igl::lim(
     gradients,
     constraintMatrix,
     constraintTargets,
-    energyType,
+    (EnergyType)energyType,
     tolerance,
     maxIteration,
     findLocalMinima
     );
 }
 
-IGL_INLINE int igl::lim(
+IGL_INLINE State igl::lim::lim(
   Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
   const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
   const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
@@ -102,7 +104,7 @@ IGL_INLINE int igl::lim(
   const Eigen::Matrix<double,Eigen::Dynamic,1>& gradients,
   const Eigen::SparseMatrix<double>& constraintMatrix,
   const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
-  int energyType,
+  Energy energyType,
   double tolerance,
   int maxIteration,
   bool findLocalMinima,
@@ -112,7 +114,7 @@ IGL_INLINE int igl::lim(
   double beta,
   double eps)
 {
-  return ComputeLIM(
+  return (State)ComputeLIM(
     vertices,
     initialVertices,
     elements,
@@ -120,7 +122,7 @@ IGL_INLINE int igl::lim(
     gradients,
     constraintMatrix,
     constraintTargets,
-    energyType,
+    (EnergyType)energyType,
     tolerance,
     maxIteration,
     findLocalMinima,

+ 16 - 17
include/igl/lim/lim.h

@@ -15,9 +15,6 @@ namespace igl
 {
   namespace lim
   {
-    // Known issues: energy type should be a readable enum rather than magic
-    // ints.
-    //
     // Computes a locally injective mapping of a triangle or tet-mesh based on
     // a deformation energy subject to some provided linear positional
     // constraints Cv-d.
@@ -39,7 +36,7 @@ namespace igl
     //                     y_2, ..., x_v,y_v])
     //   constraintTargets d: c vector target positions
     //   energyType        type of used energy:
-    //                     0=Dirichlet,1=Laplacian,2=Green,3=ARAP,4=LSCM
+    //                     Dirichlet, Laplacian, Green, ARAP, LSCM, Poisson (only 2D), UniformLaplacian, Identity
     //   tolerance         max squared positional constraints error
     //   maxIteration      max number of iterations
     //   findLocalMinima   iterating until a local minima is found. If not
@@ -61,30 +58,32 @@ namespace igl
     //                   mesh
     //--------------------------------------------------------------------------
     // Return values:
-    //  1 : Optimization deemed successful because either (a) it stagnated
-    //    (very step size) or (b) positional constraints were satisfied. (re:
-    //    https://github.com/libigl/libigl/issues/79 )
-    // -1 : Max iteration reached before tolerance was fulfilled
-    // -2 : not feasible -> has inverted elements (may want to decrease eps?)
+    //  Succeeded : Successful optimization with fulfilled tolerance
+    //  LocalMinima : Convergenged to a local minima / tolerance not fullfilled
+    //  IterationLimit : Max iteration reached before tolerance was fulfilled
+    //  Infeasible : not feasible -> has inverted elements (decrease eps?)
   
-    int lim(
+    enum Energy { Dirichlet = 0, Laplacian=1, Green=2, ARAP=3, LSCM=4, Poisson=5, UniformLaplacian=6, Identity=7 };
+    enum State { Uninitialized = -4, Infeasible = -3, IterationLimit = -2, LocalMinima = -1, Running = 0, Succeeded = 1 };
+
+    State lim(
       Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
       const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
       const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
       const Eigen::SparseMatrix<double>& constraintMatrix,
       const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
-      int energyType,
+      Energy energyType,
       double tolerance,
       int maxIteration,
       bool findLocalMinima);
   
-    int lim(
+    State lim(
       Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
       const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
       const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
       const Eigen::SparseMatrix<double>& constraintMatrix,
       const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
-      int energyType,
+      Energy energyType,
       double tolerance,
       int maxIteration,
       bool findLocalMinima,
@@ -94,7 +93,7 @@ namespace igl
       double beta,
       double eps);
   
-    int lim(
+    State lim(
       Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
       const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
       const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
@@ -102,12 +101,12 @@ namespace igl
       const Eigen::Matrix<double,Eigen::Dynamic,1>& gradients,
       const Eigen::SparseMatrix<double>& constraintMatrix,
       const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
-      int energyType,
+      Energy energyType,
       double tolerance,
       int maxIteration,
       bool findLocalMinima);
   
-    int lim(
+    State lim(
       Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
       const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
       const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
@@ -115,7 +114,7 @@ namespace igl
       const Eigen::Matrix<double,Eigen::Dynamic,1>& gradients,
       const Eigen::SparseMatrix<double>& constraintMatrix,
       const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
-      int energyType,
+      Energy energyType,
       double tolerance,
       int maxIteration,
       bool findLocalMinima,

+ 25 - 55
include/igl/list_to_matrix.cpp

@@ -15,8 +15,8 @@
 #include "max_size.h"
 #include "min_size.h"
 
-template <typename T, class Mat>
-IGL_INLINE bool igl::list_to_matrix(const std::vector<std::vector<T > > & V,Mat & M)
+template <typename T, typename Derived>
+IGL_INLINE bool igl::list_to_matrix(const std::vector<std::vector<T > > & V,Eigen::PlainObjectBase<Derived>& M)
 {
   // number of rows
   int m = V.size();
@@ -48,12 +48,12 @@ IGL_INLINE bool igl::list_to_matrix(const std::vector<std::vector<T > > & V,Mat
   return true;
 }
 
-template <typename T, class Mat>
+template <typename T, typename Derived>
 IGL_INLINE bool igl::list_to_matrix(
   const std::vector<std::vector<T > > & V,
   const int n,
   const T & padding,
-  Mat & M)
+  Eigen::PlainObjectBase<Derived>& M)
 {
   const int m = V.size();
   M.resize(m,n);
@@ -77,8 +77,8 @@ IGL_INLINE bool igl::list_to_matrix(
   return true;
 }
 
-template <typename T, class Mat>
-IGL_INLINE bool igl::list_to_matrix(const std::vector<T > & V,Mat & M)
+template <typename T, typename Derived>
+IGL_INLINE bool igl::list_to_matrix(const std::vector<T > & V,Eigen::PlainObjectBase<Derived>& M)
 {
   // number of rows
   int m = V.size();
@@ -86,10 +86,10 @@ IGL_INLINE bool igl::list_to_matrix(const std::vector<T > & V,Mat & M)
   {
     //fprintf(stderr,"Error: list_to_matrix() list is empty()\n");
     //return false;
-    if(Mat::ColsAtCompileTime == 1)
+    if(Eigen::PlainObjectBase<Derived>::ColsAtCompileTime == 1)
     {
       M.resize(0,1);
-    }else if(Mat::RowsAtCompileTime == 1)
+    }else if(Eigen::PlainObjectBase<Derived>::RowsAtCompileTime == 1)
     {
       M.resize(1,0);
     }else
@@ -99,7 +99,7 @@ IGL_INLINE bool igl::list_to_matrix(const std::vector<T > & V,Mat & M)
     return true;
   }
   // Resize output
-  if(Mat::RowsAtCompileTime == 1)
+  if(Eigen::PlainObjectBase<Derived>::RowsAtCompileTime == 1)
   {
     M.resize(1,m);
   }else
@@ -118,50 +118,20 @@ IGL_INLINE bool igl::list_to_matrix(const std::vector<T > & V,Mat & M)
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-// generated by autoexplicit.sh
-template bool igl::list_to_matrix<unsigned int, Eigen::PlainObjectBase<Eigen::Matrix<unsigned int, -1, 3, 1, -1, 3> > >(std::vector<std::vector<unsigned int, std::allocator<unsigned int> >, std::allocator<std::vector<unsigned int, std::allocator<unsigned int> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned int, -1, 3, 1, -1, 3> >&);
-// generated by autoexplicit.sh
-template bool igl::list_to_matrix<float, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > >(std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> >&);
-// generated by autoexplicit.sh
-template bool igl::list_to_matrix<double, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > >(std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> >&);
-// generated by autoexplicit.sh
-template bool igl::list_to_matrix<double, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(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<int, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > >(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
-// generated by autoexplicit.sh
-template bool igl::list_to_matrix<double, Eigen::PlainObjectBase<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::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
-// generated by autoexplicit.sh
-template bool igl::list_to_matrix<double, Eigen::PlainObjectBase<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::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
-// generated by autoexplicit.sh
-template bool igl::list_to_matrix<int, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&, Eigen::Matrix<int, -1, -1, 0, -1, -1>&);
-// generated by autoexplicit.sh
-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> >&);
-template bool igl::list_to_matrix<int, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > >(std::vector<int, std::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
-template bool igl::list_to_matrix<int, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&);
-template bool igl::list_to_matrix<int, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(std::vector<int, std::allocator<int> > const&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&);
-template bool igl::list_to_matrix<double, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> > >(std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> >&);
-template bool igl::list_to_matrix<double, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 2, 1, -1, 2> > >(std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 2, 1, -1, 2> >&);
-template bool igl::list_to_matrix<int, Eigen::PlainObjectBase<Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1> > >(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1> >&);
-template bool igl::list_to_matrix<int, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(std::vector<int, std::allocator<int> > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1>&);
-template bool igl::list_to_matrix<int, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > >(std::vector<int, std::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
-template bool igl::list_to_matrix<double, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > >(std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&);
-template bool igl::list_to_matrix<int, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > >(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
-template bool igl::list_to_matrix<double, Eigen::Matrix<double, 1, -1, 1, 1, -1> >(std::vector<double, std::allocator<double> > const&, Eigen::Matrix<double, 1, -1, 1, 1, -1>&);
-template bool igl::list_to_matrix<unsigned long, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > >(std::vector<unsigned long, std::allocator<unsigned long> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
-template bool igl::list_to_matrix<double, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(std::vector<double, std::allocator<double> > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1>&);
-template bool igl::list_to_matrix<float, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> > >(std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> >&);
-template bool igl::list_to_matrix<double, Eigen::Matrix<double, -1, 2, 0, -1, 2> >(std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > const&, Eigen::Matrix<double, -1, 2, 0, -1, 2>&);
-template bool igl::list_to_matrix<double, Eigen::Matrix<double, -1, 3, 0, -1, 3> >(std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > const&, Eigen::Matrix<double, -1, 3, 0, -1, 3>&);
-template bool igl::list_to_matrix<double, Eigen::PlainObjectBase<Eigen::Matrix<double, 2, 1, 0, 2, 1> > >(std::vector<double, std::allocator<double> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 2, 1, 0, 2, 1> >&);
-template bool igl::list_to_matrix<double, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> > >(std::vector<double, std::allocator<double> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >&);
-template bool igl::list_to_matrix<double, Eigen::PlainObjectBase<Eigen::Matrix<double, 4, 1, 0, 4, 1> > >(std::vector<double, std::allocator<double> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 4, 1, 0, 4, 1> >&);
-template bool igl::list_to_matrix<double, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > >(std::vector<double, std::allocator<double> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
-template bool igl::list_to_matrix<int, Eigen::Matrix<int, -1, 2, 0, -1, 2> >(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&, Eigen::Matrix<int, -1, 2, 0, -1, 2>&);
-template bool igl::list_to_matrix<unsigned long long int,Eigen::PlainObjectBase<Eigen::Matrix<int,-1,1,0,-1,1> > >(std::vector<unsigned long long int,std::allocator<unsigned long long int> > const &,Eigen::PlainObjectBase<Eigen::Matrix<int,-1,1,0,-1,1> > &);
-template bool igl::list_to_matrix<bool, Eigen::PlainObjectBase<Eigen::Array<bool, -1, 1, 0, -1, 1> > >(std::vector<bool, std::allocator<bool> > const&, Eigen::PlainObjectBase<Eigen::Array<bool, -1, 1, 0, -1, 1> >&);
-template bool igl::list_to_matrix<bool, Eigen::PlainObjectBase<Eigen::Array<bool, -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::Array<bool, -1, -1, 0, -1, -1> >&);
+template bool igl::list_to_matrix<double, Eigen::Matrix<double, -1, 3, 0, -1, 3> >(std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&);
+template bool igl::list_to_matrix<double, Eigen::Matrix<double, -1, 3, 1, -1, 3> >(std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> >&);
+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::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
+template bool igl::list_to_matrix<int, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
+template bool igl::list_to_matrix<int, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
+template bool igl::list_to_matrix<int, Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1> >(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1> >&);
+template bool igl::list_to_matrix<double, Eigen::Matrix<float, -1, 3, 1, -1, 3> >(std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> >&);
+template bool igl::list_to_matrix<float, Eigen::Matrix<float, -1, 3, 1, -1, 3> >(std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> >&);
+template bool igl::list_to_matrix<unsigned int, Eigen::Matrix<unsigned int, -1, 3, 1, -1, 3> >(std::vector<std::vector<unsigned int, std::allocator<unsigned int> >, std::allocator<std::vector<unsigned int, std::allocator<unsigned int> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned int, -1, 3, 1, -1, 3> >&);
+template bool igl::list_to_matrix<int, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(std::vector<int, std::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template bool igl::list_to_matrix<unsigned long, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(std::vector<unsigned long, std::allocator<unsigned long> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template bool igl::list_to_matrix<float, Eigen::Matrix<float, -1, -1, 0, -1, -1> >(std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> >&);
+template bool igl::list_to_matrix<bool, Eigen::Array<bool, -1, 1, 0, -1, 1> >(std::vector<bool, std::allocator<bool> > const&, Eigen::PlainObjectBase<Eigen::Array<bool, -1, 1, 0, -1, 1> >&);
+template bool igl::list_to_matrix<bool, Eigen::Array<bool, -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::Array<bool, -1, -1, 0, -1, -1> >&);
+template bool igl::list_to_matrix<bool, 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::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

+ 13 - 11
include/igl/list_to_matrix.h

@@ -1,18 +1,20 @@
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
+//
 // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // obtain one at http://mozilla.org/MPL/2.0/.
 #ifndef IGL_LIST_TO_MATRIX_H
 #define IGL_LIST_TO_MATRIX_H
 #include "igl_inline.h"
 #include <vector>
+#include <Eigen/Core>
+
 namespace igl
 {
   // Convert a list (std::vector) of row vectors of the same length to a matrix
-  // Template: 
+  // Template:
   //   T  type that can be safely cast to type in Mat via '='
   //   Mat  Matrix type, must implement:
   //     .resize(m,n)
@@ -22,10 +24,10 @@ namespace igl
   // Outputs:
   //   M  an m by n matrix
   // Returns true on success, false on errors
-  template <typename T, class Mat>
+  template <typename T, typename Derived>
   IGL_INLINE bool list_to_matrix(
     const std::vector<std::vector<T > > & V,
-    Mat & M);
+    Eigen::PlainObjectBase<Derived>& M);
   // Convert a list of row vectors of `n` or less to a matrix and pad on
   // the right with `padding`:
   //
@@ -35,15 +37,15 @@ namespace igl
   //   padding  value to fill in from right for short rows
   // Outputs:
   //   M  an m by n matrix
-  template <typename T, class Mat>
+  template <typename T, typename Derived>
   IGL_INLINE bool list_to_matrix(
     const std::vector<std::vector<T > > & V,
     const int n,
     const T & padding,
-    Mat & M);
+    Eigen::PlainObjectBase<Derived>& M);
   // Vector wrapper
-  template <typename T, class Mat>
-  IGL_INLINE bool list_to_matrix(const std::vector<T > & V,Mat & M);
+  template <typename T, typename Derived>
+  IGL_INLINE bool list_to_matrix(const std::vector<T > & V,Eigen::PlainObjectBase<Derived>& M);
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 1 - 0
include/igl/vertex_triangle_adjacency.cpp

@@ -51,4 +51,5 @@ template void igl::vertex_triangle_adjacency<Eigen::Matrix<double, -1, 3, 0, -1,
 template void igl::vertex_triangle_adjacency<Eigen::Matrix<double, -1, -1, 0, -1, -1>, long, long>(Eigen::Matrix<double, -1, -1, 0, -1, -1>::Scalar, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > >&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > >&);
 template void igl::vertex_triangle_adjacency<Eigen::Matrix<int, -1, -1, 0, -1, -1>, long, long>(Eigen::Matrix<int, -1, -1, 0, -1, -1>::Scalar, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > >&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > >&);
 template void igl::vertex_triangle_adjacency<Eigen::Matrix<int, -1, -1, 0, -1, -1>, unsigned long, unsigned long>(Eigen::Matrix<int, -1, -1, 0, -1, -1>::Scalar, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, std::vector<std::vector<unsigned long, std::allocator<unsigned long> >, std::allocator<std::vector<unsigned long, std::allocator<unsigned long> > > >&, std::vector<std::vector<unsigned long, std::allocator<unsigned long> >, std::allocator<std::vector<unsigned long, std::allocator<unsigned long> > > >&);
+template void igl::vertex_triangle_adjacency<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, int>(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&);
 #endif

+ 12 - 8
tutorial/106_ViewerMenu/main.cpp

@@ -3,7 +3,7 @@
 int main()
 {
   std::cerr<<
-    "Error: recompile with IGL_VIEWER_WITH_NANOGUI defined."<<std::endl;
+    "Error: recompile with LIBIGL_VIEWER_WITH_NANOGUI defined."<<std::endl;
   return EXIT_FAILURE;
 }
 #else
@@ -15,14 +15,15 @@ int main()
 #include <iostream>
 #include "tutorial_shared_path.h"
 
-Eigen::MatrixXd V;
-Eigen::MatrixXi F;
-
-bool boolVariable = true;
-float floatVariable = 0.1f;
-
 int main(int argc, char *argv[])
 {
+  Eigen::MatrixXd V;
+  Eigen::MatrixXi F;
+
+  bool boolVariable = true;
+  float floatVariable = 0.1f;
+  enum Orientation { Up=0,Down,Left,Right } dir = Up;
+
   // Load a mesh in OFF format
   igl::readOFF(TUTORIAL_SHARED_PATH "/bunny.off", V, F);
 
@@ -45,10 +46,13 @@ int main(int argc, char *argv[])
       return boolVariable; // get
     });
 
+    // Expose an enumaration type
+    viewer.ngui->addVariable<Orientation>("Direction",dir)->setItems({"Up","Down","Left","Right"});
+
     // Add a button
     viewer.ngui->addButton("Print Hello",[](){ std::cout << "Hello\n"; });
 
-    // Add an additional bar
+    // Add an additional menu window
     viewer.ngui->addWindow(Eigen::Vector2i(220,10),"New Window");
 
     // Expose the same variable directly ...

+ 7 - 7
tutorial/608_LIM/main.cpp

@@ -7,6 +7,8 @@
 
 #include "tutorial_shared_path.h"
 
+using namespace igl::lim;
+
 // Mesh
 Eigen::MatrixX3d V0;
 Eigen::MatrixX3d V1;
@@ -15,7 +17,7 @@ Eigen::MatrixXi F;
 Eigen::SparseMatrix<double> C;
 Eigen::VectorXd b;
 
-int energyType;
+Energy energyType;
 bool barriersEnabled;
 
 // This function is called every time a keyboard button is pressed
@@ -28,7 +30,7 @@ bool key_down(igl::viewer::Viewer& viewer,unsigned char key,int modifier)
   if(key >= '0' && key <= '5' || key == 'B')
   {
     // compute locally injective map
-    int energy = key - '1';
+    Energy energy = Energy(key - '1');
 
     V1 = V0;
 
@@ -44,8 +46,7 @@ bool key_down(igl::viewer::Viewer& viewer,unsigned char key,int modifier)
 
     if(key != '0')
     {
-      igl::lim::lim(
-          V1,V0,F,C,b,energyType,1e-8,100,true,true,barriersEnabled,true,-1,-1);
+      lim(V1,V0,F,C,b,energyType,1e-8,100,true,true,barriersEnabled,true,-1,-1);
     }
 
     // set mesh
@@ -62,7 +63,7 @@ int main(int argc, char *argv[])
   using namespace std;
   using namespace Eigen;
 
-  energyType = 0;
+  energyType = Dirichlet;
   barriersEnabled = true;
 
   // load a mesh in OFF format
@@ -102,8 +103,7 @@ int main(int argc, char *argv[])
   b(2*fixedVertices.size()+1) = 0.2;
 
   // compute locally injective map
-  igl::lim::lim(
-    V1,V0,F,C,b,energyType,1e-8,100,true,true,barriersEnabled,true,-1,-1);
+  lim(V1,V0,F,C,b,energyType,1e-8,100,true,true,barriersEnabled,true,-1,-1);
 
   // Show mesh
   igl::viewer::Viewer viewer;

+ 1 - 0
tutorial/CMakeLists.txt

@@ -34,6 +34,7 @@ find_package(MOSEK QUIET)
 find_package(TETGEN QUIET)
 find_package(TINYXML2 QUIET)
 find_package(TRIANGLE QUIET)
+find_package(LIM QUIET)
 
 message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
 include("CMakeLists.shared")

+ 3 - 0
tutorial/cmake/FindLIM.cmake

@@ -9,6 +9,7 @@ FIND_PATH(LIM_INCLUDE_DIR LIMSolverInterface.h
    /usr/include
    /usr/local/include
    ${PROJECT_SOURCE_DIR}/../libigl/external/lim/
+   ${PROJECT_SOURCE_DIR}/../external/lim/
    ${PROJECT_SOURCE_DIR}/../../external/lim/
    NO_DEFAULT_PATH
 )
@@ -33,6 +34,8 @@ set(
   ${LIM_INCLUDE_DIR}/GreenStrain_LIMSolver3D.cpp
   ${LIM_INCLUDE_DIR}/LSConformal_LIMSolver2D.cpp
   ${LIM_INCLUDE_DIR}/Poisson_LIMSolver2D.cpp
+  ${LIM_INCLUDE_DIR}/Identity_LIMSolver2D.cpp
+  ${LIM_INCLUDE_DIR}/Identity_LIMSolver3D.cpp
   )
 
 SET(LIM_FOUND "NO")

+ 1 - 1
tutorial/tutorial.md.REMOVED.git-id

@@ -1 +1 @@
-e2e0d9675881ddf6a0d438a24c4ef1bb8f4b4791
+c1fd59bc7313c701b8e5c88150b65216c1ea30a5