extract_cells.h 4.5 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. // 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. // By convension cell with index 0 is the infinite cell.
  29. template<
  30. typename DerivedV,
  31. typename DerivedF,
  32. typename DerivedC >
  33. IGL_INLINE size_t extract_cells(
  34. const Eigen::PlainObjectBase<DerivedV>& V,
  35. const Eigen::PlainObjectBase<DerivedF>& F,
  36. Eigen::PlainObjectBase<DerivedC>& cells);
  37. // Extract connected 3D space partitioned by mesh (V, F).
  38. //
  39. // Inputs:
  40. // V #V by 3 array of vertices.
  41. // F #F by 3 array of faces.
  42. // P #F list of patch indices.
  43. // E #E by 2 array of vertex indices, one edge per row.
  44. // uE #uE by 2 list of vertex_indices, represents undirected edges.
  45. // uE2E #uE list of lists that maps uE to E. (a one-to-many map)
  46. // EMAP #F*3 list of indices into uE.
  47. //
  48. // Output:
  49. // cells #P by 2 array of cell indices. cells(i,0) represents the
  50. // cell index on the positive side of patch i, and cells(i,1)
  51. // represents cell index of the negqtive side.
  52. // By convension cell with index 0 is the infinite cell.
  53. template<
  54. typename DerivedV,
  55. typename DerivedF,
  56. typename DerivedP,
  57. typename DerivedE,
  58. typename DeriveduE,
  59. typename uE2EType,
  60. typename DerivedEMAP,
  61. typename DerivedC >
  62. IGL_INLINE size_t extract_cells(
  63. const Eigen::PlainObjectBase<DerivedV>& V,
  64. const Eigen::PlainObjectBase<DerivedF>& F,
  65. const Eigen::PlainObjectBase<DerivedP>& P,
  66. const Eigen::PlainObjectBase<DerivedE>& E,
  67. const Eigen::PlainObjectBase<DeriveduE>& uE,
  68. const std::vector<std::vector<uE2EType> >& uE2E,
  69. const Eigen::PlainObjectBase<DerivedEMAP>& EMAP,
  70. Eigen::PlainObjectBase<DerivedC>& cells);
  71. // Extract connected 3D space partitioned by mesh (V, F). Each
  72. // connected component of the mesh partitions the ambient space
  73. // separately.
  74. //
  75. // Inputs:
  76. // V #V by 3 array of vertices.
  77. // F #F by 3 array of faces.
  78. // P #F list of patch indices.
  79. // E #E by 2 array of vertex indices, one edge per row.
  80. // uE #uE by 2 list of vertex_indices, represents undirected edges.
  81. // uE2E #uE list of lists that maps uE to E. (a one-to-many map)
  82. // EMAP #F*3 list of indices into uE.
  83. //
  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 negqtive 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