ray_mesh_intersect.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef IGL_RAY_MESH_INTERSECT_H
  2. #define IGL_RAY_MESH_INTERSECT_H
  3. #include "igl_inline.h"
  4. #include "Hit.h"
  5. #include <Eigen/Core>
  6. #include <vector>
  7. namespace igl
  8. {
  9. // Shoot a ray against a mesh (V,F) and collect all hits.
  10. //
  11. // Inputs:
  12. // source 3-vector origin of ray
  13. // dir 3-vector direction of ray
  14. // V #V by 3 list of mesh vertex positions
  15. // F #F by 3 list of mesh face indices into V
  16. // Outputs:
  17. // hits **sorted** list of hits
  18. // Returns true if there were any hits (hits.size() > 0)
  19. //
  20. template <
  21. typename Derivedsource,
  22. typename Deriveddir,
  23. typename DerivedV,
  24. typename DerivedF>
  25. IGL_INLINE bool ray_mesh_intersect(
  26. const Eigen::PlainObjectBase<Derivedsource> & source,
  27. const Eigen::PlainObjectBase<Deriveddir> & dir,
  28. const Eigen::PlainObjectBase<DerivedV> & V,
  29. const Eigen::PlainObjectBase<DerivedF> & F,
  30. std::vector<igl::Hit> & hits);
  31. // Outputs:
  32. // hit first hit, set only if it exists
  33. // Returns true if there was a hit
  34. template <
  35. typename Derivedsource,
  36. typename Deriveddir,
  37. typename DerivedV,
  38. typename DerivedF>
  39. IGL_INLINE bool ray_mesh_intersect(
  40. const Eigen::PlainObjectBase<Derivedsource> & source,
  41. const Eigen::PlainObjectBase<Deriveddir> & dir,
  42. const Eigen::PlainObjectBase<DerivedV> & V,
  43. const Eigen::PlainObjectBase<DerivedF> & F,
  44. igl::Hit & hit);
  45. }
  46. #ifndef IGL_STATIC_LIBRARY
  47. # include "ray_mesh_intersect.cpp"
  48. #endif
  49. #endif