closest_facet.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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_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. // Inputs:
  28. // V #V by 3 array of vertices.
  29. // F #F by 3 array of faces.
  30. // I #I list of triangle indices to consider.
  31. // P #P by 3 array of query points.
  32. //
  33. // Outputs:
  34. // R #P list of closest facet indices.
  35. // S #P list of bools indicating on which side of the closest facet
  36. // each query point lies.
  37. template<
  38. typename DerivedV,
  39. typename DerivedF,
  40. typename DerivedI,
  41. typename DerivedP,
  42. typename uE2EType,
  43. typename DerivedEMAP,
  44. typename DerivedR,
  45. typename DerivedS >
  46. IGL_INLINE void closest_facet(
  47. const Eigen::PlainObjectBase<DerivedV>& V,
  48. const Eigen::PlainObjectBase<DerivedF>& F,
  49. const Eigen::PlainObjectBase<DerivedI>& I,
  50. const Eigen::PlainObjectBase<DerivedP>& P,
  51. const std::vector<std::vector<uE2EType> >& uE2E,
  52. const Eigen::PlainObjectBase<DerivedEMAP>& EMAP,
  53. Eigen::PlainObjectBase<DerivedR>& R,
  54. Eigen::PlainObjectBase<DerivedS>& S);
  55. template<
  56. typename DerivedV,
  57. typename DerivedF,
  58. typename DerivedP,
  59. typename uE2EType,
  60. typename DerivedEMAP,
  61. typename DerivedR,
  62. typename DerivedS >
  63. IGL_INLINE void closest_facet(
  64. const Eigen::PlainObjectBase<DerivedV>& V,
  65. const Eigen::PlainObjectBase<DerivedF>& F,
  66. const Eigen::PlainObjectBase<DerivedP>& P,
  67. const std::vector<std::vector<uE2EType> >& uE2E,
  68. const Eigen::PlainObjectBase<DerivedEMAP>& EMAP,
  69. Eigen::PlainObjectBase<DerivedR>& R,
  70. Eigen::PlainObjectBase<DerivedS>& S);
  71. template<
  72. typename DerivedV,
  73. typename DerivedF,
  74. typename DerivedI,
  75. typename DerivedP,
  76. typename uE2EType,
  77. typename DerivedEMAP,
  78. typename Kernel,
  79. typename DerivedR,
  80. typename DerivedS >
  81. IGL_INLINE void closest_facet(
  82. const Eigen::PlainObjectBase<DerivedV>& V,
  83. const Eigen::PlainObjectBase<DerivedF>& F,
  84. const Eigen::PlainObjectBase<DerivedI>& I,
  85. const Eigen::PlainObjectBase<DerivedP>& P,
  86. const std::vector<std::vector<uE2EType> >& uE2E,
  87. const Eigen::PlainObjectBase<DerivedEMAP>& EMAP,
  88. const std::vector<std::vector<size_t> > & VF,
  89. const std::vector<std::vector<size_t> > & VFi,
  90. const CGAL::AABB_tree<
  91. CGAL::AABB_traits<
  92. Kernel,
  93. CGAL::AABB_triangle_primitive<
  94. Kernel, typename std::vector<
  95. typename Kernel::Triangle_3 >::iterator > > > & tree,
  96. const std::vector<typename Kernel::Triangle_3 > & triangles,
  97. const std::vector<bool> & in_I,
  98. Eigen::PlainObjectBase<DerivedR>& R,
  99. Eigen::PlainObjectBase<DerivedS>& S);
  100. }
  101. }
  102. }
  103. #ifndef IGL_STATIC_LIBRARY
  104. #include "closest_facet.cpp"
  105. #endif
  106. #endif