浏览代码

updated bbw demo (need to test again

Former-commit-id: bfe40e3f28e7d7a81685bb910010aeddd677d7d0
Alec Jacobson (jalec 13 年之前
父节点
当前提交
0232b4419d

+ 0 - 2
examples/bbw/main.cpp

@@ -16,8 +16,6 @@
 
 #include <Eigen/Dense>
 
-#include <Eigen/Dense>
-
 #include <iostream>
 #include <string>
 

+ 0 - 1
include/igl/edges.cpp

@@ -1,6 +1,5 @@
 #include "edges.h"
 
-#include <map>
 #include "adjacency_matrix.h"
 
 IGL_INLINE void igl::edges( const Eigen::MatrixXi& F, Eigen::MatrixXi& E)

+ 2 - 0
include/igl/material_colors.h

@@ -23,5 +23,7 @@ namespace igl
   const float WHITE_AMBIENT[4] =   { 255.0/255.0,255.0/255.0,255.0/255.0,1.0f };
   const float WHITE_DIFFUSE[4] =   { 255.0/255.0,255.0/255.0,255.0/255.0,1.0f };
   const float WHITE_SPECULAR[4] =  { 255.0/255.0,255.0/255.0,255.0/255.0,1.0f };
+  const float BBW_POINT_COLOR[4] = {239./255.,213./255.,46./255.,255.0/255.0};
+  const float BBW_LINE_COLOR[4] = {106./255.,106./255.,255./255.,255./255.};
 }
 #endif

+ 50 - 51
include/igl/mosek/mosek_quadprog.cpp

@@ -15,6 +15,41 @@ static void MSKAPI printstr(void *handle, char str[])
   printf("%s",str);
 }
 
