tt.h 2.3 KB

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