exact_geodesic.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2017 Zhongshi Jiang <jiangzs@nyu.edu>
  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_EXACT_GEODESIC_H
  9. #define IGL_EXACT_GEODESIC_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. // Exact geodesic algorithm for triangular mesh with the implementation from https://code.google.com/archive/p/geodesic/,
  15. // and the algorithm first described by Mitchell, Mount and Papadimitriou in 1987
  16. //
  17. // Inputs:
  18. // V #V by 3 list of 3D vertex positions
  19. // F #F by 3 list of mesh faces
  20. // VS #VS by 1 vector specifying indices of source vertices
  21. // FS #FS by 1 vector specifying indices of source faces
  22. // VT #VT by 1 vector specifying indices of target vertices
  23. // FT #FT by 1 vector specifying indices of target faces
  24. // Output:
  25. // D #VT+#FT by 1 vector of geodesic distances of each target w.r.t. the nearest one in the source set
  26. //
  27. // Note:
  28. // Specifying a face as target/source means its center.
  29. //
  30. template <
  31. typename DerivedV,
  32. typename DerivedF,
  33. typename DerivedVS,
  34. typename DerivedFS,
  35. typename DerivedVT,
  36. typename DerivedFT,
  37. typename DerivedD>
  38. IGL_INLINE void exact_geodesic(
  39. const Eigen::MatrixBase<DerivedV> &V,
  40. const Eigen::MatrixBase<DerivedF> &F,
  41. const Eigen::MatrixBase<DerivedVS> &VS,
  42. const Eigen::MatrixBase<DerivedFS> &FS,
  43. const Eigen::MatrixBase<DerivedVT> &VT,
  44. const Eigen::MatrixBase<DerivedFT> &FT,
  45. Eigen::PlainObjectBase<DerivedD> &D);
  46. }
  47. #ifndef IGL_STATIC_LIBRARY
  48. # include "exact_geodesic.cpp"
  49. #endif
  50. #endif