+igl::MosekData::MosekData()
+{
+  // These are the default settings that worked well for BBW. Your miles may
+  // very well be kilometers.
+
+  // >1e0 NONSOLUTION
+  // 1e-1 artifacts in deformation
+  // 1e-3 artifacts in isolines
+  // 1e-4 seems safe
+  // 1e-8 MOSEK DEFAULT SOLUTION
+  douparam[MSK_DPAR_INTPNT_TOL_REL_GAP]=1e-8;
+  // Force using multiple threads, not sure if MOSEK is properly destorying
+  //extra threads...
+  intparam[MSK_IPAR_INTPNT_NUM_THREADS] = 6;
+  // Turn off presolving
+  // intparam[MSK_IPAR_PRESOLVE_USE] = MSK_PRESOLVE_MODE_OFF;
+  // Force particular matrix reordering method
+  // MSK_ORDER_METHOD_NONE cuts time in half roughly, since half the time is
+  //   usually spent reordering the matrix
+  // !! WARNING Setting this parameter to anything but MSK_ORDER_METHOD_FREE
+  //   seems to have the effect of setting it to MSK_ORDER_METHOD_NONE
+  //   *Or maybe Mosek is spending a bunch of time analyzing the matrix to
+  //   choose the right ordering method when really any of them are
+  //   instantaneous
+  intparam[MSK_IPAR_INTPNT_ORDER_METHOD] = MSK_ORDER_METHOD_NONE;
+  // 1.0 means optimizer is very leniant about declaring model infeasible
+  douparam[MSK_DPAR_INTPNT_TOL_INFEAS] = 1e-8;
+  // Hard to say if this is doing anything, probably nothing dramatic
+  douparam[MSK_DPAR_INTPNT_TOL_PSAFE]= 1e2;
+  // Turn off convexity check
+  intparam[MSK_IPAR_CHECK_CONVEXITY] = MSK_CHECK_CONVEXITY_NONE;
+  // Force turn off data check
+  intparam[MSK_IPAR_DATA_CHECK]=MSK_OFF;
+}
+
 template <typename Index, typename Scalar>
 IGL_INLINE bool igl::mosek_quadprog(
   const Index n,
@@ -130,57 +165,21 @@ IGL_INLINE bool igl::mosek_quadprog(
   // Input Q for the objective (REMEMBER Q SHOULD ONLY BE LOWER TRIANGLE)
   mosek_guarded(MSK_putqobj(task,Qv.size(),&Qi[0],&Qj[0],&Qv[0]));
 
-  //// Set up task parameters
-
-  // set tolerance
-  //mosek_guarded(
-  //  MSK_putdouparam(task,MSK_DPAR_INTPNT_TOL_DFEAS,1e-8));
-  //mosek_guarded(
-  //  MSK_putdouparam(task,MSK_DPAR_INTPNT_TOL_DSAFE,1.0));
-  // 1.0 means optimizer is very leniant about declaring model infeasible
-  //mosek_guarded(
-  //  MSK_putdouparam(task,MSK_DPAR_INTPNT_TOL_INFEAS,1e-8));
-  //mosek_guarded(
-  //  MSK_putdouparam(task,MSK_DPAR_INTPNT_TOL_PATH,1e-8));
-  //mosek_guarded(
-  //  MSK_putdouparam(task,MSK_DPAR_INTPNT_TOL_PFEAS,1e-8));
-
-  // Hard to say if this is doing anything, probably nothing dramatic
-  mosek_guarded(MSK_putdouparam(task,MSK_DPAR_INTPNT_TOL_PSAFE,1e2));
-
-  // >1e0 NONSOLUTION
-  // 1e-1 artifacts in deformation
-  // 1e-3 artifacts in isolines
-  // 1e-4 seems safe
-  // 1e-8 MOSEK DEFAULT SOLUTION
-  mosek_guarded(MSK_putdouparam(task,MSK_DPAR_INTPNT_TOL_REL_GAP,1e-8));
-  //mosek_guarded(MSK_putdouparam(task,MSK_DPAR_INTPNT_TOL_REL_STEP,0.9999));
-
-  // Turn off presolving
-  //mosek_guarded(
-  //  MSK_putintparam(task,MSK_IPAR_PRESOLVE_USE,MSK_PRESOLVE_MODE_OFF));
-
-  // Force particular matrix reordering method
-  // MSK_ORDER_METHOD_NONE cuts time in half roughly, since half the time is
-  //   usually spent reordering the matrix
-  // !! WARNING Setting this parameter to anything but MSK_ORDER_METHOD_FREE
-  //   seems to have the effect of setting it to MSK_ORDER_METHOD_NONE
-  //   *Or maybe Mosek is spending a bunch of time analyzing the matrix to
-  //   choose the right ordering method when really any of them are
-  //   instantaneous
-  mosek_guarded(
-    MSK_putintparam(task,MSK_IPAR_INTPNT_ORDER_METHOD,MSK_ORDER_METHOD_NONE));
-
-  // Turn off convexity check
-  mosek_guarded(
-    MSK_putintparam(task,MSK_IPAR_CHECK_CONVEXITY,MSK_CHECK_CONVEXITY_NONE));
-
-  // Force using multiple threads, not sure if MOSEK is properly destorying
-  //extra threads...
-  mosek_guarded(MSK_putintparam(task,MSK_IPAR_INTPNT_NUM_THREADS,6));
-  
-  // Force turn off data check
-  mosek_guarded(MSK_putintparam(task,MSK_IPAR_DATA_CHECK,MSK_OFF));
+  // Set up task parameters
+  for(
+    std::map<MSKiparame,int>::iterator pit = mosek_data.intparam.begin();
+    pit != mosek_data.intparam.end(); 
+    pit++)
+  {
+    mosek_guarded(MSK_putintparam(task,pit->first,pit->second));
+  }
+  for(
+    std::map<MSKdparame,double>::iterator pit = mosek_data.douparam.begin();
+    pit != mosek_data.douparam.end(); 
+    pit++)
+  {
+    mosek_guarded(MSK_putdouparam(task,pit->first,pit->second));
+  }
 
   // Now the optimizer has been prepared
   MSKrescodee trmcode;

+ 8 - 0
include/igl/mosek/mosek_quadprog.h

@@ -2,6 +2,8 @@
 #define IGL_MOSEK_QUADPROG_H
 #include "../igl_inline.h"
 #include <vector>
+#include <map>
+#include "mosek.h"
 
 
 #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
@@ -12,6 +14,12 @@ namespace igl
 {
   struct MosekData
   {
+    // Integer parameters
+    std::map<MSKiparame,int> intparam;
+    // Double parameters
+    std::map<MSKdparame,double> douparam;
+    // Default values
+    MosekData();
   };
   // Solve a convex quadratic optimization problem with linear and constant
   // bounds, that is:

+ 0 - 1
include/igl/on_boundary.cpp

@@ -5,7 +5,6 @@
 #include "face_occurences.h"
 
 // STL includes
-#include <map>
 
 template <typename IntegerT>
 IGL_INLINE void igl::on_boundary(