intersect_other.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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_CGAL_INTERSECT_OTHER_H
  9. #define IGL_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 cgal
  22. {
  23. // INTERSECT_OTHER Given a triangle mesh (VA,FA) and another mesh (VB,FB)
  24. // find all pairs of intersecting faces. Note that self-intersections are
  25. // ignored.
  26. //
  27. // Inputs:
  28. // VA #V by 3 list of vertex positions
  29. // FA #F by 3 list of triangle indices into VA
  30. // VB #V by 3 list of vertex positions
  31. // FB #F by 3 list of triangle indices into VB
  32. // params whether to detect only and then whether to only find first
  33. // intersection
  34. // Outputs:
  35. // IF #intersecting face pairs by 2 list of intersecting face pairs,
  36. // indexing FA and FB
  37. // VVA #VVA by 3 list of vertex positions
  38. // FFA #FFA by 3 list of triangle indices into VVA
  39. // JA #FFA list of indices into FA denoting birth triangle
  40. // IMA #VVA list of indices into VVA of unique vertices.
  41. // VVB #VVB by 3 list of vertex positions
  42. // FFB #FFB by 3 list of triangle indices into VVB
  43. // JB #FFB list of indices into FB denoting birth triangle
  44. // IMB #VVB list of indices into VVB of unique vertices.
  45. template <
  46. typename DerivedVA,
  47. typename DerivedFA,
  48. typename DerivedVB,
  49. typename DerivedFB,
  50. typename DerivedIF,
  51. typename DerivedVVA,
  52. typename DerivedFFA,
  53. typename DerivedJA,
  54. typename DerivedIMA,
  55. typename DerivedVVB,
  56. typename DerivedFFB,
  57. typename DerivedJB,
  58. typename DerivedIMB>
  59. IGL_INLINE bool intersect_other(
  60. const Eigen::PlainObjectBase<DerivedVA> & VA,
  61. const Eigen::PlainObjectBase<DerivedFA> & FA,
  62. const Eigen::PlainObjectBase<DerivedVB> & VB,
  63. const Eigen::PlainObjectBase<DerivedFB> & FB,
  64. const RemeshSelfIntersectionsParam & params,
  65. Eigen::PlainObjectBase<DerivedIF> & IF,
  66. Eigen::PlainObjectBase<DerivedVVA> & VVA,
  67. Eigen::PlainObjectBase<DerivedFFA> & FFA,
  68. Eigen::PlainObjectBase<DerivedJA> & JA,
  69. Eigen::PlainObjectBase<DerivedIMA> & IMA,
  70. Eigen::PlainObjectBase<DerivedVVB> & VVB,
  71. Eigen::PlainObjectBase<DerivedFFB> & FFB,
  72. Eigen::PlainObjectBase<DerivedJB> & JB,
  73. Eigen::PlainObjectBase<DerivedIMB> & IMB);
  74. // Legacy wrapper for detect only using common types.
  75. //
  76. // Inputs:
  77. // VA #V by 3 list of vertex positions
  78. // FA #F by 3 list of triangle indices into VA
  79. // VB #V by 3 list of vertex positions
  80. // FB #F by 3 list of triangle indices into VB
  81. // first_only whether to only detect the first intersection.
  82. // Outputs:
  83. // IF #intersecting face pairs by 2 list of intersecting face pairs,
  84. // indexing FA and FB
  85. // Returns true if any intersections were found
  86. //
  87. // See also: remesh_self_intersections
  88. IGL_INLINE bool intersect_other(
  89. const Eigen::MatrixXd & VA,
  90. const Eigen::MatrixXi & FA,
  91. const Eigen::MatrixXd & VB,
  92. const Eigen::MatrixXi & FB,
  93. const bool first_only,
  94. Eigen::MatrixXi & IF);
  95. }
  96. }
  97. #ifndef IGL_STATIC_LIBRARY
  98. # include "intersect_other.cpp"
  99. #endif
  100. #endif