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