arap.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@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_ARAP_H
  9. #define IGL_ARAP_H
  10. #include <igl/igl_inline.h>
  11. #include <igl/min_quad_with_fixed.h>
  12. #include <igl/ARAPEnergyType.h>
  13. #include <Eigen/Core>
  14. #include <Eigen/Sparse>
  15. namespace igl
  16. {
  17. struct ARAPData
  18. {
  19. // n #V
  20. // G #V list of group indices (1 to k) for each vertex, such that vertex i
  21. // is assigned to group G(i)
  22. // energy type of energy to use
  23. // with_dynamics whether using dynamics
  24. // f_ext #V by dim list of external forces
  25. // h dynamics time step
  26. // max_iter maximum inner iterations
  27. // K rhs pre-multiplier
  28. // solver_data quadratic solver data
  29. // b list of boundary indices into V
  30. int n;
  31. Eigen::VectorXi G;
  32. ARAPEnergyType energy;
  33. bool with_dynamics;
  34. Eigen::MatrixXd f_ext;
  35. double h;
  36. int max_iter;
  37. Eigen::SparseMatrix<double> K;
  38. Eigen::SparseMatrix<double> CSM;
  39. min_quad_with_fixed_data<double> solver_data;
  40. Eigen::VectorXi b;
  41. ARAPData():
  42. n(0),
  43. G(),
  44. energy(ARAP_ENERGY_TYPE_DEFAULT),
  45. with_dynamics(false),
  46. f_ext(),
  47. h(1),
  48. max_iter(10),
  49. K(),
  50. CSM(),
  51. solver_data(),
  52. b()
  53. {
  54. };
  55. };
  56. // Compute necessary information to start using an ARAP deformation
  57. //
  58. // Inputs:
  59. // V #V by dim list of mesh positions
  60. // F #F by simplex-size list of triangle|tet indices into V
  61. // b #b list of "boundary" fixed vertex indices into V
  62. // Outputs:
  63. // data struct containing necessary precomputation
  64. template <
  65. typename DerivedV,
  66. typename DerivedF,
  67. typename Derivedb>
  68. IGL_INLINE bool arap_precomputation(
  69. const Eigen::PlainObjectBase<DerivedV> & V,
  70. const Eigen::PlainObjectBase<DerivedF> & F,
  71. const Eigen::PlainObjectBase<Derivedb> & b,
  72. ARAPData & data);
  73. template <
  74. typename Derivedbc,
  75. typename DerivedU>
  76. IGL_INLINE bool arap_solve(
  77. const Eigen::PlainObjectBase<Derivedbc> & bc,
  78. ARAPData & data,
  79. Eigen::PlainObjectBase<DerivedU> & U);
  80. };
  81. #ifdef IGL_HEADER_ONLY
  82. #include "arap.cpp"
  83. #endif
  84. #endif