lim.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2014 Christian Schüller <schuellchr@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_LIM_LIM_H
  9. #define IGL_LIM_LIM_H
  10. #include <igl/igl_inline.h>
  11. #include <Eigen/Core>
  12. #include <Eigen/Sparse>
  13. namespace igl
  14. {
  15. namespace lim
  16. {
  17. // Known issues: energy type should be a readable enum rather than magic
  18. // ints.
  19. //
  20. // Computes a locally injective mapping of a triangle or tet-mesh based on
  21. // a deformation energy subject to some provided linear positional
  22. // constraints Cv-d.
  23. //
  24. // Inputs:
  25. // vertices vx3 matrix containing vertex position of the mesh
  26. // initialVertices vx3 matrix containing vertex position of initial
  27. // rest pose mesh
  28. // elements exd matrix containing vertex indices of all elements
  29. // borderVertices (only needed for 2D LSCM) vector containing indices
  30. // of border vertices
  31. // gradients (only needed for 2D Poisson) vector containing
  32. // partial derivatives of target element gradients
  33. // (structure is: [xx_0, xy_0, xx_1, xy_1, ..., xx_v,
  34. // xy_v, yx_0, yy_0, yx_1, yy_1, ..., yx_v, yy_v]')
  35. // constraintMatrix C: (c)x(v*(d-1)) sparse linear positional constraint
  36. // matrix. X an Y-coordinates are alternatingly stacked
  37. // per row (structure for triangles: [x_1, y_1, x_2,
  38. // y_2, ..., x_v,y_v])
  39. // constraintTargets d: c vector target positions
  40. // energyType type of used energy:
  41. // 0=Dirichlet,1=Laplacian,2=Green,3=ARAP,4=LSCM
  42. // tolerance max squared positional constraints error
  43. // maxIteration max number of iterations
  44. // findLocalMinima iterating until a local minima is found. If not
  45. // enabled only tolerance must be fulfilled.
  46. // enableOutput (optional) enables the output (#iteration / hessian correction / step size / positional constraints / barrier constraints / deformation energy) (default : true)
  47. // enableBarriers (optional) enables the non-flip constraints (default = true)
  48. // enableAlphaUpdate (optional) enables dynamic alpha weight adjustment (default = true)
  49. // beta (optional) steepness factor of barrier slopes (default: ARAP/LSCM = 0.01, Green = 1)
  50. // eps (optional) smallest valid triangle area (default: 1e-5 * smallest triangle)
  51. //
  52. // where:
  53. // v : # vertices
  54. // c : # linear constraints
  55. // e : # elements of mesh
  56. // d : # vertices per element (triangle = 3, tet = 4)
  57. //--------------------------------------------------------------------------
  58. // Output:
  59. // vertices vx3 matrix containing resulting vertex position of the
  60. // mesh
  61. //--------------------------------------------------------------------------
  62. // Return values:
  63. // 1 : Optimization deemed successful because either (a) it stagnated
  64. // (very step size) or (b) positional constraints were satisfied. (re:
  65. // https://github.com/libigl/libigl/issues/79 )
  66. // -1 : Max iteration reached before tolerance was fulfilled
  67. // -2 : not feasible -> has inverted elements (may want to decrease eps?)
  68. int lim(
  69. Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
  70. const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
  71. const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
  72. const Eigen::SparseMatrix<double>& constraintMatrix,
  73. const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
  74. int energyType,
  75. double tolerance,
  76. int maxIteration,
  77. bool findLocalMinima);
  78. int lim(
  79. Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
  80. const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
  81. const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
  82. const Eigen::SparseMatrix<double>& constraintMatrix,
  83. const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
  84. int energyType,
  85. double tolerance,
  86. int maxIteration,
  87. bool findLocalMinima,
  88. bool enableOuput,
  89. bool enableBarriers,
  90. bool enableAlphaUpdate,
  91. double beta,
  92. double eps);
  93. int lim(
  94. Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
  95. const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
  96. const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
  97. const std::vector<int>& borderVertices,
  98. const Eigen::Matrix<double,Eigen::Dynamic,1>& gradients,
  99. const Eigen::SparseMatrix<double>& constraintMatrix,
  100. const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
  101. int energyType,
  102. double tolerance,
  103. int maxIteration,
  104. bool findLocalMinima);
  105. int lim(
  106. Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
  107. const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
  108. const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
  109. const std::vector<int>& borderVertices,
  110. const Eigen::Matrix<double,Eigen::Dynamic,1>& gradients,
  111. const Eigen::SparseMatrix<double>& constraintMatrix,
  112. const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
  113. int energyType,
  114. double tolerance,
  115. int maxIteration,
  116. bool findLocalMinima,
  117. bool enableOuput,
  118. bool enableBarriers,
  119. bool enableAlphaUpdate,
  120. double beta,
  121. double eps);
  122. }
  123. }
  124. #ifndef IGL_STATIC_LIBRARY
  125. # include "lim.cpp"
  126. #endif
  127. #endif