Commit 37c7ea8ca31a3c3a8690ecdf3880b1696119223b

Authored by Laila Saadatifard
1 parent ca99f951

upload the aabb3.h function to the visualization

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