Commit fddfdc023620acde6c004027e7e8a8e8914596ef

Authored by David Mayerich
1 parent 55417e1e

fixed aabb errors

stim/math/vec3.h
... ... @@ -243,7 +243,7 @@ public:
243 243 return false;
244 244 }
245 245  
246   -//#ifndef __NVCC__
  246 +#ifndef __NVCC__
247 247 /// Outputs the vector as a string
248 248 std::string str() const{
249 249 std::stringstream ss;
... ... @@ -261,7 +261,7 @@ public:
261 261  
262 262 return ss.str();
263 263 }
264   -//#endif
  264 +#endif
265 265  
266 266 size_t size(){ return 3; }
267 267  
... ...
stim/visualization/aabb3.h
... ... @@ -6,14 +6,14 @@
6 6  
7 7 namespace stim{
8 8  
9   - template<typename T>
10   - using aabb3 = aabbn<T, 3>;
11   -/*/// Structure for a 3D axis aligned bounding box
  9 + //template<typename T>
  10 + //using aabb3 = aabbn<T, 3>;
  11 +/// Structure for a 3D axis aligned bounding box
12 12 template<typename T>
13 13 struct aabb3 : public aabbn<T, 3>{
14 14  
15   - aabb3() : aabbn() {}
16   - aabb3(T x0, T y0, T z0, T x1, T y1, T z1){
  15 + CUDA_CALLABLE aabb3() : aabbn() {}
  16 + CUDA_CALLABLE aabb3(T x0, T y0, T z0, T x1, T y1, T z1){
17 17 low[0] = x0;
18 18 low[1] = y0;
19 19 low[2] = z0;
... ... @@ -22,11 +22,39 @@ struct aabb3 : public aabbn&lt;T, 3&gt;{
22 22 high[2] = x2;
23 23 }
24 24  
25   - aabb3 aabbn<T, 3>() {
  25 + CUDA_CALLABLE aabb3(T x, T y, T z) {
  26 + low[0] = high[0] = x;
  27 + low[1] = high[1] = y;
  28 + low[2] = high[2] = z;
  29 + }
  30 +
  31 + CUDA_CALLABLE void insert(T x, T y, T z) {
  32 + T p[3];
  33 + p[0] = x;
  34 + p[1] = y;
  35 + p[2] = z;
  36 + aabbn<T, 3>::insert(p);
  37 + }
26 38  
  39 + CUDA_CALLABLE void trim_low(T x, T y, T z) {
  40 + T p[3];
  41 + p[0] = x;
  42 + p[1] = y;
  43 + p[2] = z;
  44 + aabbn<T, 3>::trim_low(p);
27 45 }
28 46  
29   -};*/
  47 + CUDA_CALLABLE void trim_high(T x, T y, T z) {
  48 + T p[3];
  49 + p[0] = x;
  50 + p[1] = y;
  51 + p[2] = z;
  52 + aabbn<T, 3>::trim_high(p);
  53 + }
  54 +
  55 +
  56 +
  57 +};
30 58  
31 59 }
32 60  
... ...
stim/visualization/aabbn.h
... ... @@ -25,26 +25,58 @@ struct aabbn{
25 25 init(i);
26 26 }
27 27  
  28 + /// For even inputs to the constructor, the input could be one point or a set of pairs of points
28 29 CUDA_CALLABLE aabbn(T x0, T x1) {
29   - low[0] = x0;
30   - high[0] = x1;
  30 + if (D == 1) {
  31 + low[0] = x0;
  32 + high[0] = x1;
  33 + }
  34 + else if (D == 2) {
  35 + low[0] = high[0] = x0;
  36 + low[1] = high[1] = x1;
  37 + }
31 38 }
32 39  
  40 + /// In the case of 3 inputs, this must be a 3D bounding box, so initialize to a box of size 0 at (x, y, z)
  41 + /*CUDA_CALLABLE aabbn(T x, T y, T z) {
  42 + low[0] = high[0] = x;
  43 + low[1] = high[1] = y;
  44 + low[2] = high[2] = z;
  45 + }*/
  46 +
33 47 CUDA_CALLABLE aabbn(T x0, T y0, T x1, T y1) {
34   - low[0] = x0;
35   - high[0] = x1;
36   - low[1] = y0;
37   - high[1] = y1;
  48 + if (D == 2) {
  49 + low[0] = x0;
  50 + high[0] = x1;
  51 + low[1] = y0;
  52 + high[1] = y1;
  53 + }
  54 + else if(D == 4){
  55 + low[0] = high[0] = x0;
  56 + low[1] = high[1] = y0;
  57 + low[2] = high[2] = x1;
  58 + low[3] = high[3] = y1;
  59 + }
38 60 }
39 61  
40   - CUDA_CALLABLE aabbn(T x0, T y0, T z0, T x1, T y1, T z1) {
41   - low[0] = x0;
42   - high[0] = x1;
43   - low[1] = y0;
44   - high[1] = y1;
45   - low[2] = z0;
46   - high[2] = z1;
47   - }
  62 + /*CUDA_CALLABLE aabbn(T x0, T y0, T z0, T x1, T y1, T z1) {
  63 + if (D == 3) {
  64 + low[0] = x0;
  65 + high[0] = x1;
  66 + low[1] = y0;
  67 + high[1] = y1;
  68 + low[2] = z0;
  69 + high[2] = z1;
  70 + }
  71 + else if (D == 6) {
  72 + low[0] = high[0] = x0;
  73 + low[1] = high[1] = y0;
  74 + low[2] = high[2] = z0;
  75 + low[3] = high[3] = x1;
  76 + low[4] = high[4] = y1;
  77 + low[5] = high[5] = z1;
  78 + }
  79 + }*/
48 80  
49 81  
50 82 //insert a point into the bounding box, growing the box appropriately
... ...