lim.h 5.2 KB

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