flip_avoiding_line_search.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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/igl_inline.h>
  11. #include <Eigen/Dense>
  12. namespace igl
  13. {
  14. // A bisection line search for a mesh based energy that avoids triangle flips as suggested in
  15. // "Bijective Parameterization with Free Boundaries" (Smith J. and Schaefer S., 2015).
  16. //
  17. // The user specifies an initial vertices position (that has no flips) and target one (that my have flipped triangles).
  18. // This method first computes the largest step in direction of the destination vertices that does not incur flips,
  19. // and then minimizes a given energy using this maximal step and a bisection linesearch (see igl::line_search).
  20. //
  21. // Supports both triangle and tet meshes.
  22. //
  23. // Inputs:
  24. // F #F by 3/4 list of mesh faces or tets
  25. // cur_v #V by dim list of variables
  26. // dst_v #V by dim list of target vertices. This mesh may have flipped triangles
  27. // energy A function to compute the mesh-based energy (return an energy that is bigger than 0)
  28. // 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. // Outputs:
  31. // cur_v #V by dim list of variables at the new location
  32. // Returns the energy at the new point
  33. IGL_INLINE double flip_avoiding_line_search(
  34. const Eigen::MatrixXi F,
  35. Eigen::MatrixXd& cur_v,
  36. Eigen::MatrixXd& dst_v,
  37. std::function<double(Eigen::MatrixXd&)> energy,
  38. double cur_energy = -1);
  39. }
  40. #ifndef IGL_STATIC_LIBRARY
  41. # include "flip_avoiding_line_search.cpp"
  42. #endif
  43. #endif