remesh_intersections.h 3.4 KB

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