submesh_aabb_tree.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. // Inputs:
  29. // V #V by 3 array of vertices.
  30. // F #F by 3 array of faces.
  31. // I #I list of triangle indices to consider.
  32. // Outputs:
  33. // tree aabb containing triangles of (V,F(I,:))
  34. // triangles #I list of cgal triangles
  35. // in_I #F list of whether in submesh
  36. template<
  37. typename DerivedV,
  38. typename DerivedF,
  39. typename DerivedI,
  40. typename Kernel>
  41. IGL_INLINE void submesh_aabb_tree(
  42. const Eigen::PlainObjectBase<DerivedV>& V,
  43. const Eigen::PlainObjectBase<DerivedF>& F,
  44. const Eigen::PlainObjectBase<DerivedI>& I,
  45. CGAL::AABB_tree<
  46. CGAL::AABB_traits<
  47. Kernel,
  48. CGAL::AABB_triangle_primitive<
  49. Kernel, typename std::vector<
  50. typename Kernel::Triangle_3 >::iterator > > > & tree,
  51. std::vector<typename Kernel::Triangle_3 > & triangles,
  52. std::vector<bool> & in_I);
  53. }
  54. }
  55. }
  56. #ifndef IGL_STATIC_LIBRARY
  57. # include "submesh_aabb_tree.cpp"
  58. #endif
  59. #endif