bijective_composite_harmonic_mapping.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2017 Alec Jacobson <alecjacobson@gmail.com>
  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 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. // Inputs:
  25. // V #V by 2 list of triangle mesh vertex positions
  26. // F #F by 3 list of triangle indices into V
  27. // b #b list of boundary indices into V
  28. // bc #b by 2 list of boundary conditions corresponding to b
  29. // Outputs:
  30. // U #V by 2 list of output mesh vertex locations
  31. // Returns true if and only if U contains a successful bijectie mapping
  32. //
  33. //
  34. template <
  35. typename DerivedV,
  36. typename DerivedF,
  37. typename Derivedb,
  38. typename Derivedbc,
  39. typename DerivedU>
  40. IGL_INLINE bool bijective_composite_harmonic_mapping(
  41. const Eigen::MatrixBase<DerivedV> & V,
  42. const Eigen::MatrixBase<DerivedF> & F,
  43. const Eigen::MatrixBase<Derivedb> & b,
  44. const Eigen::MatrixBase<Derivedbc> & bc,
  45. Eigen::PlainObjectBase<DerivedU> & U);
  46. //
  47. // Inputs:
  48. // min_steps minimum number of steps to take from V(b,:) to bc
  49. // max_steps minimum number of steps to take from V(b,:) to bc (if
  50. // max_steps == min_steps then no further number of steps will be tried)
  51. // num_inner_iters number of iterations of harmonic solves to run after
  52. // for each morph step (to try to push flips back in)
  53. // test_for_flips whether to check if flips occurred (and trigger more
  54. // steps). if test_for_flips = false then this function always returns
  55. // true
  56. //
  57. template <
  58. typename DerivedV,
  59. typename DerivedF,
  60. typename Derivedb,
  61. typename Derivedbc,
  62. typename DerivedU>
  63. IGL_INLINE bool bijective_composite_harmonic_mapping(
  64. const Eigen::MatrixBase<DerivedV> & V,
  65. const Eigen::MatrixBase<DerivedF> & F,
  66. const Eigen::MatrixBase<Derivedb> & b,
  67. const Eigen::MatrixBase<Derivedbc> & bc,
  68. const int min_steps,
  69. const int max_steps,
  70. const int num_inner_iters,
  71. const bool test_for_flips,
  72. Eigen::PlainObjectBase<DerivedU> & U);
  73. }
  74. #ifndef IGL_STATIC_LIBRARY
  75. # include "bijective_composite_harmonic_mapping.cpp"
  76. #endif
  77. #endif