principal_curvature.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Daniele Panozzo <[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_PRINCIPAL_CURVATURE_H
  9. #define IGL_PRINCIPAL_CURVATURE_H
  10. #include <Eigen/Geometry>
  11. #include <Eigen/Dense>
  12. #include <vector>
  13. #include "igl_inline.h"
  14. namespace igl
  15. {
  16. /// Compute the principal curvature directions and magnitude of the given triangle mesh
  17. /// DerivedV derived from vertex positions matrix type: i.e. Eigen::MatrixXd
  18. /// DerivedF derived from face indices matrix type: i.e. Eigen::MatrixXi
  19. /// @param[in] V eigen matrix #V by 3
  20. /// @param[in] F #F by 3 list of mesh faces (must be triangles)
  21. /// @param[out] PD1 #V by 3 maximal curvature direction for each vertex.
  22. /// @param[out] PD2 #V by 3 minimal curvature direction for each vertex.
  23. /// @param[out] PV1 #V by 1 maximal curvature value for each vertex.
  24. /// @param[out] PV2 #V by 1 minimal curvature value for each vertex.
  25. /// @param[in] radius controls the size of the neighbourhood used, 1 = average edge length
  26. /// @param[in] useKring use Kring neighbourhood instead of ball neighbourhood
  27. /// @return vector of indices of bad vertices if any.
  28. ///
  29. /// This function has been developed by: Nikolas De Giorgis, Luigi Rocca and Enrico Puppo.
  30. /// The algorithm is based on:
  31. /// Efficient Multi-scale Curvature and Crease Estimation
  32. /// Daniele Panozzo, Enrico Puppo, Luigi Rocca
  33. /// GraVisMa, 2010
  34. ///
  35. /// \see average_onto_faces, average_onto_vertices
  36. template <
  37. typename DerivedV,
  38. typename DerivedF,
  39. typename DerivedPD1,
  40. typename DerivedPD2,
  41. typename DerivedPV1,
  42. typename DerivedPV2>
  43. IGL_INLINE void principal_curvature(
  44. const Eigen::MatrixBase<DerivedV>& V,
  45. const Eigen::MatrixBase<DerivedF>& F,
  46. Eigen::PlainObjectBase<DerivedPD1>& PD1,
  47. Eigen::PlainObjectBase<DerivedPD2>& PD2,
  48. Eigen::PlainObjectBase<DerivedPV1>& PV1,
  49. Eigen::PlainObjectBase<DerivedPV2>& PV2,
  50. unsigned radius = 5,
  51. bool useKring = true);
  52. /// \overload
  53. /// @param[out] bad_vertices vector of indices of bad vertices if any.
  54. template <
  55. typename DerivedV,
  56. typename DerivedF,
  57. typename DerivedPD1,
  58. typename DerivedPD2,
  59. typename DerivedPV1,
  60. typename DerivedPV2,
  61. typename Index>
  62. IGL_INLINE void principal_curvature(
  63. const Eigen::MatrixBase<DerivedV>& V,
  64. const Eigen::MatrixBase<DerivedF>& F,
  65. Eigen::PlainObjectBase<DerivedPD1>& PD1,
  66. Eigen::PlainObjectBase<DerivedPD2>& PD2,
  67. Eigen::PlainObjectBase<DerivedPV1>& PV1,
  68. Eigen::PlainObjectBase<DerivedPV2>& PV2,
  69. std::vector<Index>& bad_vertices,
  70. unsigned radius = 5,
  71. bool useKring = true);
  72. }
  73. #ifndef IGL_STATIC_LIBRARY
  74. #include "principal_curvature.cpp"
  75. #endif
  76. #endif