瀏覽代碼

Documentation and code clean ups (MIQ related) (#971)

* remove commented code

* typo

* clean up list of the arguments

* typo

* typos and different names

* rename files due to a typo and remove double include

* remove comments that do not document the code but are used to comment out code or to store TODOs that should not be placed in the code, anyway.

* clean up the documentation

* remove commented code

* add information to the doc

* improve readability of the code

* typo and a missing space

* fix a typo: missmatch -> mismatch

* remove unnecessary header files

* typos

* changed to camel notation

* clean up

* typo

* add limitations into the documentation

* camelCase

* lost refactor

* unify the variable's names

* clean up

* clean up

* missed refactor

* clean up

* name in the doc

* name in the doc

* further nameing convention changes

* refactored names missed by clion.

* unify names

* align the constructor's args
Kacper Pluta 6 年之前
父節點
當前提交
75d60e40a8

+ 0 - 4
include/igl/comb_frame_field.cpp

@@ -69,10 +69,6 @@ IGL_INLINE void igl::comb_frame_field(const Eigen::PlainObjectBase<DerivedV> &V,
     PD2_combed.row(i) = DIRs.row(M);
 
   }
-
-
-  //    PD1_combed = BIS1_combed;
-  //    PD2_combed = BIS2_combed;
 }
 
 #ifdef IGL_STATIC_LIBRARY

+ 192 - 191
include/igl/copyleft/comiso/miq.cpp

@@ -28,7 +28,7 @@
 #include <CoMISo/Solver/GMM_Tools.hh>
 
 //
-#include "../../cross_field_missmatch.h"
+#include "igl/cross_field_mismatch.h"
 #include "../../comb_frame_field.h"
 #include "../../comb_cross_field.h"
 #include "../../cut_mesh_from_singularities.h"
@@ -69,7 +69,7 @@ namespace comiso {
     ///num of integer for cuts
     int num_integer_cuts;
     ///this are used for drawing purposes
-    std::vector<SeamInfo> EdgeSeamInfo;
+    std::vector<SeamInfo> edgeSeamInfo;
   };
 
 
@@ -85,13 +85,13 @@ namespace comiso {
     const Eigen::PlainObjectBase<DerivedF> &TT;
     const Eigen::PlainObjectBase<DerivedF> &TTi;
 
-    const Eigen::Matrix<int, Eigen::Dynamic, 3> &Handle_MMatch;
-    const Eigen::Matrix<int, Eigen::Dynamic, 1> &Handle_Singular; // bool
-    const Eigen::Matrix<int, Eigen::Dynamic, 3> &Handle_Seams; // 3 bool
+    const Eigen::Matrix<int, Eigen::Dynamic, 3> &mismatch;
+    const Eigen::Matrix<int, Eigen::Dynamic, 1> &singular; // bool
+    const Eigen::Matrix<int, Eigen::Dynamic, 3> &seams; // 3 bool
 
 
     ///this handle for mesh TODO: move with the other global variables
-    MeshSystemInfo Handle_SystemInfo;
+    MeshSystemInfo systemInfo;
 
     IGL_INLINE VertexIndexing(const Eigen::PlainObjectBase<DerivedV> &_V,
                               const Eigen::PlainObjectBase<DerivedF> &_F,
@@ -99,13 +99,13 @@ namespace comiso {
                               const Eigen::PlainObjectBase<DerivedF> &_Fcut,
                               const Eigen::PlainObjectBase<DerivedF> &_TT,
                               const Eigen::PlainObjectBase<DerivedF> &_TTi,
-                              const Eigen::Matrix<int, Eigen::Dynamic, 3> &_Handle_MMatch,
-                              const Eigen::Matrix<int, Eigen::Dynamic, 1> &_Handle_Singular,
-                              const Eigen::Matrix<int, Eigen::Dynamic, 3> &_Handle_Seams
+                              const Eigen::Matrix<int, Eigen::Dynamic, 3> &_mismatch,
+                              const Eigen::Matrix<int, Eigen::Dynamic, 1> &_singular,
+                              const Eigen::Matrix<int, Eigen::Dynamic, 3> &_seams
                               );
 
     // provide information about every vertex per seam
-    IGL_INLINE void InitSeamInfo();
+    IGL_INLINE void initSeamInfo();
 
 
   private:
@@ -120,14 +120,14 @@ namespace comiso {
       }
     };
 
-    IGL_INLINE void GetSeamInfo(const int f0,
+    IGL_INLINE void getSeamInfo(const int f0,
                                 const int f1,
                                 const int indexE,
-                                int &v0,int &v1,
-                                int &v0p,int &v1p,
-                                unsigned char &_MMatch);
+                                int &v0, int &v1,
+                                int &v0p, int &v1p,
+                                unsigned char &_mismatch);
 
-    IGL_INLINE std::vector<std::vector<VertexInfo> > GetVerticesPerSeam();
+    IGL_INLINE std::vector<std::vector<VertexInfo> > getVerticesPerSeam();
   };
 
 
