bijective_composite_harmonic_mapping.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2017 Alec Jacobson <[email protected]>
  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_BIJECTIVE_COMPOSITE_HARMONIC_MAPPING_H
  9. #define IGL_BIJECTIVE_COMPOSITE_HARMONIC_MAPPING_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. /// Compute a injective planar mapping of a triangulated polygon (V,F) subjected to
  15. /// boundary conditions (b,bc). The mapping should be bijective in the sense
  16. /// that no triangles' areas become negative (this assumes they started
  17. /// positive). This mapping is computed by "composing" harmonic mappings
  18. /// between incremental morphs of the boundary conditions. This is a bit like
  19. /// a discrete version of "Bijective Composite Mean Value Mappings" [Schneider
  20. /// et al. 2013] but with a discrete harmonic map (cf. harmonic coordinates)
  21. /// instead of mean value coordinates. This is inspired by "Embedding a
  22. /// triangular graph within a given boundary" [Xu et al. 2011].
  23. ///
  24. /// @param[in] V #V by 2 list of triangle mesh vertex positions
  25. /// @param[in] F #F by 3 list of triangle indices into V
  26. /// @param[in] b #b list of boundary indices into V
  27. /// @param[in] bc #b by 2 list of boundary conditions corresponding to b
  28. /// @param[out] U #V by 2 list of output mesh vertex locations
  29. /// @return true if and only if U contains a successful bijectie mapping
  30. ///
  31. ///
  32. template <
  33. typename DerivedV,
  34. typename DerivedF,
  35. typename Derivedb,
  36. typename Derivedbc,
  37. typename DerivedU>
  38. IGL_INLINE bool bijective_composite_harmonic_mapping(
  39. const Eigen::MatrixBase<DerivedV> & V,
  40. const Eigen::MatrixBase<DerivedF> & F,
  41. const Eigen::MatrixBase<Derivedb> & b,
  42. const Eigen::MatrixBase<Derivedbc> & bc,
  43. Eigen::PlainObjectBase<DerivedU> & U);
  44. /// \overload
  45. /// @param[in] min_steps minimum number of steps to take from V(b,:) to bc
  46. /// @param[in] max_steps minimum number of steps to take from V(b,:) to bc (if
  47. /// max_steps == min_steps then no further number of steps will be tried)
  48. /// @param[in] num_inner_iters number of iterations of harmonic solves to run after
  49. /// for each morph step (to try to push flips back in)
  50. /// @param[in] test_for_flips whether to check if flips occurred (and trigger more
  51. /// steps). if test_for_flips = false then this function always returns
  52. /// true
  53. template <
  54. typename DerivedV,
  55. typename DerivedF,
  56. typename Derivedb,
  57. typename Derivedbc,
  58. typename DerivedU>
  59. IGL_INLINE bool bijective_composite_harmonic_mapping(
  60. const Eigen::MatrixBase<DerivedV> & V,
  61. const Eigen::MatrixBase<DerivedF> & F,
  62. const Eigen::MatrixBase<Derivedb> & b,
  63. const Eigen::MatrixBase<Derivedbc> & bc,
  64. const int min_steps,
  65. const int max_steps,
  66. const int num_inner_iters,
  67. const bool test_for_flips,
  68. Eigen::PlainObjectBase<DerivedU> & U);
  69. }
  70. #ifndef IGL_STATIC_LIBRARY
  71. # include "bijective_composite_harmonic_mapping.cpp"
  72. #endif
  73. #endif