remesh_intersections.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Qingnan Zhou <qnzhou@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. //
  9. #ifndef IGL_COPYLEFT_CGAL_REMESH_INTERSECTIONS_H
  10. #define IGL_COPYLEFT_CGAL_REMESH_INTERSECTIONS_H
  11. #include "../../igl_inline.h"
  12. #include <Eigen/Dense>
  13. #include "CGAL_includes.hpp"
  14. namespace igl
  15. {
  16. namespace copyleft
  17. {
  18. namespace cgal
  19. {
  20. // Remesh faces according to results of intersection detection and
  21. // construction (e.g. from `igl::copyleft::cgal::intersect_other` or
  22. // `igl::copyleft::cgal::SelfIntersectMesh`)
  23. //
  24. // Inputs:
  25. // V #V by 3 list of vertex positions
  26. // F #F by 3 list of triangle indices into V
  27. // T #F list of cgal triangles
  28. // offending #offending map taking face indices into F to pairs of order
  29. // of first finding and list of intersection objects from all
  30. // intersections
  31. // edge2faces #edges <= #offending*3 to incident offending faces
  32. // Outputs:
  33. // VV #VV by 3 list of vertex positions
  34. // FF #FF by 3 list of triangle indices into V
  35. // IF #intersecting face pairs by 2 list of intersecting face pairs,
  36. // indexing F
  37. // J #FF list of indices into F denoting birth triangle
  38. // IM #VV list of indices into VV of unique vertices.
  39. //
  40. template <
  41. typename DerivedV,
  42. typename DerivedF,
  43. typename Kernel,
  44. typename DerivedVV,
  45. typename DerivedFF,
  46. typename DerivedJ,
  47. typename DerivedIM>
  48. IGL_INLINE void remesh_intersections(
  49. const Eigen::PlainObjectBase<DerivedV> & V,
  50. const Eigen::PlainObjectBase<DerivedF> & F,
  51. const std::vector<CGAL::Triangle_3<Kernel> > & T,
  52. const std::map<
  53. typename DerivedF::Index,
  54. std::vector<
  55. std::pair<typename DerivedF::Index, CGAL::Object> > > & offending,
  56. const std::map<
  57. std::pair<typename DerivedF::Index,typename DerivedF::Index>,
  58. std::vector<typename DerivedF::Index> > & edge2faces,
  59. Eigen::PlainObjectBase<DerivedVV> & VV,
  60. Eigen::PlainObjectBase<DerivedFF> & FF,
  61. Eigen::PlainObjectBase<DerivedJ> & J,
  62. Eigen::PlainObjectBase<DerivedIM> & IM);
  63. // Same as above except ``stitch_all`` flag:
  64. //
  65. // Input:
  66. // stitch_all: if true, merge all vertices with thte same coordiante.
  67. template <
  68. typename DerivedV,
  69. typename DerivedF,
  70. typename Kernel,
  71. typename DerivedVV,
  72. typename DerivedFF,
  73. typename DerivedJ,
  74. typename DerivedIM>
  75. IGL_INLINE void remesh_intersections(
  76. const Eigen::PlainObjectBase<DerivedV> & V,
  77. const Eigen::PlainObjectBase<DerivedF> & F,
  78. const std::vector<CGAL::Triangle_3<Kernel> > & T,
  79. const std::map<
  80. typename DerivedF::Index,
  81. std::vector<
  82. std::pair<typename DerivedF::Index, CGAL::Object> > > & offending,
  83. const std::map<
  84. std::pair<typename DerivedF::Index,typename DerivedF::Index>,
  85. std::vector<typename DerivedF::Index> > & edge2faces,
  86. bool stitch_all,
  87. Eigen::PlainObjectBase<DerivedVV> & VV,
  88. Eigen::PlainObjectBase<DerivedFF> & FF,
  89. Eigen::PlainObjectBase<DerivedJ> & J,
  90. Eigen::PlainObjectBase<DerivedIM> & IM);
  91. }
  92. }
  93. }
  94. #ifndef IGL_STATIC_LIBRARY
  95. # include "remesh_intersections.cpp"
  96. #endif
  97. #endif