Blame view

stim/visualization/aabb3.h 1.19 KB
37c7ea8c   Laila Saadatifard   upload the aabb3....
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  #ifndef STIM_AABB3_H
  #define STIM_AABB3_H
  
  #include <stim/cuda/cudatools/callable.h>
  
  namespace stim{
  
  /// Structure for a 3D axis aligned bounding box
  template<typename T>
  struct aabb3{
  
  //protected:
  
  	T low[3];						//top left corner position
  	T high[3];							//dimensions along x and y and z
  
  //public:
  
  	CUDA_CALLABLE aabb3(T x, T y, T z){					//initialize an axis aligned bounding box of size 0 at the given position
  		low[0] = high[0] = x;					//set the position to the user specified coordinates
  		low[1] = high[1] = y;
  		low[2] = high[2] = z;
  	}
  
  	//insert a point into the bounding box, growing the box appropriately
  	CUDA_CALLABLE void insert(T x, T y, T z){
  		if(x < low[0]) low[0] = x;
  		if(y < low[1]) low[1] = y;
  		if(z < low[2]) low[2] = z;
  
  		if(x > high[0]) high[0] = x;		
  		if(y > high[1]) high[1] = y;
  		if(z > high[2]) high[2] = z;
  	}
  
  	//trim the bounding box so that the lower bounds are (x, y, z)
  	CUDA_CALLABLE void trim_low(T x, T y, T z){
  		if(low[0] < x) low[0] = x;
  		if(low[1] < y) low[1] = y;
  		if(low[2] < z) low[2] = z;
  	}
  
  	CUDA_CALLABLE void trim_high(T x, T y, T z){
  		if(high[0] > x) high[0] = x;
  		if(high[1] > y) high[1] = y;
  		if(high[2] > z) high[2] = z;
  	}
  
  };
  
  }
  
  
  #endif