extract_feature.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 Qingnan Zhou <qnzhou@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_COPYLEFT_CGAL_EXTRACT_FEATURE_H
  9. #define IGL_COPYLEFT_CGAL_EXTRACT_FEATURE_H
  10. #include "../../igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <vector>
  13. namespace igl
  14. {
  15. namespace copyleft
  16. {
  17. namespace cgal
  18. {
  19. // Extract feature edges based on dihedral angle.
  20. // Here, dihedral angle is defined as the angle between surface
  21. // __normals__ as described in
  22. // http://mathworld.wolfram.com/DihedralAngle.html
  23. //
  24. // Non-manifold and boundary edges are automatically considered as
  25. // features.
  26. //
  27. // Inputs:
  28. // V #V by 3 array of vertices.
  29. // F #F by 3 array of faces.
  30. // tol Edges with dihedral angle larger than this are considered
  31. // as features. Angle is measured in radian.
  32. //
  33. // Output:
  34. // feature_edges: #E by 2 array of edges. Each edge satisfies at
  35. // least one of the following criteria:
  36. //
  37. // * Edge has dihedral angle larger than tol.
  38. // * Edge is boundary.
  39. // * Edge is non-manifold (i.e. it has more than 2 adjacent
  40. // faces).
  41. template <
  42. typename DerivedV,
  43. typename DerivedF,
  44. typename DerivedE>
  45. IGL_INLINE void extract_feature(
  46. const Eigen::PlainObjectBase<DerivedV>& V,
  47. const Eigen::PlainObjectBase<DerivedF>& F,
  48. const double tol,
  49. Eigen::PlainObjectBase<DerivedE>& feature_edges);
  50. // Inputs:
  51. // V #V by 3 array of vertices.
  52. // F #F by 3 array of faces.
  53. // tol Edges with dihedral angle larger than this are considered
  54. // as features. Angle is measured in radian.
  55. // E #E by 2 array of directed edges.
  56. // uE #uE by 2 array of undirected edges.
  57. // uE2E #uE list of lists mapping undirected edges to all corresponding
  58. // directed edges.
  59. //
  60. // Output:
  61. // feature_edges: #E by 2 array of edges. Each edge satisfies at
  62. // least one of the following criteria:
  63. //
  64. // * Edge has dihedral angle larger than tol.
  65. // * Edge is boundary.
  66. // * Edge is non-manifold (i.e. it has more than 2 adjacent
  67. // faces).
  68. template <
  69. typename DerivedV,
  70. typename DerivedF,
  71. typename DerivedE>
  72. IGL_INLINE void extract_feature(
  73. const Eigen::PlainObjectBase<DerivedV>& V,
  74. const Eigen::PlainObjectBase<DerivedF>& F,
  75. const double tol,
  76. const Eigen::PlainObjectBase<DerivedE>& E,
  77. const Eigen::PlainObjectBase<DerivedE>& uE,
  78. const std::vector<std::vector<typename DerivedE::Scalar> >& uE2E,
  79. Eigen::PlainObjectBase<DerivedE>& feature_edges);
  80. }
  81. }
  82. }
  83. #ifndef IGL_STATIC_LIBRARY
  84. # include "extract_feature.cpp"
  85. #endif
  86. #endif