Browse Source

Merge commit '96d0f0f75c68e5ace90eaa9c3f6f7af63f053578 [formerly 2bae5b6002557235224942acb717a312d5ee1d22]'

Former-commit-id: 4122054c4ecd34033009dd9a603ee029f3b69b0a
Daniele Panozzo 11 years ago
parent
commit
64038eebef
4 changed files with 140 additions and 39 deletions
  1. 3 3
      build/Makefile_viewer
  2. 85 28
      include/igl/lim/compute_lim.cpp
  3. 29 0
      include/igl/lim/compute_lim.h
  4. 23 8
      tutorial/607_LIM/main.cpp

+ 3 - 3
build/Makefile_viewer

@@ -16,7 +16,7 @@ OBJ_FILES=$(addprefix obj/,$(notdir $(CPP_FILES:.cpp=.o)))
 # include igl headers
 INC+=-I../include/
 
-# EXPECTS THAT CFLAGS IS ALREADY SET APPROPRIATELY
+# EXPECTS THAT CFLAGS IS ALREADY SET APPROPRIATELY 
 
 # Eigen dependency
 EIGEN3_INC=-I$(DEFAULT_PREFIX)/include/eigen3 -I$(DEFAULT_PREFIX)/include/eigen3/unsupported
@@ -35,7 +35,7 @@ endif
 ANTTWEAKBAR_INC=-I$(ANTTWEAKBAR)/include -I$(ANTTWEAKBAR)/src
 INC+=$(ANTTWEAKBAR_INC)
 
-obj:
+obj: 
 	mkdir -p obj
 
 ../lib/libiglviewer.a: $(OBJ_FILES)
@@ -43,7 +43,7 @@ obj:
 	ar cqs $@ $(OBJ_FILES)
 
 obj/%.o: $(SRC_DIR)/%.cpp $(SRC_DIR)/%.h
