screen_space_selection.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #ifndef IGL_SCREEN_SPACE_SELECTION_H
  2. #define IGL_SCREEN_SPACE_SELECTION_H
  3. #include "igl/igl_inline.h"
  4. #include <Eigen/Core>
  5. #include <vector>
  6. // Forward declaration
  7. namespace igl { template <typename DerivedV, int DIM> class AABB; }
  8. namespace igl
  9. {
  10. /// Given a mesh, a camera determine which points are inside of a given 2D
  11. /// screen space polygon **culling points based on self-occlusion.**
  12. ///
  13. /// @param[in] V #V by 3 list of mesh vertex positions
  14. /// @param[in] F #F by 3 list of mesh triangle indices into rows of V
  15. /// @param[in] tree precomputed bounding volume heirarchy
  16. /// @param[in] model 4 by 4 camera model-view matrix
  17. /// @param[in] proj 4 by 4 camera projection matrix (perspective or orthoraphic)
  18. /// @param[in] viewport 4-vector containing camera viewport
  19. /// @param[in] L #L by 2 list of 2D polygon vertices (in order)
  20. /// @param[out] W #V by 1 list of winding numbers (|W|>0.5 indicates inside)
  21. /// @param[out] and_visible #V by 1 list of visibility values (only correct for vertices
  22. /// with |W|>0.5)
  23. template <
  24. typename DerivedV,
  25. typename DerivedF,
  26. typename DerivedM,
  27. typename DerivedN,
  28. typename DerivedO,
  29. typename Ltype,
  30. typename DerivedW,
  31. typename Deriveda>
  32. IGL_INLINE void screen_space_selection(
  33. const Eigen::MatrixBase<DerivedV> & V,
  34. const Eigen::MatrixBase<DerivedF> & F,
  35. const igl::AABB<DerivedV, 3> & tree,
  36. const Eigen::MatrixBase<DerivedM>& model,
  37. const Eigen::MatrixBase<DerivedN>& proj,
  38. const Eigen::MatrixBase<DerivedO>& viewport,
  39. const std::vector<Eigen::Matrix<Ltype,1,2> > & L,
  40. Eigen::PlainObjectBase<DerivedW> & W,
  41. Eigen::PlainObjectBase<Deriveda> & and_visible);
  42. /// Given a mesh, a camera determine which points are inside of a given 2D
  43. /// screen space polygon
  44. ///
  45. /// @param[in] V #V by 3 list of mesh vertex positions
  46. /// @param[in] model 4 by 4 camera model-view matrix
  47. /// @param[in] proj 4 by 4 camera projection matrix (perspective or orthoraphic)
  48. /// @param[in] viewport 4-vector containing camera viewport
  49. /// @param[in] L #L by 2 list of 2D polygon vertices (in order)
  50. /// @param[out] W #V by 1 list of winding numbers (|W|>0.5 indicates inside)
  51. template <
  52. typename DerivedV,
  53. typename DerivedM,
  54. typename DerivedN,
  55. typename DerivedO,
  56. typename Ltype,
  57. typename DerivedW>
  58. IGL_INLINE void screen_space_selection(
  59. const Eigen::MatrixBase<DerivedV> & V,
  60. const Eigen::MatrixBase<DerivedM>& model,
  61. const Eigen::MatrixBase<DerivedN>& proj,
  62. const Eigen::MatrixBase<DerivedO>& viewport,
  63. const std::vector<Eigen::Matrix<Ltype,1,2> > & L,
  64. Eigen::PlainObjectBase<DerivedW> & W);
  65. /// Given a mesh, a camera determine which points are inside of a given 2D
  66. /// screen space polygon
  67. ///
  68. /// @param[in] V #V by 3 list of mesh vertex positions
  69. /// @param[in] model 4 by 4 camera model-view matrix
  70. /// @param[in] proj 4 by 4 camera projection matrix (perspective or orthoraphic)
  71. /// @param[in] viewport 4-vector containing camera viewport
  72. /// @param[in] P #P by 2 list of screen space polygon vertices
  73. /// @param[in] E #E by 2 list of screen space edges as indices into rows of P
  74. /// @param[out] W #V by 1 list of winding numbers (|W|>0.5 indicates inside)
  75. template <
  76. typename DerivedV,
  77. typename DerivedM,
  78. typename DerivedN,
  79. typename DerivedO,
  80. typename DerivedP,
  81. typename DerivedE,
  82. typename DerivedW>
  83. IGL_INLINE void screen_space_selection(
  84. const Eigen::MatrixBase<DerivedV> & V,
  85. const Eigen::MatrixBase<DerivedM>& model,
  86. const Eigen::MatrixBase<DerivedN>& proj,
  87. const Eigen::MatrixBase<DerivedO>& viewport,
  88. const Eigen::MatrixBase<DerivedP> & P,
  89. const Eigen::MatrixBase<DerivedE> & E,
  90. Eigen::PlainObjectBase<DerivedW> & W);
  91. }
  92. #ifndef IGL_STATIC_LIBRARY
  93. #include "screen_space_selection.cpp"
  94. #endif
  95. #endif