extract_cells.h 4.3 KB

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