Browse Source

prevent false positive if harmonic fails

Former-commit-id: eebac2b136c4de9a8c679b1b9b4af893715fb77d
Alec Jacobson 8 years ago
parent
commit
eca91659a6
1 changed files with 11 additions and 3 deletions
  1. 11 3
      include/igl/bijective_composite_harmonic_mapping.cpp

+ 11 - 3
include/igl/bijective_composite_harmonic_mapping.cpp

@@ -10,6 +10,7 @@
 #include "slice.h"
 #include "doublearea.h"
 #include "harmonic.h"
+//#include "matlab/MatlabWorkspace.h"
 
 template <
   typename DerivedV,
@@ -42,7 +43,8 @@ IGL_INLINE bool igl::bijective_composite_harmonic_mapping(
     U = V;
     int flipped = 0;
     int nans = 0;
-    for(int step = 0;step<=nsteps;step++)
+    int step = 0;
+    for(;step<=nsteps;step++)
     {
       const Scalar t = ((Scalar)step)/((Scalar)nsteps);
       // linearly interpolate boundary conditions
@@ -56,6 +58,12 @@ IGL_INLINE bool igl::bijective_composite_harmonic_mapping(
       for(int iter = 0;iter<8;iter++)
       {
         //std::cout<<nsteps<<" t: "<<t<<" iter: "<<iter;
+        //igl::matlab::MatlabWorkspace mw;
+        //mw.save(U,"U");
+        //mw.save_index(F,"F");
+        //mw.save_index(b,"b");
+        //mw.save(bct,"bct");
+        //mw.write("numerical.mat");
         harmonic(DerivedU(U),F,b,bct,1,U);
         Eigen::Matrix<Scalar,Eigen::Dynamic,1> A;
         doublearea(U,F,A);
@@ -69,7 +77,7 @@ IGL_INLINE bool igl::bijective_composite_harmonic_mapping(
     }
     if(flipped == 0 && nans == 0)
     {
-      return true;
+      return step == nsteps+1;
     }
     nsteps *= 2;
   }
@@ -77,7 +85,7 @@ IGL_INLINE bool igl::bijective_composite_harmonic_mapping(
 }
 
 #ifdef IGL_STATIC_LIBRARY
-// Explicit template specialization
+// Explicit template instantiation
 // generated by autoexplicit.sh
 template bool igl::bijective_composite_harmonic_mapping<Eigen::Matrix<double, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 1, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> >&);
 #endif