remesh_intersections.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. // stitch_all if true, merge all vertices with thte same coordiante.
  33. // Outputs:
  34. // VV #VV by 3 list of vertex positions, if stitch_all = false then
  35. // first #V vertices will always be V
  36. // FF #FF by 3 list of triangle indices into V
  37. // IF #intersecting face pairs by 2 list of intersecting face pairs,
  38. // indexing F
  39. // J #FF list of indices into F denoting birth triangle
  40. // IM / stitch_all = true #VV list from 0 to #VV-1
  41. // \ stitch_all = false #VV list of indices into VV of unique vertices.
  42. //
  43. template <
  44. typename DerivedV,
  45. typename DerivedF,
  46. typename Kernel,
  47. typename DerivedVV,
  48. typename DerivedFF,
  49. typename DerivedJ,
  50. typename DerivedIM>
  51. IGL_INLINE void remesh_intersections(
  52. const Eigen::PlainObjectBase<DerivedV> & V,
  53. const Eigen::PlainObjectBase<DerivedF> & F,
  54. const std::vector<CGAL::Triangle_3<Kernel> > & T,
  55. const std::map<
  56. typename DerivedF::Index,
  57. std::vector<
  58. std::pair<typename DerivedF::Index, CGAL::Object> > > & offending,
  59. const std::map<
  60. std::pair<typename DerivedF::Index,typename DerivedF::Index>,
  61. std::vector<typename DerivedF::Index> > & edge2faces,
  62. bool stitch_all,
  63. Eigen::PlainObjectBase<DerivedVV> & VV,
  64. Eigen::PlainObjectBase<DerivedFF> & FF,
  65. Eigen::PlainObjectBase<DerivedJ> & J,
  66. Eigen::PlainObjectBase<DerivedIM> & IM);
  67. // Same as above except stitch_all is assumed "false"
  68. template <
  69. typename DerivedV,
  70. typename DerivedF,
  71. typename Kernel,
  72. typename DerivedVV,
  73. typename DerivedFF,
  74. typename DerivedJ,
  75. typename DerivedIM>
  76. IGL_INLINE void remesh_intersections(
  77. const Eigen::PlainObjectBase<DerivedV> & V,
  78. const Eigen::PlainObjectBase<DerivedF> & F,
  79. const std::vector<CGAL::Triangle_3<Kernel> > & T,
  80. const std::map<
  81. typename DerivedF::Index,
  82. std::vector<
  83. std::pair<typename DerivedF::Index, CGAL::Object> > > & offending,
  84. const std::map<
  85. std::pair<typename DerivedF::Index,typename DerivedF::Index>,
  86. std::vector<typename DerivedF::Index> > & edge2faces,
  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