intersection_blocking_collapse_edge_callbacks.h 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #ifndef IGL_INTERSECTION_BLOCKING_COLLAPSE_EDGE_CALLBACKS_H
  2. #define IGL_INTERSECTION_BLOCKING_COLLAPSE_EDGE_CALLBACKS_H
  3. #include "igl_inline.h"
  4. #include "decimate_callback_types.h"
  5. #include "placeholders.h"
  6. #include <Eigen/Core>
  7. #include <vector>
  8. namespace igl
  9. {
  10. // Forward declaration
  11. template <typename DerivedV, int DIM> class AABB;
  12. /// Wrap around callbacks for decimate to prevent intersections from being
  13. /// created.
  14. ///
  15. /// @param[in] orig_pre_collapse original pre_collapse callback (callers copy
  16. /// can be destroyed)
  17. /// @param[in] orig_post_collapse original post_collapse callback (ditto)
  18. /// @param[in] leaves list of pointers to leaves of tree (ditto)
  19. /// @param[in,out] tree pointer to AABB tree whose leaves will correspond to
  20. /// the current (non-null) faces in (V,F) (callers copy can _not_ be
  21. /// destroyed – not the tree and not this pointer – until use of
  22. /// pre_/post_collapse is done)
  23. /// @param[out] pre_collapse new pre_collapse callback
  24. /// @param[out] post_collapse new post_collapse callback
  25. ///
  26. /// #### Example
  27. ///
  28. /// ```cpp
  29. /// // Build tree around mesh (must be edge-manifold, may have boundaries)
  30. /// igl::AABB<Eigen::MatrixXd, 3> * tree = new igl::AABB<Eigen::MatrixXd, 3>();
  31. /// tree->init(V,F);
  32. /// // Connect boundaries to dummy infinite vertex (after tree building)
  33. /// Eigen::MatrixXd VO;
  34. /// Eigen::MatrixXi FO;
  35. /// igl::connect_boundary_to_infinity(V,F,VO,FO);
  36. /// // prepare edge structures
  37. /// Eigen::VectorXi EMAP;
  38. /// Eigen::MatrixXi E,EF,EI;
  39. /// igl::edge_flaps(FO,E,EMAP,EF,EI);
  40. /// // prepare callbacks
  41. /// igl::decimate_cost_and_placement_callback cost_and_placement;
  42. /// igl::decimate_pre_collapse_callback pre_collapse;
  43. /// igl::decimate_post_collapse_callback post_collapse;
  44. /// cost_and_placement = igl::shortest_edge_and_midpoint;
  45. /// igl::decimate_trivial_callbacks(pre_collapse,post_collapse);
  46. /// igl::intersection_blocking_collapse_edge_callbacks(
  47. /// pre_collapse, post_collapse, // These will get copied as needed
  48. /// tree,
  49. /// pre_collapse, post_collapse);
  50. /// int m = F.rows();
  51. /// const int orig_m = m;
  52. /// Eigen::MatrixXd U;
  53. /// Eigen::MatrixXi G;
  54. /// Eigen::VectorXi J,I;
  55. /// const bool ret = igl::decimate(
  56. /// VO, FO,
  57. /// cost_and_placement,
  58. /// igl::max_faces_stopping_condition(m,orig_m,target_m),
  59. /// pre_collapse,
  60. /// post_collapse,
  61. /// E, EMAP, EF, EI,
  62. /// U, G, J, I);
  63. /// G = G(igl::find((J.array()<orig_m).eval()), igl::placeholders::all).eval();
  64. /// {
  65. /// Eigen::VectorXi _;
  66. /// igl::remove_unreferenced(Eigen::MatrixXd(U),Eigen::MatrixXi(G),U,G,_);
  67. /// }
  68. /// ```
  69. ///
  70. /// \see decimate.h
  71. IGL_INLINE void intersection_blocking_collapse_edge_callbacks(
  72. const decimate_pre_collapse_callback & orig_pre_collapse,
  73. const decimate_post_collapse_callback & orig_post_collapse,
  74. const std::vector<AABB<Eigen::MatrixXd,3> *> & leaves,
  75. AABB<Eigen::MatrixXd,3> * & tree,
  76. decimate_pre_collapse_callback & pre_collapse,
  77. decimate_post_collapse_callback & post_collapse);
  78. /// \overload Same as above but computes leaves from tree
  79. IGL_INLINE void intersection_blocking_collapse_edge_callbacks(
  80. const decimate_pre_collapse_callback & orig_pre_collapse,
  81. const decimate_post_collapse_callback & orig_post_collapse,
  82. AABB<Eigen::MatrixXd,3> * & tree,
  83. decimate_pre_collapse_callback & pre_collapse,
  84. decimate_post_collapse_callback & post_collapse);
  85. /// \overload Same as above but uses trivial callbacks
  86. IGL_INLINE void intersection_blocking_collapse_edge_callbacks(
  87. AABB<Eigen::MatrixXd,3> * & tree,
  88. decimate_pre_collapse_callback & pre_collapse,
  89. decimate_post_collapse_callback & post_collapse);
  90. }
  91. #ifndef IGL_STATIC_LIBRARY
  92. # include "intersection_blocking_collapse_edge_callbacks.cpp"
  93. #endif
  94. #endif