find_intersections.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2024 Alec Jacobson [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. #ifndef IGL_FAST_FIND_INTERSECTIONS_H
  9. #define IGL_FAST_FIND_INTERSECTIONS_H
  10. #include "../igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. template <typename DerivedV, int DIM> class AABB;
  15. namespace predicates
  16. {
  17. /// Identify triangles where two meshes interesect
  18. /// using AABBTree and igl::predicates::triangle_triangle_intersect.
  19. ///
  20. /// @param[in] tree1 AABB tree for the first mesh
  21. /// @param[in] V1 #V1 by 3 list representing vertices on the first mesh
  22. /// @param[in] F1 #F1 by 3 list representing triangles on the first mesh
  23. /// @param[in] V2 #V2 by 3 list representing vertices on the second mesh
  24. /// @param[in] F2 #F2 by 3 list representing triangles on the second mesh
  25. /// @param[out] IF #IF by 2 list of intersecting triangle pairs, so that
  26. /// F1(IF(i,0),:) intersects F2(IF(i,1),:)
  27. /// @param[out] CP #IF list of whether the intersection is coplanar
  28. ///
  29. /// \see copyleft::cgal::intersect_other
  30. template <
  31. typename DerivedV1,
  32. typename DerivedF1,
  33. typename DerivedV2,
  34. typename DerivedF2,
  35. typename DerivedIF,
  36. typename DerivedCP>
  37. IGL_INLINE bool find_intersections(
  38. const AABB<DerivedV1,3> & tree1,
  39. const Eigen::MatrixBase<DerivedV1> & V1,
  40. const Eigen::MatrixBase<DerivedF1> & F1,
  41. const Eigen::MatrixBase<DerivedV2> & V2,
  42. const Eigen::MatrixBase<DerivedF2> & F2,
  43. const bool first_only,
  44. Eigen::PlainObjectBase<DerivedIF> & IF,
  45. Eigen::PlainObjectBase<DerivedCP> & CP);
  46. /// \overload
  47. /// \brief Tree built internally.
  48. template <
  49. typename DerivedV1,
  50. typename DerivedF1,
  51. typename DerivedV2,
  52. typename DerivedF2,
  53. typename DerivedIF,
  54. typename DerivedCP>
  55. IGL_INLINE bool find_intersections(
  56. const Eigen::MatrixBase<DerivedV1> & V1,
  57. const Eigen::MatrixBase<DerivedF1> & F1,
  58. const Eigen::MatrixBase<DerivedV2> & V2,
  59. const Eigen::MatrixBase<DerivedF2> & F2,
  60. const bool first_only,
  61. Eigen::PlainObjectBase<DerivedIF> & IF,
  62. Eigen::PlainObjectBase<DerivedCP> & CP);
  63. /// @param[out] EV #EV by 3 list of vertex positions of intersection segments
  64. /// @param[out] EE #EE by 2 list of edge indices into EV
  65. /// @param[out] EI #EI by 1 list of indices into rows IF indicating source of
  66. /// intersection.
  67. template <
  68. typename DerivedV1,
  69. typename DerivedF1,
  70. typename DerivedV2,
  71. typename DerivedF2,
  72. typename DerivedIF,
  73. typename DerivedCP,
  74. typename DerivedEV,
  75. typename DerivedEE,
  76. typename DerivedEI>
  77. IGL_INLINE bool find_intersections(
  78. const Eigen::MatrixBase<DerivedV1> & V1,
  79. const Eigen::MatrixBase<DerivedF1> & F1,
  80. const Eigen::MatrixBase<DerivedV2> & V2,
  81. const Eigen::MatrixBase<DerivedF2> & F2,
  82. Eigen::PlainObjectBase<DerivedIF> & IF,
  83. Eigen::PlainObjectBase<DerivedCP> & CP,
  84. Eigen::PlainObjectBase<DerivedEV> & EV,
  85. Eigen::PlainObjectBase<DerivedEE> & EE,
  86. Eigen::PlainObjectBase<DerivedEI> & EI);
  87. template <
  88. typename DerivedV1,
  89. typename DerivedF1,
  90. typename DerivedV2,
  91. typename DerivedF2,
  92. typename DerivedIF,
  93. typename DerivedCP,
  94. typename DerivedEV,
  95. typename DerivedEE,
  96. typename DerivedEI>
  97. IGL_INLINE bool find_intersections(
  98. const igl::AABB<DerivedV1,3> & tree1,
  99. const Eigen::MatrixBase<DerivedV1> & V1,
  100. const Eigen::MatrixBase<DerivedF1> & F1,
  101. const Eigen::MatrixBase<DerivedV2> & V2,
  102. const Eigen::MatrixBase<DerivedF2> & F2,
  103. Eigen::PlainObjectBase<DerivedIF> & IF,
  104. Eigen::PlainObjectBase<DerivedCP> & CP,
  105. Eigen::PlainObjectBase<DerivedEV> & EV,
  106. Eigen::PlainObjectBase<DerivedEE> & EE,
  107. Eigen::PlainObjectBase<DerivedEI> & EI);
  108. }
  109. }
  110. #ifndef IGL_STATIC_LIBRARY
  111. # include "find_intersections.cpp"
  112. #endif
  113. #endif