compute_lim.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. // Computes a locally injective mapping of a triangle or tet-mesh based on a deformation energy
  16. // subject to some provided linear positional constraints Cv-d.
  17. //
  18. // Inputs:
  19. // vertices vx3 matrix containing vertex position of the mesh
  20. // initialVertices vx3 matrix containing vertex position of initial rest pose mesh
  21. // elements exd matrix containing vertex indices of all elements
  22. // borderVertices (only needed for 2D LSCM) vector containing indices of border vertices
  23. // 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]')
  24. // 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])
  25. // constraintTargets d: c vector target positions
  26. // energyType type of used energy: 0=Dirichlet,1=Laplacian,2=Green,3=ARAP,4=LSCM
  27. // tolerance max squared positional constraints error
  28. // maxIteration max number of iterations
  29. // findLocalMinima iterating until a local minima is found. If not enabled only tolerance must be fulfilled.
  30. // enableOutput (optional) enables the output (#itaration / hessian correction / step size / positional constraints / barrier constraints / deformation energy) (default : true)
  31. // enableBarriers (optional) enables the non-flip constraints (default = true)
  32. // enableAlphaUpdate (optional) enables dynamic alpha weight adjustment (default = true)
  33. // beta (optional) steepness factor of barrier slopes (default: ARAP/LSCM = 0.01, Green = 1)
  34. // eps (optional) smallest valid triangle area (default: 1e-5 * smallest triangle)
  35. //
  36. // where:
  37. // v : # vertices
  38. // c : # linear constraints
  39. // e : # elements of mesh
  40. // d : # vertices per element (triangle = 3, tet = 4)
  41. //----------------------------------------------------------------------------------------
  42. // Output:
  43. // vertices vx3 matrix containing resulting vertex position of the mesh
  44. //----------------------------------------------------------------------------------------
  45. // Return values:
  46. // 1 : Successful optimization with fulfilled tolerance
  47. // -1 : Max iteration reached before tolerance was fulfilled
  48. // -2 : not feasible -> has inverted elements (may want to decrease eps?)
  49. int compute_lim(
  50. Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
  51. const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
  52. const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
  53. const Eigen::SparseMatrix<double>& constraintMatrix,
  54. const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
  55. int energyType,
  56. double tolerance,
  57. int maxIteration,
  58. bool findLocalMinima);
  59. int compute_lim(
  60. Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
  61. const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
  62. const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
  63. const Eigen::SparseMatrix<double>& constraintMatrix,
  64. const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
  65. int energyType,
  66. double tolerance,
  67. int maxIteration,
  68. bool findLocalMinima,
  69. bool enableOuput,
  70. bool enableBarriers,
  71. bool enableAlphaUpdate,
  72. double beta,
  73. double eps);
  74. int compute_lim(
  75. Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
  76. const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
  77. const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
  78. const std::vector<int>& borderVertices,
  79. const Eigen::Matrix<double,Eigen::Dynamic,1>& gradients,
  80. const Eigen::SparseMatrix<double>& constraintMatrix,
  81. const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
  82. int energyType,
  83. double tolerance,
  84. int maxIteration,
  85. bool findLocalMinima);
  86. int compute_lim(
  87. Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
  88. const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
  89. const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
  90. const std::vector<int>& borderVertices,
  91. const Eigen::Matrix<double,Eigen::Dynamic,1>& gradients,
  92. const Eigen::SparseMatrix<double>& constraintMatrix,
  93. const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
  94. int energyType,
  95. double tolerance,
  96. int maxIteration,
  97. bool findLocalMinima,
  98. bool enableOuput,
  99. bool enableBarriers,
  100. bool enableAlphaUpdate,
  101. double beta,
  102. double eps);
  103. }
  104. #ifndef IGL_STATIC_LIBRARY
  105. # include "compute_lim.cpp"
  106. #endif
  107. #endif