submesh_aabb_tree.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 Alec Jacobson
  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_SUBMESH_AABB_TREE_H
  10. #define IGL_COPYLET_CGAL_SUBMESH_AABB_TREE_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. /// Build an AABB tree for a submesh indicated by a face selection list I
  26. /// of a full mesh (V,F)
  27. ///
  28. /// @param[in] V #V by 3 array of vertices.
  29. /// @param[in] F #F by 3 array of faces.
  30. /// @param[in] I #I list of triangle indices to consider.
  31. /// @param[out] tree aabb containing triangles of (V,F(I,:))
  32. /// @param[out] triangles #I list of cgal triangles
  33. /// @param[out] in_I #F list of whether in submesh
  34. template<
  35. typename DerivedV,
  36. typename DerivedF,
  37. typename DerivedI,
  38. typename Kernel>
  39. IGL_INLINE void submesh_aabb_tree(
  40. const Eigen::MatrixBase<DerivedV>& V,
  41. const Eigen::MatrixBase<DerivedF>& F,
  42. const Eigen::MatrixBase<DerivedI>& I,
  43. CGAL::AABB_tree<
  44. CGAL::AABB_traits<
  45. Kernel,
  46. CGAL::AABB_triangle_primitive<
  47. Kernel, typename std::vector<
  48. typename Kernel::Triangle_3 >::iterator > > > & tree,
  49. std::vector<typename Kernel::Triangle_3 > & triangles,
  50. std::vector<bool> & in_I);
  51. }
  52. }
  53. }
  54. #ifndef IGL_STATIC_LIBRARY
  55. # include "submesh_aabb_tree.cpp"
  56. #endif
  57. #endif