heat_geodesics.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2018 Alec Jacobson <[email protected]>
  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_HEAT_GEODESICS_H
  9. #define IGL_HEAT_GEODESICS_H
  10. #include "igl_inline.h"
  11. #include "min_quad_with_fixed.h"
  12. #include <Eigen/Sparse>
  13. #include <Eigen/Sparse>
  14. namespace igl
  15. {
  16. /// Precomputation data for heat_geodesics_solve
  17. ///
  18. /// \fileinfo
  19. template <typename Scalar>
  20. struct HeatGeodesicsData
  21. {
  22. /// Gradient operator
  23. Eigen::SparseMatrix<Scalar> Grad;
  24. /// Divergence operator
  25. Eigen::SparseMatrix<Scalar> Div;
  26. /// Number of gradient components
  27. int ng;
  28. /// List of boundary vertex indices
  29. Eigen::VectorXi b;
  30. /// Cached solvers for Dirichet, Neumann problems
  31. min_quad_with_fixed_data<Scalar> Dirichlet,Neumann,Poisson;
  32. /// Whether to use intrinsic Delaunay Laplacian
  33. bool use_intrinsic_delaunay = false;
  34. };
  35. /// Precompute factorized solvers for computing a fast approximation of
  36. /// geodesic distances on a mesh (V,F). [Crane et al. 2013]
  37. ///
  38. /// @param[in] V #V by dim list of mesh vertex positions
  39. /// @param[in] F #F by 3 list of mesh face indices into V
  40. /// @param[out] data precomputation data (see heat_geodesics_solve)
  41. ///
  42. /// \fileinfo
  43. template < typename DerivedV, typename DerivedF, typename Scalar >
  44. IGL_INLINE bool heat_geodesics_precompute(
  45. const Eigen::MatrixBase<DerivedV> & V,
  46. const Eigen::MatrixBase<DerivedF> & F,
  47. HeatGeodesicsData<Scalar> & data);
  48. /// \overload
  49. /// @param[in] t "heat" parameter (smaller --> more accurate, less stable)
  50. ///
  51. /// \fileinfo
  52. template < typename DerivedV, typename DerivedF, typename Scalar >
  53. IGL_INLINE bool heat_geodesics_precompute(
  54. const Eigen::MatrixBase<DerivedV> & V,
  55. const Eigen::MatrixBase<DerivedF> & F,
  56. const Scalar t,
  57. HeatGeodesicsData<Scalar> & data);
  58. /// Compute fast approximate geodesic distances using precomputed data from a
  59. /// set of selected source vertices (gamma).
  60. ///
  61. /// @param[in] data precomputation data (see heat_geodesics_precompute)
  62. /// @param[in] gamma #gamma list of indices into V of source vertices
  63. /// @param[out] D #V list of distances to gamma
  64. ///
  65. /// \fileinfo
  66. template < typename Scalar, typename Derivedgamma, typename DerivedD>
  67. IGL_INLINE void heat_geodesics_solve(
  68. const HeatGeodesicsData<Scalar> & data,
  69. const Eigen::MatrixBase<Derivedgamma> & gamma,
  70. Eigen::PlainObjectBase<DerivedD> & D);
  71. }
  72. #ifndef IGL_STATIC_LIBRARY
  73. #include "heat_geodesics.cpp"
  74. #endif
  75. #endif