principal_curvature.h 2.7 KB

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