From 37c7ea8ca31a3c3a8690ecdf3880b1696119223b Mon Sep 17 00:00:00 2001 From: laila Saadatifard Date: Thu, 7 Jul 2016 10:48:51 -0500 Subject: [PATCH] upload the aabb3.h function to the visualization --- stim/visualization/aabb3.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+), 0 deletions(-) create mode 100644 stim/visualization/aabb3.h diff --git a/stim/visualization/aabb3.h b/stim/visualization/aabb3.h new file mode 100644 index 0000000..b21e786 --- /dev/null +++ b/stim/visualization/aabb3.h @@ -0,0 +1,54 @@ +#ifndef STIM_AABB3_H +#define STIM_AABB3_H + +#include + +namespace stim{ + +/// Structure for a 3D axis aligned bounding box +template +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 \ No newline at end of file -- libgit2 0.21.4