vertex_triangle_adjacency.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2014 Daniele Panozzo <[email protected]>
  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_VERTEX_TRIANGLE_ADJACENCY_H
  9. #define IGL_VERTEX_TRIANGLE_ADJACENCY_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Dense>
  12. #include <vector>
  13. namespace igl
  14. {
  15. /// vertex_face_adjacency constructs the vertex-face topology of a given mesh (V,F)
  16. ///
  17. /// @param[in] n number of vertices #V (e.g. `F.maxCoeff()+1` or `V.rows()`)
  18. /// @param[in] F #F by dim list of mesh faces (must be triangles)
  19. /// @param[out] VF #V list of lists of incident faces (adjacency list)
  20. /// @param[out] VI #V list of lists of index of incidence within incident faces listed
  21. /// in VF
  22. ///
  23. /// \see edges, cotmatrix, diag, vv
  24. ///
  25. /// \bug this should not take V as an input parameter.
  26. /// \bug if a facet is combinatorially degenerate then faces will appear
  27. /// multiple times in VF and correspondingly in VFI (j appears twice in
  28. /// F.row(i) then i will appear twice in VF[j])
  29. template <typename DerivedF, typename VFType, typename VFiType>
  30. IGL_INLINE void vertex_triangle_adjacency(
  31. const typename DerivedF::Scalar n,
  32. const Eigen::MatrixBase<DerivedF>& F,
  33. std::vector<std::vector<VFType> >& VF,
  34. std::vector<std::vector<VFiType> >& VFi);
  35. /// \overload
  36. template <typename DerivedV, typename DerivedF, typename IndexType>
  37. IGL_INLINE void vertex_triangle_adjacency(
  38. const Eigen::MatrixBase<DerivedV>& V,
  39. const Eigen::MatrixBase<DerivedF>& F,
  40. std::vector<std::vector<IndexType> >& VF,
  41. std::vector<std::vector<IndexType> >& VFi);
  42. /// \overload
  43. ///
  44. /// @param[in] F #F by 3 list of triangle indices into some vertex list V
  45. /// @param[in] n number of vertices, #V (e.g., F.maxCoeff()+1)
  46. /// @param[out] VF 3*#F list List of faces indice on each vertex, so that VF(NI(i)+j) =
  47. /// f, means that face f is the jth face (in no particular order) incident
  48. /// on vertex i.
  49. /// @param[out] NI #V+1 list cumulative sum of vertex-triangle degrees with a
  50. /// preceeding zero. "How many faces" have been seen before visiting this
  51. /// vertex and its incident faces.
  52. template <
  53. typename DerivedF,
  54. typename DerivedVF,
  55. typename DerivedNI>
  56. IGL_INLINE void vertex_triangle_adjacency(
  57. const Eigen::MatrixBase<DerivedF> & F,
  58. const int n,
  59. Eigen::PlainObjectBase<DerivedVF> & VF,
  60. Eigen::PlainObjectBase<DerivedNI> & NI);
  61. }
  62. #ifndef IGL_STATIC_LIBRARY
  63. # include "vertex_triangle_adjacency.cpp"
  64. #endif
  65. #endif