lscm.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2014 Daniele Panozzo <[email protected]>
  4. // 2015 Alec Jacobson
  5. //
  6. // This Source Code Form is subject to the terms of the Mozilla Public License
  7. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  8. // obtain one at http://mozilla.org/MPL/2.0/.
  9. #ifndef IGL_LSCM_H
  10. #define IGL_LSCM_H
  11. #include "igl_inline.h"
  12. #include <Eigen/Dense>
  13. #include <Eigen/Sparse>
  14. namespace igl
  15. {
  16. /// Compute a Least-squares conformal map parametrization (equivalently
  17. /// derived in "Intrinsic Parameterizations of Surface Meshes" [Desbrun et al.
  18. /// 2002] and "Least Squares Conformal Maps for Automatic Texture Atlas
  19. /// Generation" [Lévy et al. 2002]), though this implementation follows the
  20. /// derivation in: "Spectral Conformal Parameterization" [Mullen et al. 2008]
  21. /// (note, this does **not** implement the Eigen-decomposition based method in
  22. /// [Mullen et al. 2008], see below). Input should be a manifold
  23. /// mesh (also no unreferenced vertices) and "boundary" (fixed vertices) `b`
  24. /// should contain at least two vertices per connected component.
  25. ///
  26. /// @param[in] V #V by 3 list of mesh vertex positions
  27. /// @param[in] F #F by 3 list of mesh faces (must be triangles)
  28. /// @param[in] b #b boundary indices into V
  29. /// @param[in] bc #b by 2 list of boundary values
  30. /// @param[out] UV #V by 2 list of 2D mesh vertex positions in UV space
  31. /// @param[out] Q #Vx2 by #Vx2 symmetric positive semi-definite matrix for computing LSCM energy
  32. /// @return true only on solver success.
  33. template <
  34. typename DerivedV,
  35. typename DerivedF,
  36. typename Derivedb,
  37. typename Derivedbc,
  38. typename DerivedV_uv,
  39. typename QScalar>
  40. IGL_INLINE bool lscm(
  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<DerivedV_uv> & V_uv,
  46. Eigen::SparseMatrix<QScalar> & Q);
  47. /// \overload
  48. template <
  49. typename DerivedV,
  50. typename DerivedF,
  51. typename Derivedb,
  52. typename Derivedbc,
  53. typename DerivedV_uv>
  54. IGL_INLINE bool lscm(
  55. const Eigen::MatrixBase<DerivedV> & V,
  56. const Eigen::MatrixBase<DerivedF> & F,
  57. const Eigen::MatrixBase<Derivedb> & b,
  58. const Eigen::MatrixBase<Derivedbc> & bc,
  59. Eigen::PlainObjectBase<DerivedV_uv> & V_uv);
  60. /// \overload
  61. ///
  62. /// \brief Free boundary version. "Spectral Conformal Parameterization" using eigen
  63. /// decomposition; Assumes mesh is a single connected component topologically
  64. /// equivalent to a chunk of the plane.
  65. template <
  66. typename DerivedV,
  67. typename DerivedF,
  68. typename DerivedV_uv>
  69. IGL_INLINE bool lscm(
  70. const Eigen::MatrixBase<DerivedV> & V,
  71. const Eigen::MatrixBase<DerivedF> & F,
  72. Eigen::PlainObjectBase<DerivedV_uv> & V_uv);
  73. }
  74. #ifndef IGL_STATIC_LIBRARY
  75. # include "lscm.cpp"
  76. #endif
  77. #endif