bbw.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. IGL_INLINE BBWData();
  53. // Print current state of object
  54. IGL_INLINE void print();
  55. };
  56. // Compute Bounded Biharmonic Weights on a given domain (V,Ele) with a given
  57. // set of boundary conditions
  58. //
  59. // Templates
  60. // DerivedV derived type of eigen matrix for V (e.g. MatrixXd)
  61. // DerivedF derived type of eigen matrix for F (e.g. MatrixXi)
  62. // Derivedb derived type of eigen matrix for b (e.g. VectorXi)
  63. // Derivedbc derived type of eigen matrix for bc (e.g. MatrixXd)
  64. // DerivedW derived type of eigen matrix for W (e.g. MatrixXd)
  65. // Inputs:
  66. // V #V by dim vertex positions
  67. // Ele #Elements by simplex-size list of element indices
  68. // b #b boundary indices into V
  69. // bc #b by #W list of boundary values
  70. // data object containing options, intial guess --> solution and results
  71. // Outputs:
  72. // W #V by #W list of *unnormalized* weights to normalize use
  73. // igl::normalize_row_sums(W,W);
  74. // Returns true on success, false on failure
  75. template <
  76. typename DerivedV,
  77. typename DerivedEle,
  78. typename Derivedb,
  79. typename Derivedbc,
  80. typename DerivedW>
  81. IGL_INLINE bool bbw(
  82. const Eigen::PlainObjectBase<DerivedV> & V,
  83. const Eigen::PlainObjectBase<DerivedEle> & Ele,
  84. const Eigen::PlainObjectBase<Derivedb> & b,
  85. const Eigen::PlainObjectBase<Derivedbc> & bc,
  86. BBWData & data,
  87. Eigen::PlainObjectBase<DerivedW> & W);
  88. }
  89. }
  90. #ifndef IGL_STATIC_LIBRARY
  91. # include "bbw.cpp"
  92. #endif
  93. #endif