heat_geodesics.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. // Number of gradient components
  22. int ng;
  23. // List of boundary vertex indices
  24. Eigen::VectorXi b;
  25. // Solvers for Dirichet, Neumann problems
  26. min_quad_with_fixed_data<Scalar> Dirichlet,Neumann,Poisson;
  27. bool use_intrinsic_delaunay = false;
  28. };
  29. // Precompute factorized solvers for computing a fast approximation of
  30. // geodesic distances on a mesh (V,F). [Crane et al. 2013]
  31. //
  32. // Inputs:
  33. // V #V by dim list of mesh vertex positions
  34. // F #F by 3 list of mesh face indices into V
  35. // Outputs:
  36. // data precomputation data (see heat_geodesics_solve)
  37. template < typename DerivedV, typename DerivedF, typename Scalar >
  38. IGL_INLINE bool heat_geodesics_precompute(
  39. const Eigen::MatrixBase<DerivedV> & V,
  40. const Eigen::MatrixBase<DerivedF> & F,
  41. HeatGeodesicsData<Scalar> & data);
  42. // Inputs:
  43. // t "heat" parameter (smaller --> more accurate, less stable)
  44. template < typename DerivedV, typename DerivedF, typename Scalar >
  45. IGL_INLINE bool heat_geodesics_precompute(
  46. const Eigen::MatrixBase<DerivedV> & V,
  47. const Eigen::MatrixBase<DerivedF> & F,
  48. const Scalar t,
  49. HeatGeodesicsData<Scalar> & data);
  50. // Compute fast approximate geodesic distances using precomputed data from a
  51. // set of selected source vertices (gamma)
  52. //
  53. // Inputs:
  54. // data precomputation data (see heat_geodesics_precompute)
  55. // gamma #gamma list of indices into V of source vertices
  56. // Outputs:
  57. // D #V list of distances to gamma
  58. template < typename Scalar, typename Derivedgamma, typename DerivedD>
  59. IGL_INLINE void heat_geodesics_solve(
  60. const HeatGeodesicsData<Scalar> & data,
  61. const Eigen::MatrixBase<Derivedgamma> & gamma,
  62. Eigen::PlainObjectBase<DerivedD> & D);
  63. }
  64. #ifndef IGL_STATIC_LIBRARY
  65. #include "heat_geodesics.cpp"
  66. #endif
  67. #endif