slim.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 Michael Rabinovich
  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 SLIM_H
  9. #define SLIM_H
  10. #include <Eigen/Dense>
  11. #include <Eigen/Sparse>
  12. #include "igl_inline.h"
  13. class WeightedGlobalLocal;
  14. namespace igl
  15. {
  16. // Compute a SLIM map as derived in "Scalable Locally Injective Maps" [Rabinovich et al. 2016].
  17. struct SLIMData {
  18. // Input
  19. Eigen::MatrixXd V; // #V by 3 list of mesh vertex positions
  20. Eigen::MatrixXi F; // #F by 3/3 list of mesh faces (triangles/tets)
  21. enum SLIM_ENERGY {
  22. ARAP,
  23. LOG_ARAP,
  24. SYMMETRIC_DIRICHLET,
  25. CONFORMAL,
  26. EXP_CONFORMAL,
  27. EXP_SYMMETRIC_DIRICHLET
  28. };
  29. SLIM_ENERGY slim_energy;
  30. // Optional Input
  31. // soft constraints
  32. Eigen::VectorXi b;
  33. Eigen::MatrixXd bc;
  34. double soft_const_p;
  35. double exp_factor; // used for exponential energies, ignored otherwise
  36. bool mesh_improvement_3d; // only supported for 3d
  37. // Output
  38. Eigen::MatrixXd V_o; // #V by dim list of mesh vertex positions (dim = 2 for parametrization, 3 otherwise)
  39. double energy; // objective value
  40. // INTERNAL
  41. Eigen::VectorXd M;
  42. double mesh_area;
  43. double avg_edge_length;
  44. int v_num;
  45. int f_num;
  46. double proximal_p;
  47. Eigen::VectorXd WGL_M;
  48. Eigen::VectorXd rhs;
  49. Eigen::MatrixXd Ri,Ji;
  50. Eigen::VectorXd W_11; Eigen::VectorXd W_12; Eigen::VectorXd W_13;
  51. Eigen::VectorXd W_21; Eigen::VectorXd W_22; Eigen::VectorXd W_23;
  52. Eigen::VectorXd W_31; Eigen::VectorXd W_32; Eigen::VectorXd W_33;
  53. Eigen::SparseMatrix<double> Dx,Dy,Dz;
  54. int f_n,v_n;
  55. bool first_solve;
  56. bool has_pre_calc = false;
  57. int dim;
  58. };
  59. // Compute necessary information to start using SLIM
  60. // Inputs:
  61. // V #V by 3 list of mesh vertex positions
  62. // F #F by 3/3 list of mesh faces (triangles/tets)
  63. // b list of boundary indices into V
  64. // bc #b by dim list of boundary conditions
  65. // soft_p Soft penalty factor (can be zero)
  66. // slim_energy Energy to minimize
  67. IGL_INLINE void slim_precompute(Eigen::MatrixXd& V, Eigen::MatrixXi& F, Eigen::MatrixXd& V_init, SLIMData& data,
  68. SLIMData::SLIM_ENERGY slim_energy, Eigen::VectorXi& b, Eigen::MatrixXd& bc, double soft_p);
  69. // Run iter_num iterations of SLIM
  70. // Outputs:
  71. // V_o (in SLIMData): #V by dim list of mesh vertex positions
  72. IGL_INLINE Eigen::MatrixXd slim_solve(SLIMData& data, int iter_num);
  73. }
  74. #ifndef IGL_STATIC_LIBRARY
  75. # include "slim.cpp"
  76. #endif
  77. #endif // SLIM_H