From fddfdc023620acde6c004027e7e8a8e8914596ef Mon Sep 17 00:00:00 2001 From: David Mayerich Date: Tue, 14 Mar 2017 10:27:13 -0500 Subject: [PATCH] fixed aabb errors --- stim/math/vec3.h | 4 ++-- stim/visualization/aabb3.h | 42 +++++++++++++++++++++++++++++++++++------- stim/visualization/aabbn.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++-------------- 3 files changed, 83 insertions(+), 23 deletions(-) diff --git a/stim/math/vec3.h b/stim/math/vec3.h index 752b094..457092f 100644 --- a/stim/math/vec3.h +++ b/stim/math/vec3.h @@ -243,7 +243,7 @@ public: return false; } -//#ifndef __NVCC__ +#ifndef __NVCC__ /// Outputs the vector as a string std::string str() const{ std::stringstream ss; @@ -261,7 +261,7 @@ public: return ss.str(); } -//#endif +#endif size_t size(){ return 3; } diff --git a/stim/visualization/aabb3.h b/stim/visualization/aabb3.h index c171281..84acb37 100644 --- a/stim/visualization/aabb3.h +++ b/stim/visualization/aabb3.h @@ -6,14 +6,14 @@ namespace stim{ - template - using aabb3 = aabbn; -/*/// Structure for a 3D axis aligned bounding box + //template + //using aabb3 = aabbn; +/// Structure for a 3D axis aligned bounding box template struct aabb3 : public aabbn{ - aabb3() : aabbn() {} - aabb3(T x0, T y0, T z0, T x1, T y1, T z1){ + CUDA_CALLABLE aabb3() : aabbn() {} + CUDA_CALLABLE aabb3(T x0, T y0, T z0, T x1, T y1, T z1){ low[0] = x0; low[1] = y0; low[2] = z0; @@ -22,11 +22,39 @@ struct aabb3 : public aabbn{ high[2] = x2; } - aabb3 aabbn() { + CUDA_CALLABLE aabb3(T x, T y, T z) { + low[0] = high[0] = x; + low[1] = high[1] = y; + low[2] = high[2] = z; + } + + CUDA_CALLABLE void insert(T x, T y, T z) { + T p[3]; + p[0] = x; + p[1] = y; + p[2] = z; + aabbn::insert(p); + } + CUDA_CALLABLE void trim_low(T x, T y, T z) { + T p[3]; + p[0] = x; + p[1] = y; + p[2] = z; + aabbn::trim_low(p); } -};*/ + CUDA_CALLABLE void trim_high(T x, T y, T z) { + T p[3]; + p[0] = x; + p[1] = y; + p[2] = z; + aabbn::trim_high(p); + } + + + +}; } diff --git a/stim/visualization/aabbn.h b/stim/visualization/aabbn.h index 329ae42..3a0d7f2 100644 --- a/stim/visualization/aabbn.h +++ b/stim/visualization/aabbn.h @@ -25,26 +25,58 @@ struct aabbn{ init(i); } + /// For even inputs to the constructor, the input could be one point or a set of pairs of points CUDA_CALLABLE aabbn(T x0, T x1) { - low[0] = x0; - high[0] = x1; + if (D == 1) { + low[0] = x0; + high[0] = x1; + } + else if (D == 2) { + low[0] = high[0] = x0; + low[1] = high[1] = x1; + } } + /// 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) + /*CUDA_CALLABLE aabbn(T x, T y, T z) { + low[0] = high[0] = x; + low[1] = high[1] = y; + low[2] = high[2] = z; + }*/ + CUDA_CALLABLE aabbn(T x0, T y0, T x1, T y1) { - low[0] = x0; - high[0] = x1; - low[1] = y0; - high[1] = y1; + if (D == 2) { + low[0] = x0; + high[0] = x1; + low[1] = y0; + high[1] = y1; + } + else if(D == 4){ + low[0] = high[0] = x0; + low[1] = high[1] = y0; + low[2] = high[2] = x1; + low[3] = high[3] = y1; + } } - CUDA_CALLABLE aabbn(T x0, T y0, T z0, T x1, T y1, T z1) { - low[0] = x0; - high[0] = x1; - low[1] = y0; - high[1] = y1; - low[2] = z0; - high[2] = z1; - } + /*CUDA_CALLABLE aabbn(T x0, T y0, T z0, T x1, T y1, T z1) { + if (D == 3) { + low[0] = x0; + high[0] = x1; + low[1] = y0; + high[1] = y1; + low[2] = z0; + high[2] = z1; + } + else if (D == 6) { + low[0] = high[0] = x0; + low[1] = high[1] = y0; + low[2] = high[2] = z0; + low[3] = high[3] = x1; + low[4] = high[4] = y1; + low[5] = high[5] = z1; + } + }*/ //insert a point into the bounding box, growing the box appropriately -- libgit2 0.21.4