extract_cells.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Qingnan Zhou <qnzhou@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. //
  9. #ifndef IGL_COPYLEFT_CGAL_EXTRACT_CELLS
  10. #define IGL_COPYLEFT_CGAL_EXTRACT_CELLS
  11. #include "../../igl_inline.h"
  12. #include <Eigen/Core>
  13. #include <vector>
  14. namespace igl {
  15. namespace copyleft
  16. {
  17. namespace cgal {
  18. // Extract connected 3D space partitioned by mesh (V, F).
  19. //
  20. // Inputs:
  21. // V #V by 3 array of vertices.
  22. // F #F by 3 array of faces.
  23. //
  24. // Output:
  25. // cells #F by 2 array of cell indices. cells(i,0) represents the
  26. // cell index on the positive side of face i, and cells(i,1)
  27. // represents cell index of the negqtive side.
  28. template<
  29. typename DerivedV,
  30. typename DerivedF,
  31. typename DerivedC >
  32. IGL_INLINE size_t extract_cells(
  33. const Eigen::PlainObjectBase<DerivedV>& V,
  34. const Eigen::PlainObjectBase<DerivedF>& F,
  35. Eigen::PlainObjectBase<DerivedC>& cells);
  36. // Extract connected 3D space partitioned by mesh (V, F).
  37. //
  38. // Inputs:
  39. // V #V by 3 array of vertices.
  40. // F #F by 3 array of faces.
  41. // P #F list of patch indices.
  42. // E #E by 2 array of vertex indices, one edge per row.
  43. // uE #uE by 2 list of vertex_indices, represents undirected edges.
  44. // uE2E #uE list of lists that maps uE to E. (a one-to-many map)
  45. // EMAP #F*3 list of indices into uE.
  46. //
  47. // Output:
  48. // cells #P by 2 array of cell indices. cells(i,0) represents the
  49. // cell index on the positive side of patch i, and cells(i,1)
  50. // represents cell index of the negqtive side.
  51. template<
  52. typename DerivedV,
  53. typename DerivedF,
  54. typename DerivedP,
  55. typename DerivedE,
  56. typename DeriveduE,
  57. typename uE2EType,
  58. typename DerivedEMAP,
  59. typename DerivedC >
  60. IGL_INLINE size_t extract_cells(
  61. const Eigen::PlainObjectBase<DerivedV>& V,
  62. const Eigen::PlainObjectBase<DerivedF>& F,
  63. const Eigen::PlainObjectBase<DerivedP>& P,
  64. const Eigen::PlainObjectBase<DerivedE>& E,
  65. const Eigen::PlainObjectBase<DeriveduE>& uE,
  66. const std::vector<std::vector<uE2EType> >& uE2E,
  67. const Eigen::PlainObjectBase<DerivedEMAP>& EMAP,
  68. Eigen::PlainObjectBase<DerivedC>& cells);
  69. // Extract connected 3D space partitioned by mesh (V, F). Each
  70. // connected component of the mesh partitions the ambient space
  71. // separately.
  72. //
  73. // Inputs:
  74. // V #V by 3 array of vertices.
  75. // F #F by 3 array of faces.
  76. // P #F list of patch indices.
  77. // E #E by 2 array of vertex indices, one edge per row.
  78. // uE #uE by 2 list of vertex_indices, represents undirected edges.
  79. // uE2E #uE list of lists that maps uE to E. (a one-to-many map)
  80. // EMAP #F*3 list of indices into uE.
  81. //
  82. // Output:
  83. // cells #P by 2 array of cell indices. cells(i,0) represents the
  84. // cell index on the positive side of patch i, and cells(i,1)
  85. // represents cell index of the negqtive side.
  86. template<
  87. typename DerivedV,
  88. typename DerivedF,
  89. typename DerivedP,
  90. typename DeriveduE,
  91. typename uE2EType,
  92. typename DerivedEMAP,
  93. typename DerivedC >
  94. IGL_INLINE size_t extract_cells_single_component(
  95. const Eigen::PlainObjectBase<DerivedV>& V,
  96. const Eigen::PlainObjectBase<DerivedF>& F,
  97. const Eigen::PlainObjectBase<DerivedP>& P,
  98. const Eigen::PlainObjectBase<DeriveduE>& uE,
  99. const std::vector<std::vector<uE2EType> >& uE2E,
  100. const Eigen::PlainObjectBase<DerivedEMAP>& EMAP,
  101. Eigen::PlainObjectBase<DerivedC>& cells);
  102. }
  103. }
  104. }
  105. #ifndef IGL_STATIC_LIBRARY
  106. # include "extract_cells.cpp"
  107. #endif
  108. #endif