@@ -136,13 +136,13 @@ namespace comiso {
   {
 
   public:
-    IGL_INLINE void SolvePoisson(Eigen::VectorXd Stiffness,
-                                 double vector_field_scale=0.1f,
-                                 double grid_res=1.f,
-                                 bool direct_round=true,
-                                 int localIter=0,
-                                 bool _integer_rounding=true,
-                                 bool _singularity_rounding=true,
+    IGL_INLINE void solvePoisson(Eigen::VectorXd Stiffness,
+                                 double gredientSize = 0.1,
+                                 double grid_res = 1.,
+                                 bool direct_round = true,
+                                 int localIter = 0,
+                                 bool _doRound = true,
+                                 bool _singularity_rounding = true,
                                  std::vector<int> roundVertices = std::vector<int>(),
                                  std::vector<std::vector<int> > hardFeatures = std::vector<std::vector<int> >());
 
@@ -166,9 +166,9 @@ namespace comiso {
     const Eigen::PlainObjectBase<DerivedF> &TTi;
     const Eigen::PlainObjectBase<DerivedV> &PD1;
     const Eigen::PlainObjectBase<DerivedV> &PD2;
-    const Eigen::Matrix<int, Eigen::Dynamic, 1> &Handle_Singular; // bool
+    const Eigen::Matrix<int, Eigen::Dynamic, 1> &singular; // bool
 
-    const MeshSystemInfo &Handle_SystemInfo;
+    const MeshSystemInfo &systemInfo;
 
     // Internal:
     Eigen::VectorXd Handle_Stiffness;
@@ -229,62 +229,62 @@ namespace comiso {
 
     ///START COMMON MATH FUNCTIONS
     ///return the complex encoding the rotation
-    ///for a given missmatch interval
-    IGL_INLINE std::complex<double> GetRotationComplex(int interval);
+    ///for a given mismatch interval
+    IGL_INLINE std::complex<double> getRotationComplex(int interval);
     ///END COMMON MATH FUNCTIONS
 
     ///START FIXING VERTICES
     ///set a given vertex as fixed
-    IGL_INLINE void AddFixedVertex(int v);
+    IGL_INLINE void addFixedVertex(int v);
 
     ///find vertex to fix in case we're using
     ///a vector field NB: multiple components not handled
-    IGL_INLINE void FindFixedVertField();
+    IGL_INLINE void findFixedVertField();
 
     ///find hard constraint depending if using or not
     ///a vector field
-    IGL_INLINE void FindFixedVert();
+    IGL_INLINE void findFixedVert();
 
-    IGL_INLINE int GetFirstVertexIndex(int v);
+    IGL_INLINE int getFirstVertexIndex(int v);
 
     ///fix the vertices which are flagged as fixed
-    IGL_INLINE void FixBlockedVertex();
+    IGL_INLINE void fixBlockedVertex();
     ///END FIXING VERTICES
 
     ///HANDLING SINGULARITY
     //set the singularity round to integer location
-    IGL_INLINE void AddSingularityRound();
+    IGL_INLINE void addSingularityRound();
 
-    IGL_INLINE void AddToRoundVertices(std::vector<int> ids);
+    IGL_INLINE void addToRoundVertices(std::vector<int> ids);
 
     ///START GENERIC SYSTEM FUNCTIONS
-    //build the laplacian matrix cyclyng over all rangemaps
+    //build the Laplacian matrix cycling over all range maps
     //and over all faces
-    IGL_INLINE void BuildLaplacianMatrix(double vfscale=1);
+    IGL_INLINE void buildLaplacianMatrix(double vfscale = 1);
 
     ///find different sized of the system
-    IGL_INLINE void FindSizes();
+    IGL_INLINE void findSizes();
 
-    IGL_INLINE void AllocateSystem();
+    IGL_INLINE void allocateSystem();
 
     ///intitialize the whole matrix
-    IGL_INLINE void InitMatrix();
+    IGL_INLINE void initMatrix();
 
     ///map back coordinates after that
     ///the system has been solved
-    IGL_INLINE void MapCoords();
+    IGL_INLINE void mapCoords();
     ///END GENERIC SYSTEM FUNCTIONS
 
     ///set the constraints for the inter-range cuts
-    IGL_INLINE void BuildSeamConstraintsExplicitTranslation();
+    IGL_INLINE void buildSeamConstraintsExplicitTranslation();
 
     ///set the constraints for the inter-range cuts
-    IGL_INLINE void BuildUserDefinedConstraints();
+    IGL_INLINE void buildUserDefinedConstraints();
 
     ///call of the mixed integer solver
-    IGL_INLINE void MixedIntegerSolve(double cone_grid_res=1,
-                                      bool direct_round=true,
-                                      int localIter=0);
+    IGL_INLINE void mixedIntegerSolve(double cone_grid_res = 1,
+                                      bool direct_round = true,
+                                      int localIter = 0);
 
     IGL_INLINE void clearUserConstraint();
 
@@ -327,7 +327,7 @@ namespace comiso {
                          int iter = 5,
                          int localIter = 5,
                          bool DoRound = true,
-                         bool SingularityRound=true,
+                         bool SingularityRound = true,
                          std::vector<int> roundVertices = std::vector<int>(),
                          std::vector<std::vector<int> > hardFeatures = std::vector<std::vector<int> >());
 
@@ -392,25 +392,25 @@ Vcut(_Vcut),
 Fcut(_Fcut),
 TT(_TT),
 TTi(_TTi),
-Handle_MMatch(_Handle_MMatch),
-Handle_Singular(_Handle_Singular),
-Handle_Seams(_Handle_Seams)
+mismatch(_Handle_MMatch),
+singular(_Handle_Singular),
+seams(_Handle_Seams)
 {
   #ifdef DEBUG_PRINT
   cerr<<igl::matlab_format(Handle_Seams,"Handle_Seams");
 #endif
 
-  Handle_SystemInfo.num_vert_variables=Vcut.rows();
-  Handle_SystemInfo.num_integer_cuts=0;
+  systemInfo.num_vert_variables=Vcut.rows();
+  systemInfo.num_integer_cuts=0;
 }
 
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::copyleft::comiso::VertexIndexing<DerivedV, DerivedF>::GetSeamInfo(const int f0,
-                                                                     const int f1,
-                                                                     const int indexE,
-                                                                     int &v0,int &v1,
-                                                                     int &v0p,int &v1p,
-                                                                     unsigned char &_MMatch)
+IGL_INLINE void igl::copyleft::comiso::VertexIndexing<DerivedV, DerivedF>::getSeamInfo(const int f0,
+                                                                                       const int f1,
+                                                                                       const int indexE,
+                                                                                       int &v0, int &v1,
+                                                                                       int &v0p, int &v1p,
+                                                                                       unsigned char &_mismatch)
 {
   int edgef0 = indexE;
   v0 = Fcut(f0,edgef0);
@@ -421,13 +421,13 @@ IGL_INLINE void igl::copyleft::comiso::VertexIndexing<DerivedV, DerivedF>::GetSe
   v1p = Fcut(f1,edgef1);
   v0p = Fcut(f1,(edgef1+1)%3);
 
-  _MMatch = Handle_MMatch(f0,edgef0);
+  _mismatch = mismatch(f0,edgef0);
   assert(F(f0,edgef0)         == F(f1,((edgef1+1)%3)));
   assert(F(f0,((edgef0+1)%3)) == F(f1,edgef1));
 }
 
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE std::vector<std::vector<typename igl::copyleft::comiso::VertexIndexing<DerivedV, DerivedF>::VertexInfo> > igl::copyleft::comiso::VertexIndexing<DerivedV, DerivedF>::GetVerticesPerSeam()
+IGL_INLINE std::vector<std::vector<typename igl::copyleft::comiso::VertexIndexing<DerivedV, DerivedF>::VertexInfo> > igl::copyleft::comiso::VertexIndexing<DerivedV, DerivedF>::getVerticesPerSeam()
 {
   // Return value
   std::vector<std::vector<VertexInfo> >verticesPerSeam;
@@ -444,7 +444,7 @@ IGL_INLINE std::vector<std::vector<typename igl::copyleft::comiso::VertexIndexin
       if(f1 == -1)
         continue;
 
-      bool seam = Handle_Seams(f0,k0);
+      bool seam = seams(f0,k0);
       if (seam && F_hit(f0,k0) == 0)
       {
         int v0 = F(f0, k0);
@@ -465,7 +465,7 @@ IGL_INLINE std::vector<std::vector<typename igl::copyleft::comiso::VertexIndexin
   {
     isStartVertex[i] = false;
     // vertices with two neighbors are regular vertices, unless the vertex is a singularity, in which case it qualifies as a start vertex
-    if (VVSeam[i].size() > 0 && VVSeam[i].size() != 2 || Handle_Singular(i) == true)
+    if (VVSeam[i].size() > 0 && VVSeam[i].size() != 2 || singular(i) == true)
     {
       startVertexIndices.push_back(i);
       isStartVertex[i] = true;
@@ -527,10 +527,10 @@ IGL_INLINE std::vector<std::vector<typename igl::copyleft::comiso::VertexIndexin
 }
 
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::copyleft::comiso::VertexIndexing<DerivedV, DerivedF>::InitSeamInfo()
+IGL_INLINE void igl::copyleft::comiso::VertexIndexing<DerivedV, DerivedF>::initSeamInfo()
 {
-  auto verticesPerSeam = GetVerticesPerSeam();
-  Handle_SystemInfo.EdgeSeamInfo.clear();
+  auto verticesPerSeam = getVerticesPerSeam();
+  systemInfo.edgeSeamInfo.clear();
   int integerVar = 0;
   // Loop over each seam
   for(auto seam : verticesPerSeam){
@@ -569,44 +569,44 @@ IGL_INLINE void igl::copyleft::comiso::VertexIndexing<DerivedV, DerivedF>::InitS
 
       int vtx0,vtx0p,vtx1,vtx1p;
       unsigned char MM;
-      GetSeamInfo(f,ff,k,vtx0,vtx1,vtx0p,vtx1p,MM);
-      Handle_SystemInfo.EdgeSeamInfo.push_back(SeamInfo(vtx0,vtx0p,MM,integerVar));
+      getSeamInfo(f, ff, k, vtx0, vtx1, vtx0p, vtx1p, MM);
+      systemInfo.edgeSeamInfo.push_back(SeamInfo(vtx0,vtx0p,MM,integerVar));
       if(it == seam.end() -1){
-        Handle_SystemInfo.EdgeSeamInfo.push_back(SeamInfo(vtx1,vtx1p,MM,integerVar));
+        systemInfo.edgeSeamInfo.push_back(SeamInfo(vtx1,vtx1p,MM,integerVar));
       }
       priorVertexIdx = vtx1;
     }
     // use the same integer for each seam
     integerVar++;
   }
-  Handle_SystemInfo.num_integer_cuts = integerVar;
+  systemInfo.num_integer_cuts = integerVar;
 
 #ifndef NDEBUG
   int totalNVerticesOnSeams = 0;
   for(auto seam : verticesPerSeam){
     totalNVerticesOnSeams += seam.size();
   }
-  assert(Handle_SystemInfo.EdgeSeamInfo.size() == totalNVerticesOnSeams);
+  assert(systemInfo.edgeSeamInfo.size() == totalNVerticesOnSeams);
 #endif
 }
 
 
 
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::SolvePoisson(Eigen::VectorXd Stiffness,
-                                                                     double vector_field_scale,
-                                                                     double grid_res,
-                                                                     bool direct_round,
+IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::solvePoisson(Eigen::VectorXd Stiffness,
+                                                                     double gradientSize,
+                                                                     double gridResolution,
+                                                                     bool directRound,
                                                                      int localIter,
-                                                                     bool _integer_rounding,
-                                                                     bool _singularity_rounding,
+                                                                     bool doRound,
+                                                                     bool singularityRound,
                                                                      std::vector<int> roundVertices,
                                                                      std::vector<std::vector<int> > hardFeatures)
 {
   Handle_Stiffness = Stiffness;
 
   //initialization of flags and data structures
-  integer_rounding=_integer_rounding;
+  integer_rounding=doRound;
 
   ids_to_round.clear();
 
@@ -618,46 +618,45 @@ IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::SolveP
   }
 
   ///Initializing Matrix
-
   int t0=clock();
 
   ///initialize the matrix ALLOCATING SPACE
-  InitMatrix();
+  initMatrix();
   if (DEBUGPRINT)
     printf("\n ALLOCATED THE MATRIX \n");
 
-  ///build the laplacian system
-  BuildLaplacianMatrix(vector_field_scale);
+  ///build the Laplacian system
+  buildLaplacianMatrix(gradientSize);
 
   // add seam constraints
-  BuildSeamConstraintsExplicitTranslation();
+  buildSeamConstraintsExplicitTranslation();
 
   // add user defined constraints
-  BuildUserDefinedConstraints();
+  buildUserDefinedConstraints();
 
-  ////add the lagrange multiplier
-  FixBlockedVertex();
+  ////add the Lagrange multiplier
+  fixBlockedVertex();
 
   if (DEBUGPRINT)
     printf("\n BUILT THE MATRIX \n");
 
   if (integer_rounding)
-    AddToRoundVertices(roundVertices);
+    addToRoundVertices(roundVertices);
 
-  if (_singularity_rounding)
-    AddSingularityRound();
+  if (singularityRound)
+    addSingularityRound();
 
   int t1=clock();
   if (DEBUGPRINT) printf("\n time:%d \n",t1-t0);
   if (DEBUGPRINT) printf("\n SOLVING \n");
 
-  MixedIntegerSolve(grid_res,direct_round,localIter);
+  mixedIntegerSolve(gridResolution, directRound, localIter);
 
   int t2=clock();
   if (DEBUGPRINT) printf("\n time:%d \n",t2-t1);
   if (DEBUGPRINT) printf("\n ASSIGNING COORDS \n");
 
-  MapCoords();
+  mapCoords();
 
   int t3=clock();
   if (DEBUGPRINT) printf("\n time:%d \n",t3-t2);
@@ -674,8 +673,8 @@ IGL_INLINE igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>
                 const Eigen::PlainObjectBase<DerivedF> &_TTi,
                 const Eigen::PlainObjectBase<DerivedV> &_PD1,
                 const Eigen::PlainObjectBase<DerivedV> &_PD2,
-                const Eigen::Matrix<int, Eigen::Dynamic, 1>&_Handle_Singular,
-                const MeshSystemInfo &_Handle_SystemInfo
+                const Eigen::Matrix<int, Eigen::Dynamic, 1>&_singular,
+                const MeshSystemInfo &_systemInfo
 ):
 V(_V),
 F(_F),
@@ -685,8 +684,8 @@ TT(_TT),
 TTi(_TTi),
 PD1(_PD1),
 PD2(_PD2),
-Handle_Singular(_Handle_Singular),
-Handle_SystemInfo(_Handle_SystemInfo)
+singular(_singular),
+systemInfo(_systemInfo)
 {
   UV        = Eigen::MatrixXd(V.rows(),2);
   WUV       = Eigen::MatrixXd(F.rows(),6);
@@ -696,9 +695,10 @@ Handle_SystemInfo(_Handle_SystemInfo)
 
 ///START COMMON MATH FUNCTIONS
 ///return the complex encoding the rotation
-///for a given missmatch interval
+///for a given mismatch interval
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE std::complex<double> igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::GetRotationComplex(int interval)
+IGL_INLINE std::complex<double> igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::getRotationComplex(
+        int interval)
 {
   assert((interval>=0)&&(interval<4));
 
@@ -716,7 +716,7 @@ IGL_INLINE std::complex<double> igl::copyleft::comiso::PoissonSolver<DerivedV, D
 ///START FIXING VERTICES
 ///set a given vertex as fixed
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::AddFixedVertex(int v)
+IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::addFixedVertex(int v)
 {
   n_fixed_vars++;
   Hard_constraints.push_back(v);
@@ -725,7 +725,7 @@ IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::AddFix
 ///find vertex to fix in case we're using
 ///a vector field NB: multiple components not handled
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::FindFixedVertField()
+IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::findFixedVertField()
 {
   Hard_constraints.clear();
 
@@ -733,16 +733,16 @@ IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::FindFi
   //fix the first singularity
   for (unsigned int v=0;v<V.rows();v++)
   {
-    if (Handle_Singular(v))
+    if (singular(v))
     {
-      AddFixedVertex(v);
+      addFixedVertex(v);
       UV.row(v) << 0,0;
       return;
     }
   }
 
   ///if anything fixed fix the first
-  AddFixedVertex(0);
+  addFixedVertex(0);
   UV.row(0) << 0,0;
   std::cerr << "No vertices to fix, I am fixing the first vertex to the origin!" << std::endl;
 }
@@ -750,21 +750,21 @@ IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::FindFi
 ///find hard constraint depending if using or not
 ///a vector field
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::FindFixedVert()
+IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::findFixedVert()
 {
   Hard_constraints.clear();
-  FindFixedVertField();
+  findFixedVertField();
 }
 
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE int igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::GetFirstVertexIndex(int v)
+IGL_INLINE int igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::getFirstVertexIndex(int v)
 {
   return Fcut(VF[v][0],VFi[v][0]);
 }
 
 ///fix the vertices which are flagged as fixed
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::FixBlockedVertex()
+IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::fixBlockedVertex()
 {
   int offset_row = num_cut_constraint*2;
 
@@ -775,7 +775,7 @@ IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::FixBlo
 
     ///get first index of the vertex that must blocked
     //int index=v->vertex_index[0];
-    int index = GetFirstVertexIndex(v);
+    int index = getFirstVertexIndex(v);
 
     ///multiply times 2 because of uv
     int indexvert = index*2;
@@ -801,13 +801,13 @@ IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::FixBlo
 ///HANDLING SINGULARITY
 //set the singularity round to integer location
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::AddSingularityRound()
+IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::addSingularityRound()
 {
   for (unsigned int v=0;v<V.rows();v++)
   {
-    if (Handle_Singular(v))
+    if (singular(v))
     {
-      int index0=GetFirstVertexIndex(v);
+      int index0= getFirstVertexIndex(v);
       ids_to_round.push_back( index0*2   );
       ids_to_round.push_back((index0*2)+1);
     }
@@ -815,13 +815,13 @@ IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::AddSin
 }
 
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::AddToRoundVertices(std::vector<int> ids)
+IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::addToRoundVertices(std::vector<int> ids)
 {
   for (size_t i = 0; i < ids.size(); ++i)
   {
     if (ids[i] < 0 || ids[i] >= V.rows())
       std::cerr << "WARNING: Ignored round vertex constraint, vertex " << ids[i] << " does not exist in the mesh." << std::endl;
-    int index0 = GetFirstVertexIndex(ids[i]);
+    int index0 = getFirstVertexIndex(ids[i]);
     ids_to_round.push_back( index0*2   );
     ids_to_round.push_back((index0*2)+1);
   }
@@ -829,7 +829,7 @@ IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::AddToR
 
 ///START GENERIC SYSTEM FUNCTIONS
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::BuildLaplacianMatrix(double vfscale)
+IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::buildLaplacianMatrix(double vfscale)
 {
   Eigen::VectorXi idx  = igl::LinSpaced<Eigen::VectorXi >(Vcut.rows(), 0, 2*Vcut.rows()-2);
   Eigen::VectorXi idx2 = igl::LinSpaced<Eigen::VectorXi >(Vcut.rows(), 1, 2*Vcut.rows()-1);
@@ -866,20 +866,20 @@ IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::BuildL
 
 ///find different sized of the system
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::FindSizes()
+IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::findSizes()
 {
   ///find the vertex that need to be fixed
-  FindFixedVert();
+  findFixedVert();
 
   ///REAL PART
-  n_vert_vars = Handle_SystemInfo.num_vert_variables;
+  n_vert_vars = systemInfo.num_vert_variables;
 
   ///INTEGER PART
   ///the total number of integer variables
-  n_integer_vars = Handle_SystemInfo.num_integer_cuts;
+  n_integer_vars = systemInfo.num_integer_cuts;
 
   ///CONSTRAINT PART
-  num_cut_constraint = Handle_SystemInfo.EdgeSeamInfo.size();
+  num_cut_constraint = systemInfo.edgeSeamInfo.size();
 
   num_constraint_equations = num_cut_constraint * 2 + n_fixed_vars * 2 + num_userdefined_constraint;
 
@@ -905,7 +905,7 @@ IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::FindSi
 }
 
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::AllocateSystem()
+IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::allocateSystem()
 {
   Lhs.resize(n_vert_vars * 2, n_vert_vars * 2);
   Constraints.resize(num_constraint_equations, num_total_vars);
@@ -920,16 +920,16 @@ IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::Alloca
 
 ///intitialize the whole matrix
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::InitMatrix()
+IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::initMatrix()
 {
-  FindSizes();
-  AllocateSystem();
+  findSizes();
+  allocateSystem();
 }
 
 ///map back coordinates after that
 ///the system has been solved
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::MapCoords()
+IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::mapCoords()
 {
   ///map coords to faces
   for (unsigned int f=0;f<Fcut.rows();f++)
@@ -959,27 +959,27 @@ IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::MapCoo
 
 ///set the constraints for the inter-range cuts
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::BuildSeamConstraintsExplicitTranslation()
+IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::buildSeamConstraintsExplicitTranslation()
 {
   ///current constraint row
   int constr_row = 0;
 
   for (unsigned int i=0; i<num_cut_constraint; i++)
   {
-    unsigned char interval = Handle_SystemInfo.EdgeSeamInfo[i].MMatch;
+    unsigned char interval = systemInfo.edgeSeamInfo[i].MMatch;
     if (interval==1)
       interval=3;
     else
       if(interval==3)
         interval=1;
 
-    int p0  = Handle_SystemInfo.EdgeSeamInfo[i].v0;
-    int p0p = Handle_SystemInfo.EdgeSeamInfo[i].v0p;
+    int p0  = systemInfo.edgeSeamInfo[i].v0;
+    int p0p = systemInfo.edgeSeamInfo[i].v0p;
 
-    std::complex<double> rot = GetRotationComplex(interval);
+    std::complex<double> rot = getRotationComplex(interval);
 
     ///get the integer variable
-    int integerVar = n_vert_vars + Handle_SystemInfo.EdgeSeamInfo[i].integerVar;
+    int integerVar = n_vert_vars + systemInfo.edgeSeamInfo[i].integerVar;
 
     if (integer_rounding)
     {
@@ -1009,7 +1009,7 @@ IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::BuildS
 
 ///set the constraints for the inter-range cuts
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::BuildUserDefinedConstraints()
+IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::buildUserDefinedConstraints()
 {
   /// the user defined constraints are at the end
   int offset_row = num_cut_constraint*2 + n_fixed_vars*2;
@@ -1033,9 +1033,9 @@ IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::BuildU
 
 ///call of the mixed integer solver
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::MixedIntegerSolve(double cone_grid_res,
-                                                                          bool direct_round,
-                                                                          int localIter)
+IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::mixedIntegerSolve(double cone_grid_res,
+                                                                                            bool direct_round,
+                                                                                            int localIter)
 {
   X = std::vector<double>((n_vert_vars+n_integer_vars)*2);
   if (DEBUGPRINT)
@@ -1133,7 +1133,7 @@ template <typename DerivedV, typename DerivedF>
 IGL_INLINE void igl::copyleft::comiso::PoissonSolver<DerivedV, DerivedF>::addSharpEdgeConstraint(int fid, int vid)
 {
   // prepare constraint
-  std::vector<int> c(Handle_SystemInfo.num_vert_variables*2 + 1, 0);
+  std::vector<int> c(systemInfo.num_vert_variables*2 + 1, 0);
 
   int v1 = Fcut(fid,vid);
   int v2 = Fcut(fid,(vid+1)%3);
@@ -1169,32 +1169,32 @@ IGL_INLINE igl::copyleft::comiso::MIQ_class<DerivedV, DerivedF, DerivedU>::MIQ_c
                                                                    const Eigen::PlainObjectBase<DerivedF> &F_,
                                                                    const Eigen::PlainObjectBase<DerivedV> &PD1_combed,
                                                                    const Eigen::PlainObjectBase<DerivedV> &PD2_combed,
-                                                                   const Eigen::Matrix<int, Eigen::Dynamic, 3> &Handle_MMatch,
-                                                                   const Eigen::Matrix<int, Eigen::Dynamic, 1> &Handle_Singular,
-                                                                   const Eigen::Matrix<int, Eigen::Dynamic, 3> &Handle_Seams,
+                                                                   const Eigen::Matrix<int, Eigen::Dynamic, 3> &mismatch,
+                                                                   const Eigen::Matrix<int, Eigen::Dynamic, 1> &singular,
+                                                                   const Eigen::Matrix<int, Eigen::Dynamic, 3> &seams,
                                                                    Eigen::PlainObjectBase<DerivedU> &UV,
                                                                    Eigen::PlainObjectBase<DerivedF> &FUV,
-                                                                   double GradientSize,
-                                                                   double Stiffness,
-                                                                   bool DirectRound,
+                                                                   double gradientSize,
+                                                                   double stiffness,
+                                                                   bool directRound,
                                                                    int iter,
                                                                    int localIter,
-                                                                   bool DoRound,
-                                                                   bool SingularityRound,
+                                                                   bool doRound,
+                                                                   bool singularityRound,
                                                                    std::vector<int> roundVertices,
                                                                    std::vector<std::vector<int> > hardFeatures):
 V(V_),
 F(F_)
 {
-  igl::cut_mesh(V, F, Handle_Seams, Vcut, Fcut);
+  igl::cut_mesh(V, F, seams, Vcut, Fcut);
 
   igl::local_basis(V,F,B1,B2,B3);
   igl::triangle_triangle_adjacency(F,TT,TTi);
 
   // Prepare indexing for the linear system
-  VertexIndexing<DerivedV, DerivedF> VInd(V, F, Vcut, Fcut, TT, TTi, Handle_MMatch, Handle_Singular, Handle_Seams);
+  VertexIndexing<DerivedV, DerivedF> VInd(V, F, Vcut, Fcut, TT, TTi, mismatch, singular, seams);
 
-  VInd.InitSeamInfo();
+  VInd.initSeamInfo();
 
   // Assemble the system and solve
   PoissonSolver<DerivedV, DerivedF> PSolver(V,
@@ -1205,8 +1205,8 @@ F(F_)
                                             TTi,
                                             PD1_combed,
                                             PD2_combed,
-                                            Handle_Singular,
-                                            VInd.Handle_SystemInfo);
+                                            singular,
+                                            VInd.systemInfo);
   Handle_Stiffness = Eigen::VectorXd::Constant(F.rows(),1);
 
 
@@ -1214,16 +1214,18 @@ F(F_)
   {
     for (int i=0;i<iter;i++)
     {
-      PSolver.SolvePoisson(Handle_Stiffness, GradientSize,1.f,DirectRound,localIter,DoRound,SingularityRound,roundVertices,hardFeatures);
+      PSolver.solvePoisson(Handle_Stiffness, gradientSize, 1.f, directRound, localIter, doRound, singularityRound,
+                           roundVertices, hardFeatures);
       int nflips=NumFlips(PSolver.WUV);
-      bool folded = updateStiffeningJacobianDistorsion(GradientSize,PSolver.WUV);
+      bool folded = updateStiffeningJacobianDistorsion(gradientSize,PSolver.WUV);
       printf("ITERATION %d FLIPS %d \n",i,nflips);
       if (!folded)break;
     }
   }
   else
   {
-    PSolver.SolvePoisson(Handle_Stiffness,GradientSize,1.f,DirectRound,localIter,DoRound,SingularityRound,roundVertices,hardFeatures);
+    PSolver.solvePoisson(Handle_Stiffness, gradientSize, 1.f, directRound, localIter, doRound, singularityRound,
+                         roundVertices, hardFeatures);
   }
 
   int nflips=NumFlips(PSolver.WUV);
@@ -1329,7 +1331,7 @@ IGL_INLINE double igl::copyleft::comiso::MIQ_class<DerivedV, DerivedF, DerivedU>
 }
 
 ////////////////////////////////////////////////////////////////////////////
-// Approximate the distortion laplacian using a uniform laplacian on
+// Approximate the distortion Laplacian using a uniform Laplacian on
 //  the dual mesh:
 //      ___________
 //      \-1 / \-1 /
@@ -1338,9 +1340,9 @@ IGL_INLINE double igl::copyleft::comiso::MIQ_class<DerivedV, DerivedF, DerivedU>
 //         \-1 /
 //          \ /
 //
-//  @param[in]  f   facet on which to compute distortion laplacian
+//  @param[in]  f   facet on which to compute distortion Laplacian
 //  @param[in]  h   scaling factor applied to cross field
-//  @return     distortion laplacian for f
+//  @return     distortion Laplacian for f
 ///////////////////////////////////////////////////////////////////////////
 template <typename DerivedV, typename DerivedF, typename DerivedU>
 IGL_INLINE double igl::copyleft::comiso::MIQ_class<DerivedV, DerivedF, DerivedU>::LaplaceDistortion(const int f, double h, const Eigen::MatrixXd& WUV)
@@ -1424,39 +1426,39 @@ IGL_INLINE void igl::copyleft::comiso::miq(
   const Eigen::PlainObjectBase<DerivedF> &F,
   const Eigen::PlainObjectBase<DerivedV> &PD1_combed,
   const Eigen::PlainObjectBase<DerivedV> &PD2_combed,
-  const Eigen::Matrix<int, Eigen::Dynamic, 3> &Handle_MMatch,
-  const Eigen::Matrix<int, Eigen::Dynamic, 1> &Handle_Singular,
-  const Eigen::Matrix<int, Eigen::Dynamic, 3> &Handle_Seams,
+  const Eigen::Matrix<int, Eigen::Dynamic, 3> &mismatch,
+  const Eigen::Matrix<int, Eigen::Dynamic, 1> &singular,
+  const Eigen::Matrix<int, Eigen::Dynamic, 3> &seams,
   Eigen::PlainObjectBase<DerivedU> &UV,
   Eigen::PlainObjectBase<DerivedF> &FUV,
-  double GradientSize,
-  double Stiffness,
-  bool DirectRound,
+  double gradientSize,
+  double stiffness,
+  bool directRound,
   int iter,
   int localIter,
-  bool DoRound,
-  bool SingularityRound,
+  bool doRound,
+  bool singularityRound,
   std::vector<int> roundVertices,
   std::vector<std::vector<int> > hardFeatures)
 {
-  GradientSize = GradientSize/(V.colwise().maxCoeff()-V.colwise().minCoeff()).norm();
+  gradientSize = gradientSize/(V.colwise().maxCoeff()-V.colwise().minCoeff()).norm();
 
   igl::copyleft::comiso::MIQ_class<DerivedV, DerivedF, DerivedU> miq(V,
     F,
     PD1_combed,
     PD2_combed,
-    Handle_MMatch,
-    Handle_Singular,
-    Handle_Seams,
+    mismatch,
+    singular,
+    seams,
     UV,
     FUV,
-    GradientSize,
-    Stiffness,
-    DirectRound,
+    gradientSize,
+    stiffness,
+    directRound,
     iter,
     localIter,
-    DoRound,
-    SingularityRound,
+    doRound,
+    singularityRound,
     roundVertices,
     hardFeatures);
 
@@ -1471,13 +1473,13 @@ IGL_INLINE void igl::copyleft::comiso::miq(
     const Eigen::PlainObjectBase<DerivedV> &PD2,
     Eigen::PlainObjectBase<DerivedU> &UV,
     Eigen::PlainObjectBase<DerivedF> &FUV,
-    double GradientSize,
-    double Stiffness,
-    bool DirectRound,
+    double gradientSize,
+    double stiffness,
+    bool directRound,
     int iter,
     int localIter,
-    bool DoRound,
-    bool SingularityRound,
+    bool doRound,
+    bool singularityRound,
     std::vector<int> roundVertices,
     std::vector<std::vector<int> > hardFeatures)
 {
@@ -1489,7 +1491,7 @@ IGL_INLINE void igl::copyleft::comiso::miq(
   igl::comb_cross_field(V, F, BIS1, BIS2, BIS1_combed, BIS2_combed);
 
   DerivedF Handle_MMatch;
-  igl::cross_field_missmatch(V, F, BIS1_combed, BIS2_combed, true, Handle_MMatch);
+  igl::cross_field_mismatch(V, F, BIS1_combed, BIS2_combed, true, Handle_MMatch);
 
   Eigen::Matrix<int, Eigen::Dynamic, 1> isSingularity, singularityIndex;
   igl::find_cross_field_singularities(V, F, Handle_MMatch, isSingularity, singularityIndex);
@@ -1501,24 +1503,23 @@ IGL_INLINE void igl::copyleft::comiso::miq(
   igl::comb_frame_field(V, F, PD1, PD2, BIS1_combed, BIS2_combed, PD1_combed, PD2_combed);
 
   igl::copyleft::comiso::miq(V,
-           F,
-           PD1_combed,
-           PD2_combed,
-           Handle_MMatch,
-           isSingularity,
-           Handle_Seams,
-           UV,
-           FUV,
-           GradientSize,
-           Stiffness,
-           DirectRound,
-           iter,
-           localIter,
-           DoRound,
-           SingularityRound,
-           roundVertices,
-           hardFeatures);
-
+    F,
+    PD1_combed,
+    PD2_combed,
+    Handle_MMatch,
+    isSingularity,
+    Handle_Seams,
+    UV,
+    FUV,
+    gradientSize,
+    stiffness,
+    directRound,
+    iter,
+    localIter,
+    doRound,
+    singularityRound,
+    roundVertices,
+    hardFeatures);
 }
 
 #ifdef IGL_STATIC_LIBRARY

+ 64 - 40
include/igl/copyleft/comiso/miq.h

@@ -17,35 +17,37 @@ namespace igl
   {
   namespace comiso
   {
-  // Global seamless parametrization aligned with a given per-face jacobian (PD1,PD2).
+    // Global seamless parametrization aligned with a given per-face Jacobian (PD1, PD2).
     // The algorithm is based on
     // "Mixed-Integer Quadrangulation" by D. Bommes, H. Zimmer, L. Kobbelt
     // ACM SIGGRAPH 2009, Article No. 77 (http://dl.acm.org/citation.cfm?id=1531383)
     // We thank Nico Pietroni for providing a reference implementation of MIQ
     // on which our code is based.
 
-    // Inputs:
-    //   V              #V by 3 list of mesh vertex 3D positions
-    //   F              #F by 3 list of faces indices in V
-    //   PD1            #V by 3 first line of the Jacobian per triangle
-    //   PD2            #V by 3 second line of the Jacobian per triangle
-    //                  (optional, if empty it will be a vector in the tangent plane orthogonal to PD1)
-    //   scale          global scaling for the gradient (controls the quads resolution)
-    //   stiffness      weight for the stiffness iterations
-    //   direct_round   greedily round all integer variables at once (greatly improves optimization speed but lowers quality)
-    //   iter           stiffness iterations (0 = no stiffness)
-    //   local_iter     number of local iterations for the integer rounding
-    //   do_round       enables the integer rounding (disabling it could be useful for debugging)
-    //   round_vertices id of additional vertices that should be snapped to integer coordinates
-    //   hard_features  #H by 2 list of pairs of vertices that belongs to edges that should be snapped to integer coordinates
+    //  Limitations:
+    //  -  Due to the way of handling of hardFeatures the algorithm  may fail in difficult cases.
+    //  -  Meshes with boundaries are not hendled properly i.e., jagged edges along the boundary are possible
+
+    // Input:
+    // V                 #V by 3 list of mesh vertex 3D positions
+    // F                 #F by 3 list of faces indices in V
+    // PD1               #V by 3 first line of the Jacobian per triangle
+    // PD2               #V by 3 second line of the Jacobian per triangle
+    //                   (optional, if empty it will be a vector in the tangent plane orthogonal to PD1)
+    // gradientSize      global scaling for the gradient (controls the quads resolution)
+    // stiffness         weight for the stiffness iterations (Reserved but not used!)
+    // directRound       greedily round all integer variables at once (greatly improves optimization speed but lowers quality)
+    // iter              stiffness iterations (0 = no stiffness)
+    // localIter         number of local iterations for the integer rounding
+    // doRound           enables the integer rounding (disabling it could be useful for debugging)
+    // singularityRound  set true/false to decide if the singularities' coordinates should be rounded to the nearest integers
+    // roundVertices     id of additional vertices that should be snapped to integer coordinates
+    // hardFeatures      #H by 2 list of pairs of vertices that belongs to edges that should be snapped to integer coordinates
     //
     // Output:
-    //   UV             #UV by 2 list of vertices in 2D
-    //   FUV            #FUV by 3 list of face indices in UV
+    // UV                 #UV by 2 list of vertices in 2D
+    // FUV                #FUV by 3 list of face indices in UV
     //
-    // TODO: rename the parameters name in the cpp consistently
-    //       improve the handling of hard_features, right now it might fail in difficult cases
-
     template <typename DerivedV, typename DerivedF, typename DerivedU>
     IGL_INLINE void miq(
       const Eigen::PlainObjectBase<DerivedV> &V,
@@ -54,39 +56,61 @@ namespace igl
       const Eigen::PlainObjectBase<DerivedV> &PD2,
       Eigen::PlainObjectBase<DerivedU> &UV,
       Eigen::PlainObjectBase<DerivedF> &FUV,
-      double scale = 30.0,
+      double gradientSize = 30.0,
       double stiffness = 5.0,
-      bool direct_round = false,
+      bool directRound = false,
       int iter = 5,
-      int local_iter = 5,
-      bool DoRound = true,bool SingularityRound=true,
-      std::vector<int> round_vertices = std::vector<int>(),
-      std::vector<std::vector<int> > hard_features = std::vector<std::vector<int> >());
+      int localIter = 5,
+      bool doRound = true,
+      bool singularityRound = true,
+      std::vector<int> roundVertices = std::vector<int>(),
+      std::vector<std::vector<int> > hardFeatures = std::vector<std::vector<int> >());
 
     // Helper function that allows to directly provided pre-combed bisectors for an already cut mesh
-    // Additional input:
-    // PD1_combed, PD2_combed  :   #F by 3 combed jacobian
-    // BIS1_combed, BIS2_combed:   #F by 3 pre combed bi-sectors
-    // MMatch:                     #F by 3 list of per-corner integer PI/2 rotations
-    // Singular:                   #V list of flag that denotes if a vertex is singular or not
-    // SingularDegree:             #V list of flag that denotes the degree of the singularity
-    // Seams:                      #F by 3 list of per-corner flag that denotes seams
 
+    // Input:
+    // V                  #V by 3 list of mesh vertex 3D positions
+    // F                  #F by 3 list of faces indices in V
+
+    // Additional Input:
+    // PD1_combed         #F by 3 first combed Jacobian
+    // PD2_combed         #F by 3 second combed Jacobian
+    // mismatch             #F by 3 list of per-corner integer PI/2 rotations
+    // singular           #V list of flag that denotes if a vertex is singular or not
+    // seams              #F by 3 list of per-corner flag that denotes seams
+
+    // Input:
+    // gradientSize       global scaling for the gradient (controls the quads resolution)
+    // stiffness          weight for the stiffness iterations (Reserved but not used!)
+    // directRound        greedily round all integer variables at once (greatly improves optimization speed but lowers quality)
+    // iter               stiffness iterations (0 = no stiffness)
+    // localIter          number of local iterations for the integer rounding
+    // doRound            enables the integer rounding (disabling it could be useful for debugging)
+    // singularityRound   set true/false to decide if the singularities' coordinates should be rounded to the nearest integers
+    // roundVertices      id of additional vertices that should be snapped to integer coordinates
+    // hardFeatures       #H by 2 list of pairs of vertices that belongs to edges that should be snapped to integer coordinates
+
+    // Output:
+    // UV                 #UV by 2 list of vertices in 2D
+    // FUV                #FUV by 3 list of face indices in UV
+    //
     template <typename DerivedV, typename DerivedF, typename DerivedU>
     IGL_INLINE void miq(const Eigen::PlainObjectBase<DerivedV> &V,
       const Eigen::PlainObjectBase<DerivedF> &F,
       const Eigen::PlainObjectBase<DerivedV> &PD1_combed,
       const Eigen::PlainObjectBase<DerivedV> &PD2_combed,
-      const Eigen::Matrix<int, Eigen::Dynamic, 3> &MMatch,
-      const Eigen::Matrix<int, Eigen::Dynamic, 1> &Singular,
-      const Eigen::Matrix<int, Eigen::Dynamic, 3> &Seams,
+      const Eigen::Matrix<int, Eigen::Dynamic, 3> &mismatch,
+      const Eigen::Matrix<int, Eigen::Dynamic, 1> &singular,
+      const Eigen::Matrix<int, Eigen::Dynamic, 3> &seams,
       Eigen::PlainObjectBase<DerivedU> &UV,
       Eigen::PlainObjectBase<DerivedF> &FUV,
-      double GradientSize = 30.0,
-      double Stiffness = 5.0,
-      bool DirectRound = false,
+      double gradientSize = 30.0,
+      double stiffness = 5.0,
+      bool directRound = false,
       int iter = 5,
-      int localIter = 5, bool DoRound = true,bool SingularityRound=true,
+      int localIter = 5,
+      bool doRound = true,
+      bool singularityRound = true,
       std::vector<int> roundVertices = std::vector<int>(),
       std::vector<std::vector<int> > hardFeatures = std::vector<std::vector<int> >());
   };

+ 37 - 61
include/igl/copyleft/comiso/nrosy.cpp

@@ -13,9 +13,6 @@
 #include <igl/edge_topology.h>
 #include <igl/per_face_normals.h>
 
-#include <iostream>
-#include <fstream>
-
 #include <stdexcept>
 
 #include <Eigen/Geometry>
@@ -297,9 +294,18 @@ void igl::copyleft::comiso::NRosyField::prepareSystemMatrix(const int N)
     if (!isFixed_i)
     {
       row = tag_t[i];
-      if (isFixed_i) b(row) += -2               * hard[i]; else T.push_back(Eigen::Triplet<double>(row,tag_t[i]  , 2             ));
-      if (isFixed_j) b(row) +=  2               * hard[j]; else T.push_back(Eigen::Triplet<double>(row,tag_t[j]  ,-2             ));
-      if (isFixed_p) b(row) += -((4 * igl::PI)/Nd) * p[eid] ; else T.push_back(Eigen::Triplet<double>(row,tag_p[eid],((4 * igl::PI)/Nd)));
+      if (isFixed_i)
+        b(row) += -2 * hard[i];
+      else
+        T.emplace_back(row, tag_t[i], 2);
+      if (isFixed_j)
+        b(row) +=  2 * hard[j];
+      else
+        T.emplace_back(row, tag_t[j], -2);
+      if (isFixed_p)
+        b(row) += -((4 * igl::PI)/Nd) * p[eid];
+      else
+        T.emplace_back(row, tag_p[eid],((4 * igl::PI)/Nd));
       b(row) += -2 * k[eid];
       assert(hard[i] == hard[i]);
       assert(hard[j] == hard[j]);
@@ -311,9 +317,18 @@ void igl::copyleft::comiso::NRosyField::prepareSystemMatrix(const int N)
     if (!isFixed_j)
     {
       row = tag_t[j];
-      if (isFixed_i) b(row) += 2               * hard[i]; else T.push_back(Eigen::Triplet<double>(row,tag_t[i]  , -2             ));
-      if (isFixed_j) b(row) += -2              * hard[j]; else T.push_back(Eigen::Triplet<double>(row,tag_t[j] ,  2              ));
-      if (isFixed_p) b(row) += ((4 * igl::PI)/Nd) * p[eid] ; else T.push_back(Eigen::Triplet<double>(row,tag_p[eid],-((4 * igl::PI)/Nd)));
+      if (isFixed_i)
+        b(row) += 2 * hard[i];
+      else
+        T.emplace_back(row,tag_t[i], -2);
+      if (isFixed_j)
+        b(row) += -2 * hard[j];
+      else
+        T.emplace_back(row, tag_t[j], 2);
+      if (isFixed_p)
+        b(row) += (( 4. * igl::PI)/Nd) * p[eid];
+      else
+        T.emplace_back(row, tag_p[eid], -((4. * igl::PI)/Nd));
       b(row) += 2 * k[eid];
       assert(k[eid] == k[eid]);
       assert(b(row) == b(row));
@@ -322,10 +337,19 @@ void igl::copyleft::comiso::NRosyField::prepareSystemMatrix(const int N)
     if (!isFixed_p)
     {
       row = tag_p[eid];
-      if (isFixed_i) b(row) += -(4 * igl::PI)/Nd              * hard[i]; else T.push_back(Eigen::Triplet<double>(row,tag_t[i] ,   (4 * igl::PI)/Nd             ));
-      if (isFixed_j) b(row) +=  (4 * igl::PI)/Nd              * hard[j]; else T.push_back(Eigen::Triplet<double>(row,tag_t[j] ,  -(4 * igl::PI)/Nd             ));
-      if (isFixed_p) b(row) += -(2 * pow(((2*igl::PI)/Nd),2)) * p[eid] ;  else T.push_back(Eigen::Triplet<double>(row,tag_p[eid],  (2 * pow(((2*igl::PI)/Nd),2))));
-      b(row) += - (4 * igl::PI)/Nd * k[eid];
+      if (isFixed_i)
+        b(row) += -(4. * igl::PI)/Nd * hard[i];
+      else
+        T.emplace_back(row, tag_t[i], (4. * igl::PI)/Nd);
+      if (isFixed_j)
+        b(row) += (4. * igl::PI)/Nd * hard[j];
+      else
+        T.emplace_back(row, tag_t[j], -(4. * igl::PI)/Nd);
+      if (isFixed_p)
+        b(row) += -(2. * pow (((2. * igl::PI)/Nd), 2)) * p[eid];
+      else
+        T.emplace_back(row, tag_p[eid], (2. * pow(((2. * igl::PI)/Nd), 2)));
+      b(row) += - ( 4. * igl::PI ) / Nd * k[eid];
       assert(k[eid] == k[eid]);
       assert(b(row) == b(row));
     }
@@ -363,16 +387,6 @@ void igl::copyleft::comiso::NRosyField::prepareSystemMatrix(const int N)
     SparseMatrix<double> ASoft(count_t + count_p, count_t + count_p);
     ASoft.setFromTriplets(TSoft.begin(), TSoft.end());
 
-//    ofstream s("/Users/daniele/As.txt");
-//    for(unsigned i=0; i<TSoft.size(); ++i)
-//      s << TSoft[i].row() << " " << TSoft[i].col() << " " << TSoft[i].value() << endl;
-//    s.close();
-
-//    ofstream s2("/Users/daniele/bs.txt");
-//    for(unsigned i=0; i<bSoft.rows(); ++i)
-//      s2 << bSoft(i) << endl;
-//    s2.close();
-
     // Stupid Eigen bug
     SparseMatrix<double> Atmp (count_t + count_p, count_t + count_p);
     SparseMatrix<double> Atmp2(count_t + count_p, count_t + count_p);
@@ -386,19 +400,6 @@ void igl::copyleft::comiso::NRosyField::prepareSystemMatrix(const int N)
     A = Atmp3;
     b = b*(1.0 - softAlpha) + bSoft * softAlpha;
   }
-
-//  ofstream s("/Users/daniele/A.txt");
-//  for (int k=0; k<A.outerSize(); ++k)
-//    for (SparseMatrix<double>::InnerIterator it(A,k); it; ++it)
-//    {
-//      s << it.row() << " " << it.col() << " " << it.value() << endl;
-//    }
-//  s.close();
-//
-//  ofstream s2("/Users/daniele/b.txt");
-//  for(unsigned i=0; i<b.rows(); ++i)
-//    s2 << b(i) << endl;
-//  s2.close();
 }
 
 void igl::copyleft::comiso::NRosyField::solveNoRoundings()
@@ -460,7 +461,6 @@ void igl::copyleft::comiso::NRosyField::solveRoundings()
   gmm::row_matrix< gmm::wsvector< double > > gmm_C(0, n);
 
   COMISO::ConstrainedSolver cs;
-  //print_miso_settings(cs.misolver());
   cs.solve(gmm_C, gmm_A, x, gmm_b, ids_to_round, 0.0, false, true);
 
   // Copy the result back
@@ -503,19 +503,6 @@ void igl::copyleft::comiso::NRosyField::solve(const int N)
   // Solve with integer roundings
   solveRoundings();
 
-  // This is a very greedy solving strategy
-  // // Solve with no roundings
-  // solveNoRoundings();
-  //
-  // // Round all p and fix them
-  // roundAndFix();
-  //
-  // // Build the system
-  // prepareSystemMatrix(N);
-  //
-  // // Solve with no roundings (they are all fixed)
-  // solveNoRoundings();
-
   // Find the cones
   findCones(N);
 }
@@ -688,11 +675,6 @@ void igl::copyleft::comiso::NRosyField::reduceSpace()
 
   vector<VectorXd> debug;
 
-  // debug
-//  MatrixXd B(F.rows(),3);
-//  for(unsigned i=0; i<F.rows(); ++i)
-//    B.row(i) = 1./3. * (V.row(F(i,0)) + V.row(F(i,1)) + V.row(F(i,2)));
-
   vector<bool> visited(EV.rows());
   for(unsigned i=0; i<EV.rows(); ++i)
     visited[i] = false;
@@ -766,12 +748,6 @@ void igl::copyleft::comiso::NRosyField::reduceSpace()
       }
     }
   }
-
-//  std::ofstream s("/Users/daniele/debug.txt");
-//  for(unsigned i=0; i<debug.size(); i += 2)
-//    s << debug[i].transpose() << " " << debug[i+1].transpose() << endl;
-//  s.close();
-
 }
 
 double igl::copyleft::comiso::NRosyField::convert3DtoLocal(unsigned fid, const Eigen::Vector3d& v)

+ 132 - 0
include/igl/cross_field_mismatch.cpp

@@ -0,0 +1,132 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+//
+// Copyright (C) 2014 Daniele Panozzo <daniele.panozzo@gmail.com>, Olga Diamanti <olga.diam@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
+// obtain one at http://mozilla.org/MPL/2.0/.
+
+#include "cross_field_mismatch.h"
+
+#include <cmath>
+#include <vector>
+#include <deque>
+#include <igl/comb_cross_field.h>
+#include <igl/per_face_normals.h>
+#include <igl/is_border_vertex.h>
+#include <igl/vertex_triangle_adjacency.h>
+#include <igl/triangle_triangle_adjacency.h>
+#include <igl/rotation_matrix_from_directions.h>
+#include <igl/PI.h>
+
+namespace igl {
+  template <typename DerivedV, typename DerivedF, typename DerivedM>
+  class MismatchCalculator
+  {
+  public:
+
+    const Eigen::PlainObjectBase<DerivedV> &V;
+    const Eigen::PlainObjectBase<DerivedF> &F;
+    const Eigen::PlainObjectBase<DerivedV> &PD1;
+    const Eigen::PlainObjectBase<DerivedV> &PD2;
+    
+    DerivedV N;
+
+  private:
+    // internal
+    std::vector<bool> V_border; // bool
+    std::vector<std::vector<int> > VF;
+    std::vector<std::vector<int> > VFi;
+    
+    DerivedF TT;
+    DerivedF TTi;
+
+
+  private:
+    ///compute the mismatch between 2 faces
+    inline int mismatchByCross(const int f0,
+                               const int f1)
+    {
+      Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir0 = PD1.row(f0);
+      Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir1 = PD1.row(f1);
+      Eigen::Matrix<typename DerivedV::Scalar, 3, 1> n0 = N.row(f0);
+      Eigen::Matrix<typename DerivedV::Scalar, 3, 1> n1 = N.row(f1);
+
+      Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir1Rot = igl::rotation_matrix_from_directions(n1,n0)*dir1;
+      dir1Rot.normalize();
+
+      double angle_diff = atan2(dir1Rot.dot(PD2.row(f0)),dir1Rot.dot(PD1.row(f0)));
+
+      double step=igl::PI/2.0;
+      int i=(int)std::floor((angle_diff/step)+0.5);
+      int k=0;
+      if (i>=0)
+        k=i%4;
+      else
+        k=(-(3*i))%4;
+      return k;
+    }
+
+
+public:
+  inline MismatchCalculator(const Eigen::PlainObjectBase<DerivedV> &_V,
+                            const Eigen::PlainObjectBase<DerivedF> &_F,
+                            const Eigen::PlainObjectBase<DerivedV> &_PD1,
+                            const Eigen::PlainObjectBase<DerivedV> &_PD2):
+  V(_V),
+  F(_F),
+  PD1(_PD1),
+  PD2(_PD2)
+  {
+    igl::per_face_normals(V,F,N);
+    V_border = igl::is_border_vertex(V,F);
+    igl::vertex_triangle_adjacency(V,F,VF,VFi);
+    igl::triangle_triangle_adjacency(F,TT,TTi);
+  }
+
+  inline void calculateMismatch(Eigen::PlainObjectBase<DerivedM> &Handle_MMatch)
+  {
+    Handle_MMatch.setConstant(F.rows(),3,-1);
+    for (size_t i=0;i<F.rows();i++)
+    {
+      for (int j=0;j<3;j++)
+      {
+        if (((int)i)==TT(i,j) || TT(i,j) == -1)
+          Handle_MMatch(i,j)=0;
+        else
+          Handle_MMatch(i,j) = mismatchByCross(i, TT(i, j));
+      }
+    }
+  }
+
+};
+}
+template <typename DerivedV, typename DerivedF, typename DerivedM>
+IGL_INLINE void igl::cross_field_mismatch(const Eigen::PlainObjectBase<DerivedV> &V,
+                                          const Eigen::PlainObjectBase<DerivedF> &F,
+                                          const Eigen::PlainObjectBase<DerivedV> &PD1,
+                                          const Eigen::PlainObjectBase<DerivedV> &PD2,
+                                          const bool isCombed,
+                                          Eigen::PlainObjectBase<DerivedM> &mismatch)
+{
+  DerivedV PD1_combed;
+  DerivedV PD2_combed;
+
+  if (!isCombed)
+    igl::comb_cross_field(V,F,PD1,PD2,PD1_combed,PD2_combed);
+  else
+  {
+    PD1_combed = PD1;
+    PD2_combed = PD2;
+  }
+  igl::MismatchCalculator<DerivedV, DerivedF, DerivedM> sf(V, F, PD1_combed, PD2_combed);
+  sf.calculateMismatch(mismatch);
+}
+
+#ifdef IGL_STATIC_LIBRARY
+// Explicit template instantiation
+template void igl::cross_field_mismatch<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 &,  Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const &,  Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const &, const bool,  Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > &);
+template void igl::cross_field_mismatch<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 &, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const &, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const &, const bool, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > &);
+template void igl::cross_field_mismatch<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const &, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const &, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const &, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const &, const bool, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > &);
+
+#endif

+ 43 - 0
include/igl/cross_field_mismatch.h

@@ -0,0 +1,43 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+//
+// Copyright (C) 2014 Daniele Panozzo <daniele.panozzo@gmail.com>, Olga Diamanti <olga.diam@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
+// obtain one at http://mozilla.org/MPL/2.0/.
+
+#ifndef IGL_CROSS_FIELD_MISMATCH_H
+#define IGL_CROSS_FIELD_MISMATCH_H
+#include "igl_inline.h"
+#include <Eigen/Core>
+namespace igl
+{
+  // Calculates the mismatch (integer), at each face edge, of a cross field defined on the mesh faces.
+  // The integer mismatch is a multiple of pi/2 that transforms the cross on one side of the edge to
+  // the cross on the other side. It represents the deviation from a Lie connection across the edge.
+
+  // Inputs:
+  //   V         #V by 3 eigen Matrix of mesh vertex 3D positions
+  //   F         #F by 3 eigen Matrix of face (quad) indices
+  //   PD1       #F by 3 eigen Matrix of the first per face cross field vector
+  //   PD2       #F by 3 eigen Matrix of the second per face cross field vector
+  //   isCombed  boolean, specifying whether the field is combed (i.e. matching has been precomputed.
+  //             If not, the field is combed first.
+  // Output:
+  //   mismatch  #F by 3 eigen Matrix containing the integer mismatch of the cross field
+  //             across all face edges
+  //
+
+  template <typename DerivedV, typename DerivedF, typename DerivedM>
+  IGL_INLINE void cross_field_mismatch(const Eigen::PlainObjectBase<DerivedV> &V,
+                                       const Eigen::PlainObjectBase<DerivedF> &F,
+                                       const Eigen::PlainObjectBase<DerivedV> &PD1,
+                                       const Eigen::PlainObjectBase<DerivedV> &PD2,
+                                       const bool isCombed,
+                                       Eigen::PlainObjectBase<DerivedM> &mismatch);
+}
+#ifndef IGL_STATIC_LIBRARY
+#include "cross_field_mismatch.cpp"
+#endif
+
+#endif

+ 0 - 142
include/igl/cross_field_missmatch.cpp

@@ -1,142 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-//
-// Copyright (C) 2014 Daniele Panozzo <daniele.panozzo@gmail.com>, Olga Diamanti <olga.diam@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
-// obtain one at http://mozilla.org/MPL/2.0/.
-
-#include "cross_field_missmatch.h"
-
-#include <cmath>
-#include <vector>
-#include <deque>
-#include <igl/comb_cross_field.h>
-#include <igl/per_face_normals.h>
-#include <igl/is_border_vertex.h>
-#include <igl/vertex_triangle_adjacency.h>
-#include <igl/triangle_triangle_adjacency.h>
-#include <igl/rotation_matrix_from_directions.h>
-#include <igl/PI.h>
-
-namespace igl {
-  template <typename DerivedV, typename DerivedF, typename DerivedM>
-  class MissMatchCalculator
-  {
-  public:
-
-    const Eigen::PlainObjectBase<DerivedV> &V;
-    const Eigen::PlainObjectBase<DerivedF> &F;
-    const Eigen::PlainObjectBase<DerivedV> &PD1;
-    const Eigen::PlainObjectBase<DerivedV> &PD2;
-    
-    DerivedV N;
-
-  private:
-    // internal
-    std::vector<bool> V_border; // bool
-    std::vector<std::vector<int> > VF;
-    std::vector<std::vector<int> > VFi;
-    
-    DerivedF TT;
-    DerivedF TTi;
-
-
-  private:
-    ///compute the mismatch between 2 faces
-    inline int MissMatchByCross(const int f0,
-                         const int f1)
-    {
-      Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir0 = PD1.row(f0);
-      Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir1 = PD1.row(f1);
-      Eigen::Matrix<typename DerivedV::Scalar, 3, 1> n0 = N.row(f0);
-      Eigen::Matrix<typename DerivedV::Scalar, 3, 1> n1 = N.row(f1);
-
-      Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir1Rot = igl::rotation_matrix_from_directions(n1,n0)*dir1;
-      dir1Rot.normalize();
-
-      // TODO: this should be equivalent to the other code below, to check!
-      // Compute the angle between the two vectors
-      //    double a0 = atan2(dir0.dot(B2.row(f0)),dir0.dot(B1.row(f0)));
-      //    double a1 = atan2(dir1Rot.dot(B2.row(f0)),dir1Rot.dot(B1.row(f0)));
-      //
-      //    double angle_diff = a1-a0;   //VectToAngle(f0,dir1Rot);
-
-      double angle_diff = atan2(dir1Rot.dot(PD2.row(f0)),dir1Rot.dot(PD1.row(f0)));
-
-      //    std::cerr << "Dani: " << dir0(0) << " " << dir0(1) << " " << dir0(2) << " " << dir1Rot(0) << " " << dir1Rot(1) << " " << dir1Rot(2) << " " << angle_diff << std::endl;
-
-      double step=igl::PI/2.0;
-      int i=(int)std::floor((angle_diff/step)+0.5);
-      int k=0;
-      if (i>=0)
-        k=i%4;
-      else
-        k=(-(3*i))%4;
-      return k;
-    }
-
-
-public:
-  inline MissMatchCalculator(const Eigen::PlainObjectBase<DerivedV> &_V,
-                      const Eigen::PlainObjectBase<DerivedF> &_F,
-                      const Eigen::PlainObjectBase<DerivedV> &_PD1,
-                      const Eigen::PlainObjectBase<DerivedV> &_PD2
-                      ):
-  V(_V),
-  F(_F),
-  PD1(_PD1),
-  PD2(_PD2)
-  {
-    igl::per_face_normals(V,F,N);
-    V_border = igl::is_border_vertex(V,F);
-    igl::vertex_triangle_adjacency(V,F,VF,VFi);
-    igl::triangle_triangle_adjacency(F,TT,TTi);
-  }
-
-  inline void calculateMissmatch(Eigen::PlainObjectBase<DerivedM> &Handle_MMatch)
-  {
-    Handle_MMatch.setConstant(F.rows(),3,-1);
-    for (size_t i=0;i<F.rows();i++)
-    {
-      for (int j=0;j<3;j++)
-      {
-        if (((int)i)==TT(i,j) || TT(i,j) == -1)
-          Handle_MMatch(i,j)=0;
-        else
-          Handle_MMatch(i,j) = MissMatchByCross(i,TT(i,j));
-      }
-    }
-  }
-
-};
-}
-template <typename DerivedV, typename DerivedF, typename DerivedM>
-IGL_INLINE void igl::cross_field_missmatch(const Eigen::PlainObjectBase<DerivedV> &V,
-                                           const Eigen::PlainObjectBase<DerivedF> &F,
-                                           const Eigen::PlainObjectBase<DerivedV> &PD1,
-                                           const Eigen::PlainObjectBase<DerivedV> &PD2,
-                                           const bool isCombed,
-                                           Eigen::PlainObjectBase<DerivedM> &missmatch)
-{
-  DerivedV PD1_combed;
-  DerivedV PD2_combed;
-
-  if (!isCombed)
-    igl::comb_cross_field(V,F,PD1,PD2,PD1_combed,PD2_combed);
-  else
-  {
-    PD1_combed = PD1;
-    PD2_combed = PD2;
-  }
-  igl::MissMatchCalculator<DerivedV, DerivedF, DerivedM> sf(V, F, PD1_combed, PD2_combed);
-  sf.calculateMissmatch(missmatch);
-}
-
-#ifdef IGL_STATIC_LIBRARY
-// Explicit template instantiation
-template void igl::cross_field_missmatch<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&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, bool, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
-template void igl::cross_field_missmatch<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&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, bool, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
-template void igl::cross_field_missmatch<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, bool, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
-
-#endif

+ 7 - 8
include/igl/find_cross_field_singularities.cpp

@@ -9,11 +9,10 @@
 #include "find_cross_field_singularities.h"
 
 #include <vector>
-#include <igl/cross_field_missmatch.h>
+#include <igl/cross_field_mismatch.h>
 #include <igl/is_border_vertex.h>
 #include <igl/vertex_triangle_adjacency.h>
 #include <igl/is_border_vertex.h>
-#include <igl/cross_field_missmatch.h>
 
 
 template <typename DerivedV, typename DerivedF, typename DerivedM, typename DerivedO>
@@ -38,7 +37,7 @@ IGL_INLINE void igl::find_cross_field_singularities(const Eigen::PlainObjectBase
     if (V_border[vid])
       continue;
 
-    int missmatch=0;
+    int mismatch=0;
     for (unsigned int i=0;i<VF[vid].size();i++)
     {
       // look for the vertex
@@ -48,12 +47,12 @@ IGL_INLINE void igl::find_cross_field_singularities(const Eigen::PlainObjectBase
           j=z;
       assert(j!=-1);
 
-      missmatch+=Handle_MMatch(VF[vid][i],j);
+      mismatch+=Handle_MMatch(VF[vid][i],j);
     }
-    missmatch=missmatch%4;
+    mismatch=mismatch%4;
 
-    isSingularity(vid)=(missmatch!=0);
-    singularityIndex(vid)=missmatch;
+    isSingularity(vid)=(mismatch!=0);
+    singularityIndex(vid)=mismatch;
   }
 
 
@@ -70,7 +69,7 @@ IGL_INLINE void igl::find_cross_field_singularities(const Eigen::PlainObjectBase
 {
   Eigen::Matrix<typename DerivedF::Scalar, Eigen::Dynamic, 3> Handle_MMatch;
 
-  igl::cross_field_missmatch(V, F, PD1, PD2, isCombed, Handle_MMatch);
+  igl::cross_field_mismatch(V, F, PD1, PD2, isCombed, Handle_MMatch);
   igl::find_cross_field_singularities(V, F, Handle_MMatch, isSingularity, singularityIndex);
 }
 

+ 3 - 3
include/igl/find_cross_field_singularities.h

@@ -18,7 +18,7 @@ namespace igl
   // Inputs:
   //   V                #V by 3 eigen Matrix of mesh vertex 3D positions
   //   F                #F by 3 eigen Matrix of face (quad) indices
-  //   Handle_MMatch    #F by 3 eigen Matrix containing the integer missmatch of the cross field
+  //   mismatch         #F by 3 eigen Matrix containing the integer mismatch of the cross field
   //                    across all face edges
   // Output:
   //   isSingularity    #V by 1 boolean eigen Vector indicating the presence of a singularity on a vertex
@@ -27,11 +27,11 @@ namespace igl
   template <typename DerivedV, typename DerivedF, typename DerivedM, typename DerivedO>
   IGL_INLINE void find_cross_field_singularities(const Eigen::PlainObjectBase<DerivedV> &V,
                                                  const Eigen::PlainObjectBase<DerivedF> &F,
-                                                 const Eigen::PlainObjectBase<DerivedM> &Handle_MMatch,
+                                                 const Eigen::PlainObjectBase<DerivedM> &mismatch,
                                                  Eigen::PlainObjectBase<DerivedO> &isSingularity,
                                                  Eigen::PlainObjectBase<DerivedO> &singularityIndex);
 
-  // Wrapper that calculates the missmatch if it is not provided.
+  // Wrapper that calculates the mismatch if it is not provided.
   // Note that the field in PD1 and PD2 MUST BE combed (see igl::comb_cross_field).
   // Inputs:
   //   V                #V by 3 eigen Matrix of mesh vertex 3D positions

+ 14 - 14
include/igl/line_field_missmatch.cpp → include/igl/line_field_mismatch.cpp

@@ -6,7 +6,7 @@
 // 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/.
 
-#include "line_field_missmatch.h"
+#include "line_field_mismatch.h"
 
 #include <vector>
 #include <deque>
@@ -24,7 +24,7 @@
 
 namespace igl {
 template <typename DerivedV, typename DerivedF, typename DerivedO>
-class MissMatchCalculatorLine
+class MismatchCalculatorLine
 {
 public:
 
@@ -46,8 +46,8 @@ private:
 private:
 
     //compute the mismatch between 2 faces
-    inline int MissMatchByLine(const int f0,
-                               const int f1)
+    inline int mismatchByLine(const int f0,
+                              const int f1)
     {
         Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir0 = PD1.row(f0);
         Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir1 = PD1.row(f1);
@@ -81,7 +81,7 @@ private:
 
 public:
 
-    inline MissMatchCalculatorLine(const Eigen::PlainObjectBase<DerivedV> &_V,
+    inline MismatchCalculatorLine(const Eigen::PlainObjectBase<DerivedV> &_V,
                                const Eigen::PlainObjectBase<DerivedF> &_F,
                                const Eigen::PlainObjectBase<DerivedV> &_PD1,
                                const Eigen::PlainObjectBase<DerivedV> &_PD2
@@ -97,7 +97,7 @@ public:
         igl::triangle_triangle_adjacency(F,TT,TTi);
     }
 
-    inline void calculateMissmatchLine(Eigen::PlainObjectBase<DerivedO> &Handle_MMatch)
+    inline void calculateMismatchLine(Eigen::PlainObjectBase<DerivedO> &Handle_MMatch)
     {
         Handle_MMatch.setConstant(F.rows(),3,-1);
         for (unsigned int i=0;i<F.rows();i++)
@@ -107,7 +107,7 @@ public:
                 if (i==TT(i,j) || TT(i,j) == -1)
                     Handle_MMatch(i,j)=0;
                 else
-                    Handle_MMatch(i,j) = MissMatchByLine(i,TT(i,j));
+                    Handle_MMatch(i,j) = mismatchByLine(i, TT(i, j));
             }
         }
     }
@@ -117,11 +117,11 @@ public:
 
 
 template <typename DerivedV, typename DerivedF, typename DerivedO>
-IGL_INLINE void igl::line_field_missmatch(const Eigen::PlainObjectBase<DerivedV> &V,
-                                const Eigen::PlainObjectBase<DerivedF> &F,
-                                const Eigen::PlainObjectBase<DerivedV> &PD1,
-                                const bool isCombed,
-                                Eigen::PlainObjectBase<DerivedO> &missmatch)
+IGL_INLINE void igl::line_field_mismatch(const Eigen::PlainObjectBase<DerivedV> &V,
+                                         const Eigen::PlainObjectBase<DerivedF> &F,
+                                         const Eigen::PlainObjectBase<DerivedV> &PD1,
+                                         const bool isCombed,
+                                         Eigen::PlainObjectBase<DerivedO> &mismatch)
 {
     DerivedV PD1_combed;
     DerivedV PD2_combed;
@@ -135,8 +135,8 @@ IGL_INLINE void igl::line_field_missmatch(const Eigen::PlainObjectBase<DerivedV>
     Eigen::MatrixXd B1,B2,B3;
     igl::local_basis(V,F,B1,B2,B3);
     PD2_combed = igl::rotate_vectors(PD1_combed, Eigen::VectorXd::Constant(1,igl::PI/2), B1, B2);
-    igl::MissMatchCalculatorLine<DerivedV, DerivedF, DerivedO> sf(V, F, PD1_combed, PD2_combed);
-    sf.calculateMissmatchLine(missmatch);
+    igl::MismatchCalculatorLine<DerivedV, DerivedF, DerivedO> sf(V, F, PD1_combed, PD2_combed);
+    sf.calculateMismatchLine(mismatch);
 }
 
 #ifdef IGL_STATIC_LIBRARY

+ 11 - 12
include/igl/cross_field_missmatch.h → include/igl/line_field_mismatch.h

@@ -1,19 +1,19 @@
 // This file is part of libigl, a simple c++ geometry processing library.
 //
-// Copyright (C) 2014 Daniele Panozzo <daniele.panozzo@gmail.com>, Olga Diamanti <olga.diam@gmail.com>
+// Copyright (C) 2014 Nico Pietroni <nico.pietroni@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
 // obtain one at http://mozilla.org/MPL/2.0/.
 
-#ifndef IGL_CROSS_FIELD_MISSMATCH_H
-#define IGL_CROSS_FIELD_MISSMATCH_H
+#ifndef IGL_LINE_FIELD_MISSMATCH_H
+#define IGL_LINE_FIELD_MISSMATCH_H
 #include "igl_inline.h"
 #include <Eigen/Core>
 namespace igl
 {
-  // Calculates the missmatch (integer), at each face edge, of a cross field defined on the mesh faces.
-  // The integer missmatch is a multiple of pi/2 that transforms the cross on one side of the edge to
+  // Calculates the mismatch (integer), at each face edge, of a cross field defined on the mesh faces.
+  // The integer mismatch is a multiple of pi/2 that transforms the cross on one side of the edge to
   // the cross on the other side. It represents the deviation from a Lie connection across the edge.
 
   // Inputs:
@@ -24,20 +24,19 @@ namespace igl
   //   isCombed  boolean, specifying whether the field is combed (i.e. matching has been precomputed.
   //             If not, the field is combed first.
   // Output:
-  //   Handle_MMatch    #F by 3 eigen Matrix containing the integer missmatch of the cross field
-  //                    across all face edges
+  //   mismatch  #F by 3 eigen Matrix containing the integer mismatch of the cross field
+  //             across all face edges
   //
 
-  template <typename DerivedV, typename DerivedF, typename DerivedM>
-  IGL_INLINE void cross_field_missmatch(const Eigen::PlainObjectBase<DerivedV> &V,
+    template <typename DerivedV, typename DerivedF, typename DerivedO>
+    IGL_INLINE void line_field_mismatch(const Eigen::PlainObjectBase<DerivedV> &V,
                                         const Eigen::PlainObjectBase<DerivedF> &F,
                                         const Eigen::PlainObjectBase<DerivedV> &PD1,
-                                        const Eigen::PlainObjectBase<DerivedV> &PD2,
                                         const bool isCombed,
-                                        Eigen::PlainObjectBase<DerivedM> &missmatch);
+                                        Eigen::PlainObjectBase<DerivedO> &mismatch);
 }
 #ifndef IGL_STATIC_LIBRARY
-#include "cross_field_missmatch.cpp"
+#include "line_field_mismatch.cpp"
 #endif
 
 #endif

+ 0 - 42
include/igl/line_field_missmatch.h

@@ -1,42 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-//
-// Copyright (C) 2014 Nico Pietroni <nico.pietroni@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
-// obtain one at http://mozilla.org/MPL/2.0/.
-
-#ifndef IGL_LINE_FIELD_MISSMATCH_H
-#define IGL_LINE_FIELD_MISSMATCH_H
-#include "igl_inline.h"
-#include <Eigen/Core>
-namespace igl
-{
-  // Calculates the missmatch (integer), at each face edge, of a cross field defined on the mesh faces.
-  // The integer missmatch is a multiple of pi/2 that transforms the cross on one side of the edge to
-  // the cross on the other side. It represents the deviation from a Lie connection across the edge.
-
-  // Inputs:
-  //   V         #V by 3 eigen Matrix of mesh vertex 3D positions
-  //   F         #F by 3 eigen Matrix of face (quad) indices
-  //   PD1       #F by 3 eigen Matrix of the first per face cross field vector
-  //   PD2       #F by 3 eigen Matrix of the second per face cross field vector
-  //   isCombed  boolean, specifying whether the field is combed (i.e. matching has been precomputed.
-  //             If not, the field is combed first.
-  // Output:
-  //   Handle_MMatch    #F by 3 eigen Matrix containing the integer missmatch of the cross field
-  //                    across all face edges
-  //
-
-    template <typename DerivedV, typename DerivedF, typename DerivedO>
-    IGL_INLINE void line_field_missmatch(const Eigen::PlainObjectBase<DerivedV> &V,
-                                         const Eigen::PlainObjectBase<DerivedF> &F,
-                                         const Eigen::PlainObjectBase<DerivedV> &PD1,
-                                         const bool isCombed,
-                                         Eigen::PlainObjectBase<DerivedO> &missmatch);
-}
-#ifndef IGL_STATIC_LIBRARY
-#include "line_field_missmatch.cpp"
-#endif
-
-#endif

+ 1 - 1
include/igl/rotate_vectors.h

@@ -12,7 +12,7 @@
 #include <Eigen/Core>
 namespace igl
 {
-  // Rotate the vectors V by A radiants on the tangent plane spanned by B1 and
+  // Rotate the vectors V by A radians on the tangent plane spanned by B1 and
   // B2
   //
   // Inputs:

+ 3 - 3
python/py_doc.cpp

@@ -431,7 +431,7 @@ const char *__doc_igl_covariance_scatter_matrix = R"igl_Qu8mg5v7(// Construct th
   //   CSM dim*#V/#F by dim*#V sparse matrix containing special laplacians along
   //     the diagonal so that when multiplied by V gives covariance matrix
   //     elements, can be used to speed up covariance matrix computation)igl_Qu8mg5v7";
-const char *__doc_igl_cross_field_missmatch = R"igl_Qu8mg5v7(// Inputs:
+const char *__doc_igl_cross_field_mismatch = R"igl_Qu8mg5v7(// Inputs:
   //   V         #V by 3 eigen Matrix of mesh vertex 3D positions
   //   F         #F by 3 eigen Matrix of face (quad) indices
   //   PD1       #F by 3 eigen Matrix of the first per face cross field vector
@@ -439,7 +439,7 @@ const char *__doc_igl_cross_field_missmatch = R"igl_Qu8mg5v7(// Inputs:
   //   isCombed  boolean, specifying whether the field is combed (i.e. matching has been precomputed.
   //             If not, the field is combed first.
   // Output:
-  //   Handle_MMatch    #F by 3 eigen Matrix containing the integer missmatch of the cross field
+  //   Handle_MMatch    #F by 3 eigen Matrix containing the integer mismatch of the cross field
   //                    across all face edges
   //)igl_Qu8mg5v7";
 const char *__doc_igl_cut_mesh_from_singularities = R"igl_Qu8mg5v7(// Given a mesh (V,F) and the integer mismatch of a cross field per edge
@@ -618,7 +618,7 @@ const char *__doc_igl_exact_geodesic = R"igl_Qu8mg5v7(
 const char *__doc_igl_find_cross_field_singularities = R"igl_Qu8mg5v7(// Inputs:
   //   V                #V by 3 eigen Matrix of mesh vertex 3D positions
   //   F                #F by 3 eigen Matrix of face (quad) indices
-  //   Handle_MMatch    #F by 3 eigen Matrix containing the integer missmatch of the cross field
+  //   Handle_MMatch    #F by 3 eigen Matrix containing the integer mismatch of the cross field
   //                    across all face edges
   // Output:
   //   isSingularity    #V by 1 boolean eigen Vector indicating the presence of a singularity on a vertex

+ 1 - 1
python/py_doc.h

@@ -33,7 +33,7 @@ extern const char *__doc_igl_copyleft_swept_volume;
 extern const char *__doc_igl_copyleft_tetgen_tetrahedralize;
 extern const char *__doc_igl_cotmatrix;
 extern const char *__doc_igl_covariance_scatter_matrix;
-extern const char *__doc_igl_cross_field_missmatch;
+extern const char *__doc_igl_cross_field_mismatch;
 extern const char *__doc_igl_cut_mesh_from_singularities;
 extern const char *__doc_igl_deform_skeleton;
 extern const char *__doc_igl_directed_edge_orientations;

+ 2 - 2
python/py_igl.cpp

@@ -35,7 +35,7 @@
 #include <igl/compute_frame_field_bisectors.h>
 #include <igl/cotmatrix.h>
 #include <igl/covariance_scatter_matrix.h>
-#include <igl/cross_field_missmatch.h>
+#include <igl/cross_field_mismatch.h>
 #include <igl/cut_mesh_from_singularities.h>
 #include <igl/deform_skeleton.h>
 #include <igl/directed_edge_orientations.h>
@@ -134,7 +134,7 @@ void python_export_igl(py::module &m)
 #include "py_igl/py_compute_frame_field_bisectors.cpp"
 #include "py_igl/py_cotmatrix.cpp"
 #include "py_igl/py_covariance_scatter_matrix.cpp"
-#include "py_igl/py_cross_field_missmatch.cpp"
+#include "py_igl/py_cross_field_mismatch.cpp"
 #include "py_igl/py_cut_mesh_from_singularities.cpp"
 #include "py_igl/py_deform_skeleton.cpp"
 #include "py_igl/py_directed_edge_orientations.cpp"

+ 5 - 5
python/py_igl/py_cross_field_missmatch.cpp → python/py_igl/py_cross_field_mismatch.cpp

@@ -5,16 +5,16 @@
 // 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/.
-m.def("cross_field_missmatch", []
+m.def("cross_field_mismatch", []
 (
   const Eigen::MatrixXd &V,
   const Eigen::MatrixXi &F,
   const Eigen::MatrixXd &PD1,
   const Eigen::MatrixXd &PD2,
   const bool isCombed,
-  Eigen::MatrixXi &missmatch
+  Eigen::MatrixXi &mismatch
 )
 {
-  return igl::cross_field_missmatch(V,F,PD1,PD2,isCombed,missmatch);
-}, __doc_igl_cross_field_missmatch,
-py::arg("V"), py::arg("F"), py::arg("PD1"), py::arg("PD2"), py::arg("isCombed"), py::arg("missmatch"));
+  return igl::cross_field_mismatch(V,F,PD1,PD2,isCombed,mismatch);
+}, __doc_igl_cross_field_mismatch,
+py::arg("V"), py::arg("F"), py::arg("PD1"), py::arg("PD2"), py::arg("isCombed"), py::arg("mismatch"));

+ 1 - 1
python/python_shared.cpp

@@ -87,7 +87,7 @@ PYBIND11_PLUGIN(pyigl) {
            copyleft_tetgen_tetrahedralize
            cotmatrix
            covariance_scatter_matrix
-           cross_field_missmatch
+           cross_field_mismatch
            cut_mesh_from_singularities
            deform_skeleton
            directed_edge_orientations

+ 2 - 2
tests/include/igl/copyleft/comiso/miq.cpp

@@ -5,7 +5,7 @@
 #include <igl/comb_cross_field.h>
 #include <igl/comb_frame_field.h>
 #include <igl/compute_frame_field_bisectors.h>
-#include <igl/cross_field_missmatch.h>
+#include <igl/cross_field_mismatch.h>
 #include <igl/cut_mesh_from_singularities.h>
 #include <igl/find_cross_field_singularities.h>
 #include <igl/local_basis.h>
@@ -91,7 +91,7 @@ igl::compute_frame_field_bisectors(V, F, X1, X2, BIS1, BIS2);
 igl::comb_cross_field(V, F, BIS1, BIS2, BIS1_combed, BIS2_combed);
 
 // Find the integer mismatches
-igl::cross_field_missmatch(V, F, BIS1_combed, BIS2_combed, true, MMatch);
+    igl::cross_field_mismatch(V, F, BIS1_combed, BIS2_combed, true, MMatch);
 
 // Find the singularities
 igl::find_cross_field_singularities(V, F, MMatch, isSingularity, singularityIndex);

+ 2 - 2
tutorial/505_MIQ/main.cpp

@@ -3,7 +3,7 @@
 #include <igl/comb_cross_field.h>
 #include <igl/comb_frame_field.h>
 #include <igl/compute_frame_field_bisectors.h>
-#include <igl/cross_field_missmatch.h>
+#include <igl/cross_field_mismatch.h>
 #include <igl/cut_mesh_from_singularities.h>
 #include <igl/find_cross_field_singularities.h>
 #include <igl/local_basis.h>
@@ -269,7 +269,7 @@ int main(int argc, char *argv[])
     igl::comb_cross_field(V, F, BIS1, BIS2, BIS1_combed, BIS2_combed);
 
     // Find the integer mismatches
-    igl::cross_field_missmatch(V, F, BIS1_combed, BIS2_combed, true, MMatch);
+    igl::cross_field_mismatch(V, F, BIS1_combed, BIS2_combed, true, MMatch);
 
     // Find the singularities
     igl::find_cross_field_singularities(V, F, MMatch, isSingularity, singularityIndex);