bbw.h 2.7 KB

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