tt.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // IGL Lib - Simple C++ mesh library
  3. //
  4. // Copyright 2011, Daniele Panozzo. All rights reserved.
  5. #ifndef IGL_TT_H
  6. #define IGL_TT_H
  7. #include "igl_inline.h"
  8. #include <Eigen/Core>
  9. #include <vector>
  10. namespace igl
  11. {
  12. // Constructs the triangle adjacency matrix for a given
  13. // mesh (V,F).
  14. //
  15. // Templates:
  16. // Scalar derived type of eigen matrix for V (e.g. derived from
  17. // MatirxXd)
  18. // Index derived type of eigen matrix for F (e.g. derived from
  19. // MatrixXi)
  20. // Inputs:
  21. // V #V by dim list of mesh vertex positions
  22. // F #F by simplex_size list of mesh faces (must be triangles)
  23. // Outputs:
  24. // TT #F by #3 adjacent matrix, the element i,j is the id of the triangle adjacent to the j edge of triangle i
  25. // TTi #F by #3 adjacent matrix, the element i,j is the id of edge of the triangle TT(i,j) that is adjacent with triangle i
  26. // NOTE: the first edge of a triangle is [0,1] the second [1,2] and the third [2,3].
  27. // this convention is DIFFERENT from cotangent.h
  28. template <typename Scalar, typename Index>
  29. IGL_INLINE void tt(const Eigen::PlainObjectBase<Scalar>& V,
  30. const Eigen::PlainObjectBase<Index>& F,
  31. Eigen::PlainObjectBase<Index>& TT);
  32. // Compute triangle-triangle adjacency with indices
  33. template <typename Scalar, typename Index>
  34. IGL_INLINE void tt(const Eigen::PlainObjectBase<Scalar>& V,
  35. const Eigen::PlainObjectBase<Index>& F,
  36. Eigen::PlainObjectBase<Index>& TT,
  37. Eigen::PlainObjectBase<Index>& TTi);
  38. // Preprocessing
  39. template <typename Scalar, typename Index>
  40. IGL_INLINE void tt_preprocess(const Eigen::PlainObjectBase<Scalar>& V,
  41. const Eigen::PlainObjectBase<Index>& F,
  42. std::vector<std::vector<int> >& TTT);
  43. // Extract the face adjacencies
  44. template <typename Index>
  45. IGL_INLINE void tt_extractTT(const Eigen::PlainObjectBase<Index>& F,
  46. std::vector<std::vector<int> >& TTT,
  47. Eigen::PlainObjectBase<Index>& TT);
  48. // Extract the face adjacencies indices (needed for fast traversal)
  49. template <typename Index>
  50. IGL_INLINE void tt_extractTTi(const Eigen::PlainObjectBase<Index>& F,
  51. std::vector<std::vector<int> >& TTT,
  52. Eigen::PlainObjectBase<Index>& TTi);
  53. }
  54. #ifdef IGL_HEADER_ONLY
  55. # include "tt.cpp"
  56. #endif
  57. #endif