remesh_intersections.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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_CGAL_REMESH_INTERSECTIONS_H
  9. #define IGL_CGAL_REMESH_INTERSECTIONS_H
  10. #include <igl/igl_inline.h>
  11. #include <Eigen/Dense>
  12. #include "CGAL_includes.hpp"
  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 cgal
  22. {
  23. // Remesh faces according to results of intersection detection and
  24. // construction (e.g. from `igl::cgal::intersect_other` or
  25. // `igl::cgal::SelfIntersectMesh`)
  26. //
  27. // Inputs:
  28. // V #V by 3 list of vertex positions
  29. // F #F by 3 list of triangle indices into V
  30. // T #F list of cgal triangles
  31. // offending #offending map taking face indices into F to pairs of order
  32. // of first finding and list of intersection objects from all
  33. // intersections
  34. // edge2faces #edges <= #offending*3 to incident offending faces
  35. // Outputs:
  36. // VV #VV by 3 list of vertex positions
  37. // FF #FF by 3 list of triangle indices into V
  38. // IF #intersecting face pairs by 2 list of intersecting face pairs,
  39. // indexing F
  40. // J #FF list of indices into F denoting birth triangle
  41. // IM #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::pair<typename DerivedF::Index,
  58. std::vector<CGAL::Object> > > & offending,
  59. const std::map<
  60. std::pair<typename DerivedF::Index,typename DerivedF::Index>,
  61. std::vector<typename DerivedF::Index> > & edge2faces,
  62. Eigen::PlainObjectBase<DerivedVV> & VV,
  63. Eigen::PlainObjectBase<DerivedFF> & FF,
  64. Eigen::PlainObjectBase<DerivedJ> & J,
  65. Eigen::PlainObjectBase<DerivedIM> & IM);
  66. }
  67. }
  68. #ifndef IGL_STATIC_LIBRARY
  69. # include "remesh_intersections.cpp"
  70. #endif
  71. #endif