heat_geodesics.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2018 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_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. template <typename Scalar>
  17. struct HeatGeodesicsData
  18. {
  19. // Gradient and Divergence operators
  20. Eigen::SparseMatrix<Scalar> Grad,Div;
  21. // List of boundary vertex indices
  22. Eigen::VectorXi b;
  23. // Solvers for Dirichet, Neumann problems
  24. min_quad_with_fixed_data<Scalar> Dirichlet,Neumann,Poisson;
  25. bool use_intrinsic_delaunay = false;
  26. };
  27. // Precompute factorized solvers for computing a fast approximation of
  28. // geodesic distances on a mesh (V,F). [Crane et al. 2013]
  29. //
  30. // Inputs:
  31. // V #V by dim list of mesh vertex positions
  32. // F #F by 3 list of mesh face indices into V
  33. // Outputs:
  34. // data precomputation data (see heat_geodesics_solve)
  35. template < typename DerivedV, typename DerivedF, typename Scalar >
  36. IGL_INLINE bool heat_geodesics_precompute(
  37. const Eigen::MatrixBase<DerivedV> & V,
  38. const Eigen::MatrixBase<DerivedF> & F,
  39. HeatGeodesicsData<Scalar> & data);
  40. // Inputs:
  41. // t "heat" parameter (smaller --> more accurate, less stable)
  42. template < typename DerivedV, typename DerivedF, typename Scalar >
  43. IGL_INLINE bool heat_geodesics_precompute(
  44. const Eigen::MatrixBase<DerivedV> & V,
  45. const Eigen::MatrixBase<DerivedF> & F,
  46. const Scalar t,
  47. HeatGeodesicsData<Scalar> & data);
  48. // Compute fast approximate geodesic distances using precomputed data from a
  49. // set of selected source vertices (gamma)
  50. //
  51. // Inputs:
  52. // data precomputation data (see heat_geodesics_precompute)
  53. // gamma #gamma list of indices into V of source vertices
  54. // Outputs:
  55. // D #V list of distances to gamma
  56. template < typename Scalar, typename Derivedgamma, typename DerivedD>
  57. IGL_INLINE void heat_geodesics_solve(
  58. const HeatGeodesicsData<Scalar> & data,
  59. const Eigen::MatrixBase<Derivedgamma> & gamma,
  60. Eigen::PlainObjectBase<DerivedD> & D);
  61. }
  62. #ifndef IGL_STATIC_LIBRARY
  63. #include "heat_geodesics.cpp"
  64. #endif
  65. #endif