flip_avoiding_line_search.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 Michael Rabinovich
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_FLIP_AVOIDING_LINE_SEARCH_H
  9. #define IGL_FLIP_AVOIDING_LINE_SEARCH_H
  10. #include "igl_inline.h"
  11. #include "PI.h"
  12. #include <Eigen/Dense>
  13. namespace igl
  14. {
  15. // A bisection line search for a mesh based energy that avoids triangle flips as suggested in
  16. // "Bijective Parameterization with Free Boundaries" (Smith J. and Schaefer S., 2015).
  17. //
  18. // The user specifies an initial vertices position (that has no flips) and target one (that my have flipped triangles).
  19. // This method first computes the largest step in direction of the destination vertices that does not incur flips,
  20. // and then minimizes a given energy using this maximal step and a bisection linesearch (see igl::line_search).
  21. //
  22. // Supports both triangle and tet meshes.
  23. //
  24. // Inputs:
  25. // F #F by 3/4 list of mesh faces or tets
  26. // cur_v #V by dim list of variables
  27. // dst_v #V by dim list of target vertices. This mesh may have flipped triangles
  28. // energy A function to compute the mesh-based energy (return an energy that is bigger than 0)
  29. // cur_energy(OPTIONAL) The energy at the given point. Helps save redundant computations.
  30. // This is optional. If not specified, the function will compute it.
  31. // Outputs:
  32. // cur_v #V by dim list of variables at the new location
  33. // Returns the energy at the new point
  34. IGL_INLINE double flip_avoiding_line_search(
  35. const Eigen::MatrixXi F,
  36. Eigen::MatrixXd& cur_v,
  37. Eigen::MatrixXd& dst_v,
  38. std::function<double(Eigen::MatrixXd&)> energy,
  39. double cur_energy = -1);
  40. }
  41. #ifndef IGL_STATIC_LIBRARY
  42. # include "flip_avoiding_line_search.cpp"
  43. #endif
  44. #endif