polyvector_field_singularities_from_matchings.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Olga Diamanti <olga.diam@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_POLYVECTOR_FIELD_SINGULARITIES_FROM_MATCHINGS
  9. #define IGL_POLYVECTOR_FIELD_SINGULARITIES_FROM_MATCHINGS
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <vector>
  13. namespace igl {
  14. // We are given a polyvector field on a mesh (with N vectors per face), and matchings between the vector sets
  15. // across all non-boundary edges. The function computes, for the one-ring
  16. // neighborhood of a given vertex, and for the selected vector of the vector set,
  17. // the sequence of the vectors that match to it around the one-ring. If the vector that
  18. // we land on by following the matchings is not the original vector that we started from,
  19. // the vertex is a singularity.
  20. //
  21. // Inputs:
  22. // V #V by 3 list of the vertex positions
  23. // F #F by 3 list of the faces (must be triangles)
  24. // VF #V list of lists of incident faces (adjacency list), e.g.
  25. // as returned by igl::vertex_triangle_adjacency
  26. // E2F #E by 2 list of the edge-to-face relation (e.g. computed
  27. // via igl::edge_topology)
  28. // F2E #F by 3 list of the face-to-edge relation (e.g. computed
  29. // via igl::edge_topology)
  30. // TT #F by 3 triangle to triangle adjacent matrix (e.g. computed
  31. // via igl:triangle_triangle_adjacency)
  32. // match_ab #E by N matrix, describing for each edge the matching a->b, where a
  33. // and b are the faces adjacent to the edge (i.e. vector #i of
  34. // the vector set in a is matched to vector #mab[i] in b)
  35. // match_ba #E by N matrix, describing for each edge the matching b->a, where a
  36. // and b are the faces adjacent to the edge (i.e. vector #mba[i] of
  37. // the vector set in a is matched to vector #i in b)
  38. // vi the selected one ring
  39. // vector_id the selected vector of the polyvector
  40. //
  41. // Output:
  42. // mvi #numOneRingFaces by 1 list of the indices of the sequentially matching vectors
  43. // in the faces of the one ring (first enty is always vector_id, then the vector matching
  44. // vector_id in the next face, then the vector matching that in the third face etc.)
  45. // fi #numOneRingFaces by 1 list of the sequentially visited faces in the one ring neighborhood
  46. //
  47. template <typename DerivedV, typename DerivedF, typename DerivedM, typename VFType, typename DerivedTT>
  48. void polyvector_field_one_ring_matchings(const Eigen::PlainObjectBase<DerivedV> &V,
  49. const Eigen::PlainObjectBase<DerivedF> &F,
  50. const std::vector<std::vector<VFType> >& VF,
  51. const Eigen::MatrixXi& E2F,
  52. const Eigen::MatrixXi& F2E,
  53. const Eigen::PlainObjectBase<DerivedTT>& TT,
  54. const Eigen::PlainObjectBase<DerivedM> &match_ab,
  55. const Eigen::PlainObjectBase<DerivedM> &match_ba,
  56. const int vi,
  57. const int vector_id,
  58. Eigen::VectorXi &mvi,
  59. Eigen::VectorXi &fi);
  60. // Given a polyvector field on a mesh, and matchings between the vector sets
  61. // across all non-boundary edges, the function computes the singularities of the
  62. // polyvector field, by computing the one ring matchings.
  63. //
  64. // Inputs:
  65. // V #V by 3 list of the vertex positions
  66. // F #F by 3 list of the faces (must be triangles)
  67. // V_border #V by 1 list of booleans, indicating if the corresponging vertex is
  68. // at the mesh boundary, e.g. as returned by igl::is_border_vertex
  69. // VF #V list of lists of incident faces (adjacency list), e.g.
  70. // as returned by igl::vertex_triangle_adjacency
  71. // TT #F by 3 triangle to triangle adjacent matrix (e.g. computed
  72. // via igl:triangle_triangle_adjacency)
  73. // E2F #E by 2 list of the edge-to-face relation (e.g. computed
  74. // via igl::edge_topology)
  75. // F2E #F by 3 list of the face-to-edge relation (e.g. computed
  76. // via igl::edge_topology)
  77. // match_ab #E by N matrix, describing for each edge the matching a->b, where a
  78. // and b are the faces adjacent to the edge (i.e. vector #i of
  79. // the vector set in a is matched to vector #mab[i] in b)
  80. // match_ba #E by N matrix, describing for each edge the matching b->a, where a
  81. // and b are the faces adjacent to the edge (i.e. vector #mba[i] of
  82. // the vector set in a is matched to vector #i in b)
  83. //
  84. // Output:
  85. // singularities #S by 1 list of the indices of the singular vertices
  86. //
  87. template <typename DerivedV, typename DerivedF, typename DerivedM, typename VFType, typename DerivedS>
  88. IGL_INLINE void polyvector_field_singularities_from_matchings(
  89. const Eigen::PlainObjectBase<DerivedV> &V,
  90. const Eigen::PlainObjectBase<DerivedF> &F,
  91. const std::vector<bool> &V_border,
  92. const std::vector<std::vector<VFType> > &VF,
  93. const Eigen::MatrixXi &TT,
  94. const Eigen::MatrixXi &E2F,
  95. const Eigen::MatrixXi &F2E,
  96. const Eigen::PlainObjectBase<DerivedM> &match_ab,
  97. const Eigen::PlainObjectBase<DerivedM> &match_ba,
  98. Eigen::PlainObjectBase<DerivedS> &singularities);
  99. // Wrapper with only V,F and the matchings as input
  100. template <typename DerivedV, typename DerivedF, typename DerivedM, typename DerivedS>
  101. IGL_INLINE void polyvector_field_singularities_from_matchings(
  102. const Eigen::PlainObjectBase<DerivedV> &V,
  103. const Eigen::PlainObjectBase<DerivedF> &F,
  104. const Eigen::PlainObjectBase<DerivedM> &match_ab,
  105. const Eigen::PlainObjectBase<DerivedM> &match_ba,
  106. Eigen::PlainObjectBase<DerivedS> &singularities);
  107. };
  108. #ifndef IGL_STATIC_LIBRARY
  109. #include "polyvector_field_singularities_from_matchings.cpp"
  110. #endif
  111. #endif /* defined(IGL_POLYVECTOR_FIELD_SINGULARITIES_FROM_MATCHINGS) */