compute_lim.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. // enableAlphaUpdate (optional) enables dynamic alpha weight adjustment (default = true)
  31. // beta (optional) steepness factor of barrier slopes (default: ARAP/LSCM = 0.01, Green = 1)
  32. // eps (optional) smallest valid triangle area (default: 1e-5 * smallest triangle)
  33. //
  34. // where:
  35. // v : # vertices
  36. // c : # linear constraints
  37. // e : # elements of mesh
  38. // d : # vertices per element (triangle = 3, tet = 4)
  39. //----------------------------------------------------------------------------------------
  40. // Output:
  41. // vertices vx3 matrix containing resulting vertex position of the mesh
  42. //----------------------------------------------------------------------------------------
  43. // Return values:
  44. // 1 : Successful optimization with fulfilled tolerance
  45. // -1 : Max iteration reached before tolerance was fulfilled
  46. // -2 : not feasible -> has inverted elements (may want to decrease eps?)
  47. int compute_lim(
  48. Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
  49. const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
  50. const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
  51. const std::vector<int>& borderVertices,
  52. const Eigen::Matrix<double,Eigen::Dynamic,1>& gradients,
  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 std::vector<int>& borderVertices,
  64. const Eigen::Matrix<double,Eigen::Dynamic,1>& gradients,
  65. const Eigen::SparseMatrix<double>& constraintMatrix,
  66. const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
  67. int energyType,
  68. double tolerance,
  69. int maxIteration,
  70. bool findLocalMinima,
  71. bool enableOuput,
  72. bool enableAlphaUpdate,
  73. double beta,
  74. double eps);
  75. }
  76. #ifndef IGL_STATIC_LIBRARY
  77. # include "compute_lim.cpp"
  78. #endif
  79. #endif