extract_cells.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. {
  19. // Extract connected 3D space partitioned by mesh (V, F).
  20. //
  21. // Inputs:
  22. // V #V by 3 array of vertices.
  23. // F #F by 3 array of faces.
  24. //
  25. // Output:
  26. // cells #F by 2 array of cell indices. cells(i,0) represents the
  27. // cell index on the positive side of face i, and cells(i,1)
  28. // represents cell index of the negqtive side.
  29. // By convension cell with index 0 is the infinite cell.
  30. template<
  31. typename DerivedV,
  32. typename DerivedF,
  33. typename DerivedC >
  34. IGL_INLINE size_t extract_cells(
  35. const Eigen::PlainObjectBase<DerivedV>& V,
  36. const Eigen::PlainObjectBase<DerivedF>& F,
  37. Eigen::PlainObjectBase<DerivedC>& cells);
  38. // Extract connected 3D space partitioned by mesh (V, F).
  39. //
  40. // Inputs:
  41. // V #V by 3 array of vertices.
  42. // F #F by 3 array of faces.
  43. // P #F list of patch indices.
  44. // E #E by 2 array of vertex indices, one edge per row.
  45. // uE #uE by 2 list of vertex_indices, represents undirected edges.
  46. // uE2E #uE list of lists that maps uE to E. (a one-to-many map)
  47. // EMAP #F*3 list of indices into uE.
  48. //
  49. // Output:
  50. // cells #P by 2 array of cell indices. cells(i,0) represents the
  51. // cell index on the positive side of patch i, and cells(i,1)
  52. // represents cell index of the negqtive side.
  53. // By convension cell with index 0 is the infinite cell.
  54. template<
  55. typename DerivedV,
  56. typename DerivedF,
  57. typename DerivedP,
  58. typename DerivedE,
  59. typename DeriveduE,
  60. typename uE2EType,
  61. typename DerivedEMAP,
  62. typename DerivedC >
  63. IGL_INLINE size_t extract_cells(
  64. const Eigen::PlainObjectBase<DerivedV>& V,
  65. const Eigen::PlainObjectBase<DerivedF>& F,
  66. const Eigen::PlainObjectBase<DerivedP>& P,
  67. const Eigen::PlainObjectBase<DerivedE>& E,
  68. const Eigen::PlainObjectBase<DeriveduE>& uE,
  69. const std::vector<std::vector<uE2EType> >& uE2E,
  70. const Eigen::PlainObjectBase<DerivedEMAP>& EMAP,
  71. Eigen::PlainObjectBase<DerivedC>& cells);
  72. // Extract connected 3D space partitioned by mesh (V,F) composed of
  73. // **possibly multiple components** (the name of this function is
  74. // dubious).
  75. //
  76. // Inputs:
  77. // V #V by 3 array of vertices.
  78. // F #F by 3 array of faces.
  79. // P #F list of patch indices.
  80. // E #E by 2 array of vertex indices, one edge per row.
  81. // uE #uE by 2 list of vertex_indices, represents undirected edges.
  82. // uE2E #uE list of lists that maps uE to E. (a one-to-many map)
  83. // EMAP #F*3 list of indices into uE.
  84. // Output:
  85. // cells #P by 2 array of cell indices. cells(i,0) represents the
  86. // cell index on the positive side of patch i, and cells(i,1)
  87. // represents cell index of the negative side.
  88. template<
  89. typename DerivedV,
  90. typename DerivedF,
  91. typename DerivedP,
  92. typename DeriveduE,
  93. typename uE2EType,
  94. typename DerivedEMAP,
  95. typename DerivedC >
  96. IGL_INLINE size_t extract_cells_single_component(
  97. const Eigen::PlainObjectBase<DerivedV>& V,
  98. const Eigen::PlainObjectBase<DerivedF>& F,
  99. const Eigen::PlainObjectBase<DerivedP>& P,
  100. const Eigen::PlainObjectBase<DeriveduE>& uE,
  101. const std::vector<std::vector<uE2EType> >& uE2E,
  102. const Eigen::PlainObjectBase<DerivedEMAP>& EMAP,
  103. Eigen::PlainObjectBase<DerivedC>& cells);
  104. }
  105. }
  106. }
  107. #ifndef IGL_STATIC_LIBRARY
  108. # include "extract_cells.cpp"
  109. #endif
  110. #endif