vertex_triangle_adjacency.h 2.7 KB

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