find_self_intersections.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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_PREDICATES_FIND_SELF_INTERSECTIONS_H
  9. #define IGL_PREDICATES_FIND_SELF_INTERSECTIONS_H
  10. #include "../igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. namespace predicates
  15. {
  16. /// Identify triangle-triangle interesections within the same mesh using
  17. /// AABBTree and igl::predicates::triangle_triangle_intersect.
  18. ///
  19. /// @param[in] V #V by 3 list representing vertices on the first mesh
  20. /// @param[in] F #F by 3 list representing triangles on the first mesh
  21. /// @param[out] IF #IF by 2 list of intersecting triangle pairs, so that
  22. /// F1(IF(i,0),:) intersects F2(IF(i,1),:)
  23. /// @param[out] CP #IF list of whether the intersection is coplanar
  24. ///
  25. /// \see copyleft::cgal::SelfIntersectMesh
  26. template <
  27. typename DerivedV,
  28. typename DerivedF,
  29. typename DerivedIF,
  30. typename DerivedCP>
  31. IGL_INLINE bool find_self_intersections(
  32. const Eigen::MatrixBase<DerivedV> & V,
  33. const Eigen::MatrixBase<DerivedF> & F,
  34. const bool first_only,
  35. Eigen::PlainObjectBase<DerivedIF> & IF,
  36. Eigen::PlainObjectBase<DerivedCP> & CP);
  37. /// @param[out] EV #EV by 3 list of vertex positions of intersection segments
  38. /// @param[out] EE #EE by 2 list of edge indices into EV
  39. /// @param[out] EI #EI by 1 list of indices into rows IF indicating source of
  40. /// intersection.
  41. template <
  42. typename DerivedV,
  43. typename DerivedF,
  44. typename DerivedIF,
  45. typename DerivedCP,
  46. typename DerivedEV,
  47. typename DerivedEE,
  48. typename DerivedEI>
  49. IGL_INLINE bool find_self_intersections(
  50. const Eigen::MatrixBase<DerivedV> & V,
  51. const Eigen::MatrixBase<DerivedF> & F,
  52. Eigen::PlainObjectBase<DerivedIF> & IF,
  53. Eigen::PlainObjectBase<DerivedCP> & CP,
  54. Eigen::PlainObjectBase<DerivedEV> & EV,
  55. Eigen::PlainObjectBase<DerivedEE> & EE,
  56. Eigen::PlainObjectBase<DerivedEI> & EI);
  57. }
  58. }
  59. #ifndef IGL_STATIC_LIBRARY
  60. # include "find_self_intersections.cpp"
  61. #endif
  62. #endif