extract_cells.h 4.4 KB

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