seam_edges.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 Yotam Gingold <yotam@yotamgingold.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_SEAM_EDGES_H
  9. #define IGL_SEAM_EDGES_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. /*
  15. Returns all UV-space boundaries of a mesh.
  16. Inputs:
  17. V: The positions of the input mesh.
  18. TC: The 2D texture coordinates of the input mesh (2 columns).
  19. F: A manifold-with-boundary triangle mesh, as vertex indices into `V` for the three vertices of each triangle.
  20. FTC: Indices into `TC` for the three vertices of each triangle.
  21. Outputs:
  22. seams: Edges where the forwards and backwards directions have different texture
  23. coordinates, as a #seams-by-4 matrix of indices.
  24. Each row is organized as [ forward_face_index, forward_face_vertex_index,
  25. backwards_face_index, backwards_face_vertex_index ]
  26. such that one side of the seam is the edge:
  27. F[ seams( i, 0 ), seams( i, 1 ) ], F[ seams( i, 0 ), (seams( i, 1 ) + 1) % 3 ]
  28. and the other side is the edge:
  29. F[ seams( i, 2 ), seams( i, 3 ) ], F[ seams( i, 2 ), (seams( i, 3 ) + 1) % 3 ]
  30. boundaries: Edges with only one incident triangle, as a #boundaries-by-2 matrix of
  31. indices. Each row is organized as [ face_index, face_vertex_index ]
  32. such that the edge is:
  33. F[ boundaries( i, 0 ), boundaries( i, 1 ) ], F[ boundaries( i, 0 ), (boundaries( i, 1 ) + 1) % 3 ]
  34. foldovers: Edges where the two incident triangles fold over each other in UV-space,
  35. as a #foldovers-by-4 matrix of indices.
  36. Each row is organized as [ forward_face_index, forward_face_vertex_index,
  37. backwards_face_index, backwards_face_vertex_index ]
  38. such that one side of the foldover is the edge:
  39. F[ foldovers( i, 0 ), foldovers( i, 1 ) ], F[ foldovers( i, 0 ), (foldovers( i, 1 ) + 1) % 3 ]
  40. and the other side is the edge:
  41. F[ foldovers( i, 2 ), foldovers( i, 3 ) ], F[ foldovers( i, 2 ), (foldovers( i, 3 ) + 1) % 3 ]
  42. */
  43. template <typename DerivedV, typename DerivedF, typename DerivedT>
  44. IGL_INLINE void seam_edges(
  45. const Eigen::PlainObjectBase<DerivedV>& V,
  46. const Eigen::PlainObjectBase<DerivedT>& TC,
  47. const Eigen::PlainObjectBase<DerivedF>& F,
  48. const Eigen::PlainObjectBase<DerivedF>& FTC,
  49. Eigen::PlainObjectBase<DerivedF>& seams,
  50. Eigen::PlainObjectBase<DerivedF>& boundaries,
  51. Eigen::PlainObjectBase<DerivedF>& foldovers
  52. );
  53. }
  54. #ifndef IGL_STATIC_LIBRARY
  55. # include "seam_edges.cpp"
  56. #endif
  57. #endif // IGL_SEAM_EDGES_H