principal_curvature.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 <stdio.h>
  14. #include <map>
  15. #include <igl/igl_inline.h>
  16. #include <igl/cotmatrix.h>
  17. #include <igl/writeOFF.h>
  18. namespace igl
  19. {
  20. // Compute the principal curvature directions and magnitude of the given triangle mesh
  21. // DerivedV derived from vertex positions matrix type: i.e. MatrixXd
  22. // DerivedF derived from face indices matrix type: i.e. MatrixXi
  23. // Inputs:
  24. // V eigen matrix #V by 3
  25. // F #F by 3 list of mesh faces (must be triangles)
  26. // radius controls the size of the neighbourhood used, 1 = average edge lenght
  27. //
  28. // Outputs:
  29. // PD1 #V by 3 maximal curvature direction for each vertex.
  30. // PD2 #V by 3 minimal curvature direction for each vertex.
  31. // PV1 #V by 1 maximal curvature value for each vertex.
  32. // PV2 #V by 1 minimal curvature value for each vertex.
  33. //
  34. // See also: average_onto_faces, average_onto_vertices
  35. //
  36. // This function has been developed by: Nikolas De Giorgis, Luigi Rocca and Enrico Puppo.
  37. // The algorithm is based on:
  38. // Efficient Multi-scale Curvature and Crease Estimation
  39. // Daniele Panozzo, Enrico Puppo, Luigi Rocca
  40. // GraVisMa, 2010
  41. template <
  42. typename DerivedV,
  43. typename DerivedF,
  44. typename DerivedPD1,
  45. typename DerivedPD2,
  46. typename DerivedPV1,
  47. typename DerivedPV2>
  48. IGL_INLINE void principal_curvature(
  49. const Eigen::PlainObjectBase<DerivedV>& V,
  50. const Eigen::PlainObjectBase<DerivedF>& F,
  51. Eigen::PlainObjectBase<DerivedPD1>& PD1,
  52. Eigen::PlainObjectBase<DerivedPD2>& PD2,
  53. Eigen::PlainObjectBase<DerivedPV1>& PV1,
  54. Eigen::PlainObjectBase<DerivedPV2>& PV2,
  55. unsigned radius = 5,
  56. bool useKring = true);
  57. }
  58. #ifndef IGL_STATIC_LIBRARY
  59. #include "principal_curvature.cpp"
  60. #endif
  61. #endif