closest_facet.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Qingnan Zhou <[email protected]>
  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_COPYLET_CGAL_CLOSEST_FACET_H
  10. #define IGL_COPYLET_CGAL_CLOSEST_FACET_H
  11. #include "../../igl_inline.h"
  12. #include <Eigen/Core>
  13. #include <vector>
  14. #include <CGAL/AABB_tree.h>
  15. #include <CGAL/AABB_traits.h>
  16. #include <CGAL/AABB_triangle_primitive.h>
  17. #include <CGAL/intersections.h>
  18. #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
  19. namespace igl
  20. {
  21. namespace copyleft
  22. {
  23. namespace cgal
  24. {
  25. /// Determine the closest facet for each of the input points.
  26. ///
  27. /// @param[in] V #V by 3 array of vertices.
  28. /// @param[in] F #F by 3 array of faces.
  29. /// @param[in] I #I list of triangle indices to consider.
  30. /// @param[in] P #P by 3 array of query points.
  31. /// @param[in] EMAP #F*3 list of indices into uE.
  32. /// @param[in] uEC #uE+1 list of cumsums of directed edges sharing each unique edge
  33. /// @param[in] uEE #E list of indices into E (see `igl::unique_edge_map`)
  34. /// @param[in] VF #V list of lists of incident faces (adjacency list)
  35. /// @param[in] VFi #V list of lists of index of incidence within incident faces listed in VF
  36. /// @param[in] tree AABB containing triangles of (V,F(I,:))
  37. /// @param[in] triangles #I list of cgal triangles
  38. /// @param[in] in_I #F list of whether in submesh
  39. /// @param[out] R #P list of closest facet indices.
  40. /// @param[out] S #P list of bools indicating on which side of the closest facet
  41. /// each query point lies.
  42. ///
  43. /// \note The use of `size_t` here is a bad idea. These should just be int
  44. /// to avoid nonsense with windows.
  45. template<
  46. typename DerivedV,
  47. typename DerivedF,
  48. typename DerivedI,
  49. typename DerivedP,
  50. typename DerivedEMAP,
  51. typename DeriveduEC,
  52. typename DeriveduEE,
  53. typename Kernel,
  54. typename DerivedR,
  55. typename DerivedS >
  56. IGL_INLINE void closest_facet(
  57. const Eigen::MatrixBase<DerivedV>& V,
  58. const Eigen::MatrixBase<DerivedF>& F,
  59. const Eigen::MatrixBase<DerivedI>& I,
  60. const Eigen::MatrixBase<DerivedP>& P,
  61. const Eigen::MatrixBase<DerivedEMAP>& EMAP,
  62. const Eigen::MatrixBase<DeriveduEC>& uEC,
  63. const Eigen::MatrixBase<DeriveduEE>& uEE,
  64. const std::vector<std::vector<size_t> > & VF,
  65. const std::vector<std::vector<size_t> > & VFi,
  66. const CGAL::AABB_tree<
  67. CGAL::AABB_traits<
  68. Kernel,
  69. CGAL::AABB_triangle_primitive<
  70. Kernel, typename std::vector<
  71. typename Kernel::Triangle_3 >::iterator > > > & tree,
  72. const std::vector<typename Kernel::Triangle_3 > & triangles,
  73. const std::vector<bool> & in_I,
  74. Eigen::PlainObjectBase<DerivedR>& R,
  75. Eigen::PlainObjectBase<DerivedS>& S);
  76. /// \overload
  77. template<
  78. typename DerivedV,
  79. typename DerivedF,
  80. typename DerivedI,
  81. typename DerivedP,
  82. typename DerivedEMAP,
  83. typename DeriveduEC,
  84. typename DeriveduEE,
  85. typename DerivedR,
  86. typename DerivedS >
  87. IGL_INLINE void closest_facet(
  88. const Eigen::MatrixBase<DerivedV>& V,
  89. const Eigen::MatrixBase<DerivedF>& F,
  90. const Eigen::MatrixBase<DerivedI>& I,
  91. const Eigen::MatrixBase<DerivedP>& P,
  92. const Eigen::MatrixBase<DerivedEMAP>& EMAP,
  93. const Eigen::MatrixBase<DeriveduEC>& uEC,
  94. const Eigen::MatrixBase<DeriveduEE>& uEE,
  95. Eigen::PlainObjectBase<DerivedR>& R,
  96. Eigen::PlainObjectBase<DerivedS>& S);
  97. /// \overload
  98. template<
  99. typename DerivedV,
  100. typename DerivedF,
  101. typename DerivedP,
  102. typename DerivedEMAP,
  103. typename DeriveduEC,
  104. typename DeriveduEE,
  105. typename DerivedR,
  106. typename DerivedS >
  107. IGL_INLINE void closest_facet(
  108. const Eigen::MatrixBase<DerivedV>& V,
  109. const Eigen::MatrixBase<DerivedF>& F,
  110. const Eigen::MatrixBase<DerivedP>& P,
  111. const Eigen::MatrixBase<DerivedEMAP>& EMAP,
  112. const Eigen::MatrixBase<DeriveduEC>& uEC,
  113. const Eigen::MatrixBase<DeriveduEE>& uEE,
  114. Eigen::PlainObjectBase<DerivedR>& R,
  115. Eigen::PlainObjectBase<DerivedS>& S);
  116. /// \overload
  117. template<
  118. typename DerivedV,
  119. typename DerivedF,
  120. typename DerivedI,
  121. typename DerivedP,
  122. typename DerivedEMAP,
  123. typename DeriveduEC,
  124. typename DeriveduEE,
  125. typename Kernel,
  126. typename DerivedR,
  127. typename DerivedS >
  128. IGL_INLINE void closest_facet(
  129. const Eigen::MatrixBase<DerivedV>& V,
  130. const Eigen::MatrixBase<DerivedF>& F,
  131. const Eigen::MatrixBase<DerivedI>& I,
  132. const Eigen::MatrixBase<DerivedP>& P,
  133. const Eigen::MatrixBase<DerivedEMAP>& EMAP,
  134. const Eigen::MatrixBase<DeriveduEC>& uEC,
  135. const Eigen::MatrixBase<DeriveduEE>& uEE,
  136. const std::vector<std::vector<size_t> > & VF,
  137. const std::vector<std::vector<size_t> > & VFi,
  138. const CGAL::AABB_tree<
  139. CGAL::AABB_traits<
  140. Kernel,
  141. CGAL::AABB_triangle_primitive<
  142. Kernel, typename std::vector<
  143. typename Kernel::Triangle_3 >::iterator > > > & tree,
  144. const std::vector<typename Kernel::Triangle_3 > & triangles,
  145. const std::vector<bool> & in_I,
  146. Eigen::PlainObjectBase<DerivedR>& R,
  147. Eigen::PlainObjectBase<DerivedS>& S);
  148. }
  149. }
  150. }
  151. #ifndef IGL_STATIC_LIBRARY
  152. #include "closest_facet.cpp"
  153. #endif
  154. #endif