bone_visible.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <[email protected]>
  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_EMBREE_BONE_VISIBLE_H
  9. #define IGL_EMBREE_BONE_VISIBLE_H
  10. #include "../igl_inline.h"
  11. #include <Eigen/Core>
  12. #include "EmbreeIntersector.h"
  13. namespace igl
  14. {
  15. namespace embree
  16. {
  17. /// Test whether vertices of mesh are "visible" to a given bone,
  18. /// where "visible" is defined as in [Baran & Popovic 07]. Instead of checking
  19. /// whether each point can see *any* of the bone, we just check if each point
  20. /// can see its own projection onto the bone segment. In other words, we project
  21. /// each vertex v onto the bone, projv. Then we check if there are any
  22. /// intersections between the line segment (projv-->v) and the mesh.
  23. ///
  24. /// @param[in] V #V by 3 list of vertex positions
  25. /// @param[in] F #F by 3 list of triangle indices
  26. /// @param[in] s row vector of position of start end point of bone
  27. /// @param[in] d row vector of position of dest end point of bone
  28. /// @param[out] flag #V by 1 list of bools (true) visible, (false) obstructed
  29. ///
  30. /// \note This checks for hits along the segment which are facing in *any*
  31. /// direction from the ray.
  32. template <
  33. typename DerivedV,
  34. typename DerivedF,
  35. typename DerivedSD,
  36. typename Derivedflag>
  37. IGL_INLINE void bone_visible(
  38. const Eigen::MatrixBase<DerivedV> & V,
  39. const Eigen::MatrixBase<DerivedF> & F,
  40. const Eigen::MatrixBase<DerivedSD> & s,
  41. const Eigen::MatrixBase<DerivedSD> & d,
  42. Eigen::PlainObjectBase<Derivedflag> & flag);
  43. /// \overload
  44. /// @param[in] ei EmbreeIntersector for mesh (V,F) should be double sided
  45. template <
  46. typename DerivedV,
  47. typename DerivedF,
  48. typename DerivedSD,
  49. typename Derivedflag>
  50. IGL_INLINE void bone_visible(
  51. const Eigen::MatrixBase<DerivedV> & V,
  52. const Eigen::MatrixBase<DerivedF> & F,
  53. const EmbreeIntersector & ei,
  54. const Eigen::MatrixBase<DerivedSD> & s,
  55. const Eigen::MatrixBase<DerivedSD> & d,
  56. Eigen::PlainObjectBase<Derivedflag> & flag);
  57. }
  58. }
  59. #ifndef IGL_STATIC_LIBRARY
  60. # include "bone_visible.cpp"
  61. #endif
  62. #endif