tt.h 2.7 KB

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