bone_visible.h 2.3 KB

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