-	$(GG) $(AFLAGS) $(CFLAGS) -c -o $@ $< $(INC)
+	g++ $(AFLAGS) $(CFLAGS) -c -o $@ $< $(INC)
 
 clean:
 	rm -f obj/*.o

+ 85 - 28
include/igl/lim/compute_lim.cpp

@@ -8,6 +8,64 @@
 #include "compute_lim.h"
 #include <LIMSolverInterface.h>
 
+IGL_INLINE int igl::compute_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,
+  double tolerance,
+  int maxIteration,
+  bool findLocalMinima)
+{
+  return ComputeLIM(
+    vertices,
+    initialVertices,
+    elements,
+    constraintMatrix,
+    constraintTargets,
+    energyType,
+    tolerance,
+    maxIteration,
+    findLocalMinima
+    );
+}
+
+IGL_INLINE int igl::compute_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,
+  double tolerance,
+  int maxIteration,
+  bool findLocalMinima,
+  bool enableOuput,
+  bool enableBarriers,
+  bool enableAlphaUpdate,
+  double beta,
+  double eps)
+{
+  return ComputeLIM(
+    vertices,
+    initialVertices,
+    elements,
+    constraintMatrix,
+    constraintTargets,
+    energyType,
+    tolerance,
+    maxIteration,
+    findLocalMinima,
+    enableOuput,
+    enableBarriers,
+    enableAlphaUpdate,
+    beta,
+    eps
+    );
+}
+
 IGL_INLINE int igl::compute_lim(
   Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
   const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
@@ -23,20 +81,17 @@ IGL_INLINE int igl::compute_lim(
 {
   return ComputeLIM(
     vertices,
-  initialVertices,
-  elements,
-  borderVertices,
-  gradients,
-  constraintMatrix,
-  constraintTargets,
-  energyType,
-  tolerance,
-  maxIteration,
-  findLocalMinima,
-  true,
-  true,
-  -1,
-  -1);
+    initialVertices,
+    elements,
+    borderVertices,
+    gradients,
+    constraintMatrix,
+    constraintTargets,
+    energyType,
+    tolerance,
+    maxIteration,
+    findLocalMinima
+    );
 }
 
 IGL_INLINE int igl::compute_lim(
@@ -52,26 +107,28 @@ IGL_INLINE int igl::compute_lim(
   int maxIteration,
   bool findLocalMinima,
   bool enableOuput,
+  bool enableBarriers,
   bool enableAlphaUpdate,
   double beta,
   double eps)
 {
   return ComputeLIM(
     vertices,
-  initialVertices,
-  elements,
-  borderVertices,
-  gradients,
-  constraintMatrix,
-  constraintTargets,
-  energyType,
-  tolerance,
-  maxIteration,
-  findLocalMinima,
-  enableOuput,
-  enableAlphaUpdate,
-  beta,
-  eps);
+    initialVertices,
+    elements,
+    borderVertices,
+    gradients,
+    constraintMatrix,
+    constraintTargets,
+    energyType,
+    tolerance,
+    maxIteration,
+    findLocalMinima,
+    enableOuput,
+    enableBarriers,
+    enableAlphaUpdate,
+    beta,
+    eps);
 }
 
 #ifdef IGL_STATIC_LIBRARY

+ 29 - 0
include/igl/lim/compute_lim.h

@@ -28,6 +28,7 @@ namespace igl
   //   maxIteration      max number of iterations
   //   findLocalMinima   iterating until a local minima is found. If not enabled only tolerance must be fulfilled.
   //   enableOutput      (optional) enables the output (#itaration / hessian correction / step size / positional constraints / barrier constraints / deformation energy) (default : true)
+  //   enableBarriers    (optional) enables the non-flip constraints (default = true)
   //   enableAlphaUpdate (optional) enables dynamic alpha weight adjustment (default = true)
   //   beta              (optional) steepness factor of barrier slopes (default: ARAP/LSCM = 0.01, Green = 1)
   //   eps               (optional) smallest valid triangle area (default: 1e-5 * smallest triangle)
@@ -46,6 +47,33 @@ namespace igl
   // -1 : Max iteration reached before tolerance was fulfilled
   // -2 : not feasible -> has inverted elements (may want to decrease eps?)
 
+  int compute_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,
+    double tolerance,
+    int maxIteration,
+    bool findLocalMinima);
+
+  int compute_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,
+    double tolerance,
+    int maxIteration,
+    bool findLocalMinima,
+    bool enableOuput,
+    bool enableBarriers,
+    bool enableAlphaUpdate,
+    double beta,
+    double eps);
+
   int compute_lim(
     Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
     const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
@@ -72,6 +100,7 @@ namespace igl
     int maxIteration,
     bool findLocalMinima,
     bool enableOuput,
+    bool enableBarriers,
     bool enableAlphaUpdate,
     double beta,
     double eps);

+ 23 - 8
tutorial/607_LIM/main.cpp

@@ -16,8 +16,9 @@ Eigen::MatrixXi F;
 
 SparseMatrix<double> C;
 Eigen::VectorXd b;
-vector<int> bv; // border vertices (don't need to be defined exept for LSCM)
-Eigen::VectorXd g; // gradients (don't need to be defined execpt for Poisson)
+
+int energyType;
+bool barriersEnabled;
 
 // This function is called every time a keyboard button is pressed
 // keys: 0:Original Mesh / 1:Harmonic / 2:Biharmonic / 3:Green / 4:ARAP
@@ -26,19 +27,30 @@ bool key_down(igl::Viewer& viewer,unsigned char key,int modifier)
   using namespace std;
   using namespace Eigen;
 
-  if(key >= '0' && key <= '4')
+  if(key >= '1' && key <= '5' || key == 'B')
   {
     // compute locally injective map
-    int energy = key - 49;
+    int energy = key - '1';
 
     V1 = V0;
-    if(energy >= 0)
-      igl::compute_lim(V1,V0,F,bv,g,C,b,energy,1e-8,100,true);
+
+    if(key == 'B')
+    {
+      barriersEnabled = !barriersEnabled;
+    }
+    else
+    {
+      if(energy >= 0)
+        energyType = energy;
+    }
+
+    igl::compute_lim(V1,V0,F,C,b,energyType,1e-8,100,true,true,barriersEnabled,true,-1,-1);
 
     // set mesh
     viewer.set_vertices(V1);
-  }
 
+    return true;
+  }
 
   return false;
 }
@@ -48,6 +60,9 @@ int main(int argc, char *argv[])
   using namespace std;
   using namespace Eigen;
 
+  energyType = 0;
+  barriersEnabled = true;
+
   // load a mesh in OFF format
   igl::readOFF("../shared/grid.off",V0,F);
   V1 = V0;
@@ -85,7 +100,7 @@ int main(int argc, char *argv[])
   b(2*fixedVertices.size()+1) = 0.2;
 
   // compute locally injective map
-  igl::compute_lim(V1,V0,F,bv,g,C,b,0,1e-8,100,true);
+  igl::compute_lim(V1,V0,F,C,b,energyType,1e-8,100,true,true,barriersEnabled,true,-1,-1);
 
   // Show mesh
   igl::Viewer viewer;