intersect_other.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Alec Jacobson <alecjacobson@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. #ifndef IGL_COPYLEFT_CGAL_INTERSECT_OTHER_H
  9. #define IGL_COPYLEFT_CGAL_INTERSECT_OTHER_H
  10. #include "../../igl_inline.h"
  11. #include "RemeshSelfIntersectionsParam.h"
  12. #include <Eigen/Dense>
  13. #ifdef MEX
  14. # include <mex.h>
  15. # include <cassert>
  16. # undef assert
  17. # define assert( isOK ) ( (isOK) ? (void)0 : (void) mexErrMsgTxt(C_STR(__FILE__<<":"<<__LINE__<<": failed assertion `"<<#isOK<<"'"<<std::endl) ) )
  18. #endif
  19. namespace igl
  20. {
  21. namespace copyleft
  22. {
  23. namespace cgal
  24. {
  25. // INTERSECT_OTHER Given a triangle mesh (VA,FA) and another mesh (VB,FB)
  26. // find all pairs of intersecting faces. Note that self-intersections are
  27. // ignored.
  28. //
  29. // Inputs:
  30. // VA #V by 3 list of vertex positions
  31. // FA #F by 3 list of triangle indices into VA
  32. // VB #V by 3 list of vertex positions
  33. // FB #F by 3 list of triangle indices into VB
  34. // params whether to detect only and then whether to only find first
  35. // intersection
  36. // Outputs:
  37. // IF #intersecting face pairs by 2 list of intersecting face pairs,
  38. // indexing FA and FB
  39. // VVA #VVA by 3 list of vertex positions
  40. // FFA #FFA by 3 list of triangle indices into VVA
  41. // JA #FFA list of indices into FA denoting birth triangle
  42. // IMA #VVA list of indices into VVA of unique vertices.
  43. // VVB #VVB by 3 list of vertex positions
  44. // FFB #FFB by 3 list of triangle indices into VVB
  45. // JB #FFB list of indices into FB denoting birth triangle
  46. // IMB #VVB list of indices into VVB of unique vertices.
  47. template <
  48. typename DerivedVA,
  49. typename DerivedFA,
  50. typename DerivedVB,
  51. typename DerivedFB,
  52. typename DerivedIF,
  53. typename DerivedVVA,
  54. typename DerivedFFA,
  55. typename DerivedJA,
  56. typename DerivedIMA,
  57. typename DerivedVVB,
  58. typename DerivedFFB,
  59. typename DerivedJB,
  60. typename DerivedIMB>
  61. IGL_INLINE bool intersect_other(
  62. const Eigen::PlainObjectBase<DerivedVA> & VA,
  63. const Eigen::PlainObjectBase<DerivedFA> & FA,
  64. const Eigen::PlainObjectBase<DerivedVB> & VB,
  65. const Eigen::PlainObjectBase<DerivedFB> & FB,
  66. const RemeshSelfIntersectionsParam & params,
  67. Eigen::PlainObjectBase<DerivedIF> & IF,
  68. Eigen::PlainObjectBase<DerivedVVA> & VVA,
  69. Eigen::PlainObjectBase<DerivedFFA> & FFA,
  70. Eigen::PlainObjectBase<DerivedJA> & JA,
  71. Eigen::PlainObjectBase<DerivedIMA> & IMA,
  72. Eigen::PlainObjectBase<DerivedVVB> & VVB,
  73. Eigen::PlainObjectBase<DerivedFFB> & FFB,
  74. Eigen::PlainObjectBase<DerivedJB> & JB,
  75. Eigen::PlainObjectBase<DerivedIMB> & IMB);
  76. // Legacy wrapper for detect only using common types.
  77. //
  78. // Inputs:
  79. // VA #V by 3 list of vertex positions
  80. // FA #F by 3 list of triangle indices into VA
  81. // VB #V by 3 list of vertex positions
  82. // FB #F by 3 list of triangle indices into VB
  83. // first_only whether to only detect the first intersection.
  84. // Outputs:
  85. // IF #intersecting face pairs by 2 list of intersecting face pairs,
  86. // indexing FA and FB
  87. // Returns true if any intersections were found
  88. //
  89. // See also: remesh_self_intersections
  90. IGL_INLINE bool intersect_other(
  91. const Eigen::MatrixXd & VA,
  92. const Eigen::MatrixXi & FA,
  93. const Eigen::MatrixXd & VB,
  94. const Eigen::MatrixXi & FB,
  95. const bool first_only,
  96. Eigen::MatrixXi & IF);
  97. }
  98. }
  99. }
  100. #ifndef IGL_STATIC_LIBRARY
  101. # include "intersect_other.cpp"
  102. #endif
  103. #endif