compute_lim.h 5.1 KB

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