fast_find_intersections.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2022 Vladimir S. FONOV <[email protected]>
  4. // Copyright (C) 2023 Alec Jacobson <[email protected]>
  5. //
  6. // This Source Code Form is subject to the terms of the Mozilla Public License
  7. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  8. // obtain one at http://mozilla.org/MPL/2.0/
  9. #pragma once
  10. #ifndef FAST_FIND_MESH_INTERSECT_H
  11. #define FAST_FIND_MESH_INTERSECT_H
  12. #include "igl_inline.h"
  13. #include <Eigen/Core>
  14. namespace igl
  15. {
  16. template <typename DerivedV, int DIM> class AABB;
  17. /// Identify triangles where two meshes interesect
  18. /// using AABBTree and tri_tri_intersection_test_3d.
  19. ///
  20. /// @param[in] V1 #V1 by 3 list representing vertices on the first mesh
  21. /// @param[in] F1 #F1 by 3 list representing triangles on the first mesh
  22. /// @param[in] V2 #V2 by 3 list representing vertices on the second mesh
  23. /// @param[in] F2 #F2 by 3 list representing triangles on the second mesh
  24. /// @param[out] IF #IF by 2 list of intersecting triangle pairs, so that
  25. /// F1(IF(i,0),:) intersects F2(IF(i,1),:)
  26. /// @param[out] EV #EV by 3 list of vertices definining intersection segments
  27. /// for non-coplanar intersections
  28. /// @param[out] EE #EE by 2 list of edges indices into rows of EV
  29. /// @param[out] EI #EI by 1 list of indices into rows IF indicating source of
  30. /// intersection.
  31. ///
  32. /// \see copyleft::cgal::intersect_other
  33. template <
  34. typename DerivedV1,
  35. typename DerivedF1,
  36. typename DerivedV2,
  37. typename DerivedF2,
  38. typename DerivedIF,
  39. typename DerivedEV,
  40. typename DerivedEE,
  41. typename DerivedEI>
  42. IGL_INLINE bool fast_find_intersections(
  43. const AABB<DerivedV1,3> & tree,
  44. const Eigen::MatrixBase<DerivedV1> & V1,
  45. const Eigen::MatrixBase<DerivedF1> & F1,
  46. const Eigen::MatrixBase<DerivedV2> & V2,
  47. const Eigen::MatrixBase<DerivedF2> & F2,
  48. const bool detect_only,
  49. const bool first_only,
  50. Eigen::PlainObjectBase<DerivedIF> & IF,
  51. Eigen::PlainObjectBase<DerivedEV> & EV,
  52. Eigen::PlainObjectBase<DerivedEE> & EE,
  53. Eigen::PlainObjectBase<DerivedEI> & EI);
  54. /// \overload
  55. /// \brief Tree built internally.
  56. template <
  57. typename DerivedV1,
  58. typename DerivedF1,
  59. typename DerivedV2,
  60. typename DerivedF2,
  61. typename DerivedIF,
  62. typename DerivedEV,
  63. typename DerivedEE,
  64. typename DerivedEI>
  65. IGL_INLINE bool fast_find_intersections(
  66. const Eigen::MatrixBase<DerivedV1> & V1,
  67. const Eigen::MatrixBase<DerivedF1> & F1,
  68. const Eigen::MatrixBase<DerivedV2> & V2,
  69. const Eigen::MatrixBase<DerivedF2> & F2,
  70. const bool detect_only,
  71. const bool first_only,
  72. Eigen::PlainObjectBase<DerivedIF> & IF,
  73. Eigen::PlainObjectBase<DerivedEV> & EV,
  74. Eigen::PlainObjectBase<DerivedEE> & EE,
  75. Eigen::PlainObjectBase<DerivedEI> & EI);
  76. };
  77. #ifndef IGL_STATIC_LIBRARY
  78. # include "fast_find_intersections.cpp"
  79. #endif
  80. #endif