intersect_other.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. // VVAB #VVAB by 3 list of vertex positions
  40. // FFAB #FFAB by 3 list of triangle indices into VVA
  41. // JAB #FFAB list of indices into [FA;FB] denoting birth triangle
  42. // IMAB #VVAB list of indices stitching duplicates (resulting from
  43. // mesh intersections) together
  44. template <
  45. typename DerivedVA,
  46. typename DerivedFA,
  47. typename DerivedVB,
  48. typename DerivedFB,
  49. typename DerivedIF,
  50. typename DerivedVVAB,
  51. typename DerivedFFAB,
  52. typename DerivedJAB,
  53. typename DerivedIMAB>
  54. IGL_INLINE bool intersect_other(
  55. const Eigen::PlainObjectBase<DerivedVA> & VA,
  56. const Eigen::PlainObjectBase<DerivedFA> & FA,
  57. const Eigen::PlainObjectBase<DerivedVB> & VB,
  58. const Eigen::PlainObjectBase<DerivedFB> & FB,
  59. const RemeshSelfIntersectionsParam & params,
  60. Eigen::PlainObjectBase<DerivedIF> & IF,
  61. Eigen::PlainObjectBase<DerivedVVAB> & VVAB,
  62. Eigen::PlainObjectBase<DerivedFFAB> & FFAB,
  63. Eigen::PlainObjectBase<DerivedJAB> & JAB,
  64. Eigen::PlainObjectBase<DerivedIMAB> & IMAB);
  65. // Legacy wrapper for detect only using common types.
  66. //
  67. // Inputs:
  68. // VA #V by 3 list of vertex positions
  69. // FA #F by 3 list of triangle indices into VA
  70. // VB #V by 3 list of vertex positions
  71. // FB #F by 3 list of triangle indices into VB
  72. // first_only whether to only detect the first intersection.
  73. // Outputs:
  74. // IF #intersecting face pairs by 2 list of intersecting face pairs,
  75. // indexing FA and FB
  76. // Returns true if any intersections were found
  77. //
  78. // See also: remesh_self_intersections
  79. IGL_INLINE bool intersect_other(
  80. const Eigen::MatrixXd & VA,
  81. const Eigen::MatrixXi & FA,
  82. const Eigen::MatrixXd & VB,
  83. const Eigen::MatrixXi & FB,
  84. const bool first_only,
  85. Eigen::MatrixXi & IF);
  86. }
  87. }
  88. }
  89. #ifndef IGL_STATIC_LIBRARY
  90. # include "intersect_other.cpp"
  91. #endif
  92. #endif