miq.h 5.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef IGL_MIQ_H
  2. #define IGL_MIQ_H
  3. #include <igl/igl_inline.h>
  4. #include <Eigen/Core>
  5. #include <vector>
  6. namespace igl
  7. {
  8. // Global seamless parametrization aligned with a given per-face jacobian (PD1,PD2).
  9. // The algorithm is based on
  10. // "Mixed-Integer Quadrangulation" by D. Bommes, H. Zimmer, L. Kobbelt
  11. // ACM SIGGRAPH 2009, Article No. 77 (http://dl.acm.org/citation.cfm?id=1531383)
  12. // Inputs:
  13. // V #V by 3 list of mesh vertex 3D positions
  14. // F #F by 3 list of faces indices in V
  15. // PD1 #V by 3 first line of the Jacobian per triangle
  16. // PD2 #V by 3 second line of the Jacobian per triangle
  17. // (optional, if empty it will be a vector in the tangent plane orthogonal to PD1)
  18. // scale global scaling for the gradient (controls the quads resolution)
  19. // stiffness weight for the stiffness iterations
  20. // direct_round greedily round all integer variables at once (greatly improves optimization speed but lowers quality)
  21. // iter stiffness iterations (0 = no stiffness)
  22. // local_iter number of local iterations for the integer rounding
  23. // do_round enables the integer rounding (disabling it could be useful for debugging)
  24. // round_vertices id of additional vertices that should be snapped to integer coordinates
  25. // hard_features #H by 2 list of pairs of vertices that belongs to edges that should be snapped to integer coordinates
  26. //
  27. // Output:
  28. // UV #UV by 2 list of vertices in 2D
  29. // FUV #FUV by 3 list of face indices in UV
  30. //
  31. // TODO: rename the parameters name in the cpp consistenly
  32. // improve the handling of hard_features, right now it might fail in difficult cases
  33. template <typename DerivedV, typename DerivedF, typename DerivedU>
  34. IGL_INLINE void miq(const Eigen::PlainObjectBase<DerivedV> &V,
  35. const Eigen::PlainObjectBase<DerivedF> &F,
  36. const Eigen::PlainObjectBase<DerivedV> &PD1,
  37. const Eigen::PlainObjectBase<DerivedV> &PD2,
  38. Eigen::PlainObjectBase<DerivedU> &UV,
  39. Eigen::PlainObjectBase<DerivedF> &FUV,
  40. double scale = 30.0,
  41. double stiffness = 5.0,
  42. bool direct_round = false,
  43. int iter = 5,
  44. int local_iter = 5,
  45. bool DoRound = true,
  46. std::vector<int> round_vertices = std::vector<int>(),
  47. std::vector<std::vector<int> > hard_features = std::vector<std::vector<int> >());
  48. // Helper function that allows to directly provided pre-combed bisectors for an already cut mesh
  49. // Additional input:
  50. // PD1_combed, PD2_combed : #F by 3 combed jacobian
  51. // BIS1_combed, BIS2_combed: #F by 3 pre combed bi-sectors
  52. // MMatch: #F by 3 list of per-corner integer PI/2 rotations
  53. // Singular: #V list of flag that denotes if a vertex is singular or not
  54. // SingularDegree: #V list of flag that denotes the degree of the singularity
  55. // Seams: #F by 3 list of per-corner flag that denotes seams
  56. template <typename DerivedV, typename DerivedF, typename DerivedU>
  57. IGL_INLINE void miq(const Eigen::PlainObjectBase<DerivedV> &V,
  58. const Eigen::PlainObjectBase<DerivedF> &F,
  59. const Eigen::PlainObjectBase<DerivedV> &PD1_combed,
  60. const Eigen::PlainObjectBase<DerivedV> &PD2_combed,
  61. const Eigen::PlainObjectBase<DerivedV> &BIS1_combed,
  62. const Eigen::PlainObjectBase<DerivedV> &BIS2_combed,
  63. const Eigen::Matrix<int, Eigen::Dynamic, 3> &MMatch,
  64. const Eigen::Matrix<int, Eigen::Dynamic, 1> &Singular,
  65. const Eigen::Matrix<int, Eigen::Dynamic, 1> &SingularDegree,
  66. const Eigen::Matrix<int, Eigen::Dynamic, 3> &Seams,
  67. Eigen::PlainObjectBase<DerivedU> &UV,
  68. Eigen::PlainObjectBase<DerivedF> &FUV,
  69. double GradientSize = 30.0,
  70. double Stiffness = 5.0,
  71. bool DirectRound = false,
  72. int iter = 5,
  73. int localIter = 5, bool DoRound = true,
  74. std::vector<int> roundVertices = std::vector<int>(),
  75. std::vector<std::vector<int> > hardFeatures = std::vector<std::vector<int> >());
  76. };
  77. #ifdef IGL_HEADER_ONLY
  78. #include "miq.cpp"
  79. #endif
  80. #endif