slim.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 <string>
  13. #include <igl/jet.h>
  14. #include <igl/readOBJ.h>
  15. #include <igl/facet_components.h>
  16. #include <igl/slice.h>
  17. class WeightedGlobalLocal;
  18. namespace igl
  19. {
  20. // Compute a SLIM map as derived in "Scalable Locally Injective Maps" [Rabinovich et al. 2016].
  21. struct SLIMData {
  22. // Input
  23. Eigen::MatrixXd V; // #V by 3 list of mesh vertex positions
  24. Eigen::MatrixXi F; // #F by 3/3 list of mesh faces (triangles/tets)
  25. enum SLIM_ENERGY {
  26. ARAP,
  27. LOG_ARAP,
  28. SYMMETRIC_DIRICHLET,
  29. CONFORMAL,
  30. EXP_CONFORMAL,
  31. EXP_SYMMETRIC_DIRICHLET
  32. };
  33. SLIM_ENERGY slim_energy;
  34. // Optional Input
  35. // soft constraints
  36. Eigen::VectorXi b;
  37. Eigen::MatrixXd bc;
  38. double soft_const_p;
  39. double exp_factor; // used for exponential energies, ignored otherwise
  40. bool mesh_improvement_3d; // only supported for 3d
  41. // Output
  42. Eigen::MatrixXd V_o; // #V by dim list of mesh vertex positions (dim = 2 for parametrization, 3 otherwise)
  43. double energy; // objective value
  44. // INTERNAL
  45. Eigen::VectorXd M;
  46. double mesh_area;
  47. double avg_edge_length;
  48. int v_num;
  49. int f_num;
  50. double proximal_p;
  51. WeightedGlobalLocal* wGlobalLocal;
  52. };
  53. // Compute necessary information to start using SLIM
  54. // Inputs:
  55. // V #V by 3 list of mesh vertex positions
  56. // F #F by 3/3 list of mesh faces (triangles/tets)
  57. // b list of boundary indices into V
  58. // bc #b by dim list of boundary conditions
  59. // soft_p Soft penalty factor (can be zero)
  60. // slim_energy Energy to minimize
  61. IGL_INLINE void slim_precompute(Eigen::MatrixXd& V, Eigen::MatrixXi& F, Eigen::MatrixXd& V_init, SLIMData& data,
  62. SLIMData::SLIM_ENERGY slim_energy, Eigen::VectorXi& b, Eigen::MatrixXd& bc, double soft_p);
  63. // Run iter_num iterations of SLIM
  64. // Outputs:
  65. // V_o (in SLIMData): #V by dim list of mesh vertex positions
  66. IGL_INLINE void slim_solve(SLIMData& data, int iter_num);
  67. }
  68. #ifndef IGL_STATIC_LIBRARY
  69. # include "slim.cpp"
  70. #endif
  71. #endif // SLIM_H