GemaCoreLib
The GeMA Core library
gmBVHAcceleration.h
Go to the documentation of this file.
1 
13 #ifndef _GEMA_BVHACCELERATION_H_
14 #define _GEMA_BVHACCELERATION_H_
15 
16 // BVH includes
17 #include <bvh.h>
18 #include <vec.h>
19 #include <ray.h>
20 #include <node.h>
21 #include <default_builder.h>
22 #include <thread_pool.h>
23 #include <stack.h>
24 #include <tri.h>
26 
27 
28 #include <vector>
29 
30 
32  double first[3];
33  double last[3];
34  int count;
35 };
36 
37 
39 {
40 
41  //BVH aliases for double and 3 geometry
42  using Scalar = double;
43  using Vec3 = bvh::Vec<Scalar, 3>;
44  using BBox = bvh::BBox<Scalar, 3>;
45  using Tri = bvh::Tri<Scalar, 3>;
46  using Node = bvh::Node<Scalar, 3>;
47  using Bvh = bvh::Bvh<Node>;
48  using Ray = bvh::Ray<Scalar, 3>;
49  using PrecomputedTri = bvh::PrecomputedTri<Scalar>;
50 
52 
53 private:
54 
55  Bvh bvh;
56  std::vector<PrecomputedTri> preTri;
57 
58 public:
59  /*
60  * Constructor for BVH acceleration structure
61  *
62  * triCoords - [x1, y1, z1, .., xn, yn, zn]
63  * triIndex - [ t1_v1, t1_v2, t1_v3, ..., tm_v1, tm_v2, tm_v3]
64  * numPoints - N
65  * numTriangles - M
66  * threadPool - default (inefficient)
67  */
68  GmBVHAcceleration(const double* triCoords, const int* triIndex, int numPoints, int numTriangles, bvh::ThreadPool threadPool = bvh::ThreadPool());
69 
70  /*
71  * Return true if the the segment given by 'start' and 'end'
72  * intersects any of the triangles and stores the intersection
73  * point at 'intersection'
74  */
75  bool segIntersection(const double* start, const double* end, RayIntersection& ri);
76 
77 private:
78 
79  void computeLinePoint(Vec3 p0, Vec3 dir, double t, double* out);
80 };
81 #endif
Definition: gmBVHAcceleration.h:31
Definition: gmBVHAcceleration.h:38