bbw.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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_BBW_BBW_H
  9. #define IGL_BBW_BBW_H
  10. #include "../igl_inline.h"
  11. #include <Eigen/Dense>
  12. #ifndef IGL_NO_MOSEK
  13. # include <igl/mosek/mosek_quadprog.h>
  14. #endif
  15. #include <igl/active_set.h>
  16. namespace igl
  17. {
  18. namespace bbw
  19. {
  20. enum QPSolver
  21. {
  22. QP_SOLVER_IGL_ACTIVE_SET = 0,
  23. QP_SOLVER_MOSEK = 1,
  24. NUM_QP_SOLVERS = 2
  25. };
  26. const char * const QPSolverNames[NUM_QP_SOLVERS] =
  27. {
  28. "QP_SOLVER_IGL_ACTIVE_SET",
  29. "QP_SOLVER_MOSEK"
  30. };
  31. // Container for BBW computation related data and flags
  32. class BBWData
  33. {
  34. public:
  35. // Enforce partition of unity during optimization (optimize all weight
  36. // simultaneously)
  37. bool partition_unity;
  38. // Initial guess
  39. Eigen::MatrixXd W0;
  40. #ifndef IGL_NO_MOSEK
  41. igl::mosek::MosekData mosek_data;
  42. #endif
  43. igl::active_set_params active_set_params;
  44. // Which solver
  45. QPSolver qp_solver;
  46. // Verbosity level
  47. // 0: quiet
  48. // 1: loud
  49. // 2: louder
  50. int verbosity;
  51. public:
  52. inline BBWData():
  53. partition_unity(false),
  54. W0(),
  55. #ifndef IGL_NO_MOSEK
  56. mosek_data(),
  57. #endif
  58. active_set_params(),
  59. qp_solver(QP_SOLVER_IGL_ACTIVE_SET),
  60. verbosity(0)
  61. {
  62. // We know that the Bilaplacian is positive semi-definite
  63. active_set_params.Auu_pd = true;
  64. }
  65. // Print current state of object
  66. inline void print();
  67. };
  68. // Compute Bounded Biharmonic Weights on a given domain (V,Ele) with a given
  69. // set of boundary conditions
  70. //
  71. // Templates
  72. // DerivedV derived type of eigen matrix for V (e.g. MatrixXd)
  73. // DerivedF derived type of eigen matrix for F (e.g. MatrixXi)
  74. // Derivedb derived type of eigen matrix for b (e.g. VectorXi)
  75. // Derivedbc derived type of eigen matrix for bc (e.g. MatrixXd)
  76. // DerivedW derived type of eigen matrix for W (e.g. MatrixXd)
  77. // Inputs:
  78. // V #V by dim vertex positions
  79. // Ele #Elements by simplex-size list of element indices
  80. // b #b boundary indices into V
  81. // bc #b by #W list of boundary values
  82. // data object containing options, intial guess --> solution and results
  83. // Outputs:
  84. // W #V by #W list of *unnormalized* weights to normalize use
  85. // igl::normalize_row_sums(W,W);
  86. // Returns true on success, false on failure
  87. template <
  88. typename DerivedV,
  89. typename DerivedEle,
  90. typename Derivedb,
  91. typename Derivedbc,
  92. typename DerivedW>
  93. IGL_INLINE bool bbw(
  94. const Eigen::PlainObjectBase<DerivedV> & V,
  95. const Eigen::PlainObjectBase<DerivedEle> & Ele,
  96. const Eigen::PlainObjectBase<Derivedb> & b,
  97. const Eigen::PlainObjectBase<Derivedbc> & bc,
  98. BBWData & data,
  99. Eigen::PlainObjectBase<DerivedW> & W);
  100. }
  101. }
  102. #ifndef IGL_STATIC_LIBRARY
  103. # include "bbw.cpp"
  104. #endif
  105. #endif