flip_avoiding_line_search.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. /// @param[in] F #F by 3/4 list of mesh faces or tets
  25. /// @param[in] cur_v #V by dim list of variables
  26. /// @param[in] dst_v #V by dim list of target vertices. This mesh may have flipped triangles
  27. /// @param[in] energy A function to compute the mesh-based energy (return an energy that is bigger than 0)
  28. /// @param[in] cur_energy(OPTIONAL) The energy at the given point. Helps save redundant computations.
  29. /// This is optional. If not specified, the function will compute it.
  30. /// @param[out] cur_v #V by dim list of variables at the new location
  31. /// @return the energy at the new point
  32. IGL_INLINE double flip_avoiding_line_search(
  33. const Eigen::MatrixXi & F,
  34. Eigen::MatrixXd& cur_v,
  35. const Eigen::MatrixXd& dst_v,
  36. std::function<double(Eigen::MatrixXd&)> & energy,
  37. double cur_energy = -1);
  38. }
  39. #ifndef IGL_STATIC_LIBRARY
  40. # include "flip_avoiding_line_search.cpp"
  41. #endif
  42. #endif