Просмотр исходного кода

Bug fix flip_avoiding_line_search.h (#1968)

* Update flip_avoiding_line_search.h

* pass by reference

* use std::function to match reference type

* fix test
Alec Jacobson 3 лет назад
Родитель
Сommit
e19a68cfa6

+ 2 - 2
include/igl/flip_avoiding_line_search.cpp

@@ -301,10 +301,10 @@ namespace igl
 }
 
 IGL_INLINE double igl::flip_avoiding_line_search(
-  const Eigen::MatrixXi F,
+  const Eigen::MatrixXi & F,
   Eigen::MatrixXd& cur_v,
   const Eigen::MatrixXd& dst_v,
-  std::function<double(Eigen::MatrixXd&)> energy,
+  std::function<double(Eigen::MatrixXd&)> & energy,
   double cur_energy)
 {
   using namespace std;

+ 2 - 2
include/igl/flip_avoiding_line_search.h

@@ -34,10 +34,10 @@ namespace igl
   //		cur_v  						#V by dim list of variables at the new location
   // Returns the energy at the new point
   IGL_INLINE double flip_avoiding_line_search(
-    const Eigen::MatrixXi F,
+    const Eigen::MatrixXi & F,
     Eigen::MatrixXd& cur_v,
     const Eigen::MatrixXd& dst_v,
-    std::function<double(Eigen::MatrixXd&)> energy,
+    std::function<double(Eigen::MatrixXd&)> & energy,
     double cur_energy = -1);
 
 }

+ 3 - 4
include/igl/triangle/scaf.cpp

@@ -605,16 +605,15 @@ IGL_INLINE double perform_iteration(SCAFData &s)
   igl::slim_update_weights_and_closest_rotations_with_jacobians(s.Ji_m, s.slim_energy, 0, s.W_m, s.Ri_m);
   igl::slim_update_weights_and_closest_rotations_with_jacobians(s.Ji_s, s.scaf_energy, 0, s.W_s, s.Ri_s);
   solve_weighted_arap(s, V_out);
-  auto whole_E = [&s](Eigen::MatrixXd &uv) { return compute_energy(s, uv, true); };
+  std::function<double(Eigen::MatrixXd&)> whole_E = [&s](Eigen::MatrixXd &uv) { return compute_energy(s, uv, true); };
 
   Eigen::MatrixXi w_T;
   if (s.m_T.cols() == s.s_T.cols())
     igl::cat(1, s.m_T, s.s_T, w_T);
   else
     w_T = s.s_T;
-  return igl::flip_avoiding_line_search(w_T, s.w_uv, V_out,
-                                        whole_E, -1) /
-         s.mesh_measure;
+  return igl::flip_avoiding_line_search( w_T, s.w_uv, V_out, whole_E, -1) /
+    s.mesh_measure;
 }
 
 }

+ 2 - 1
tests/include/igl/triangle/scaf.cpp

@@ -69,7 +69,8 @@ TEST_CASE("scaf_system: Test scaf_system() vs scaf_solve()", "[igl]")
       }
 
       // Line search
-      auto E = [&s_test](Eigen::MatrixXd &uv) { return igl::triangle::scaf::compute_energy(s_test, uv, true); };
+      std::function<double(Eigen::MatrixXd&)> E = 
+        [&s_test](Eigen::MatrixXd &uv) { return igl::triangle::scaf::compute_energy(s_test, uv, true); };
       Eigen::MatrixXi w_T;
       igl::cat(1, s_test.m_T, s_test.s_T, w_T);
       igl::flip_avoiding_line_search(w_T, s_test.w_uv, uv_target, E, -1);