Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef PCL_OCTREE_KEY_H
00039 #define PCL_OCTREE_KEY_H
00040
00041 #include <string>
00042
00043 namespace pcl
00044 {
00045 namespace octree
00046 {
00048
00052
00053 class OctreeKey
00054 {
00055 public:
00056
00058 OctreeKey () :
00059 x (0), y (0), z (0)
00060 {
00061 }
00062
00064 OctreeKey (unsigned int keyX, unsigned int keyY, unsigned int keyZ) :
00065 x (keyX), y (keyY), z (keyZ)
00066 {
00067 }
00068
00070 OctreeKey (const OctreeKey& source)
00071 {
00072 memcpy(key_, source.key_, sizeof(key_));
00073 }
00074
00078 bool
00079 operator == (const OctreeKey& b) const
00080 {
00081 return ((b.x == this->x) && (b.y == this->y) && (b.z == this->z));
00082 }
00083
00087 bool
00088 operator <= (const OctreeKey& b) const
00089 {
00090 return ((b.x >= this->x) && (b.y >= this->y) && (b.z >= this->z));
00091 }
00092
00096 bool
00097 operator >= (const OctreeKey& b) const
00098 {
00099 return ((b.x <= this->x) && (b.y <= this->y) && (b.z <= this->z));
00100 }
00101
00105 inline void
00106 pushBranch (unsigned char childIndex)
00107 {
00108 this->x = (this->x << 1) | (!!(childIndex & (1 << 2)));
00109 this->y = (this->y << 1) | (!!(childIndex & (1 << 1)));
00110 this->z = (this->z << 1) | (!!(childIndex & (1 << 0)));
00111 }
00112
00115 inline void
00116 popBranch ()
00117 {
00118 this->x >>= 1;
00119 this->y >>= 1;
00120 this->z >>= 1;
00121 }
00122
00127 inline unsigned char
00128 getChildIdxWithDepthMask (unsigned int depthMask) const
00129 {
00130 return static_cast<unsigned char> (((!!(this->x & depthMask)) << 2)
00131 | ((!!(this->y & depthMask)) << 1)
00132 | (!!(this->z & depthMask)));
00133 }
00134
00135
00136 static const unsigned char maxDepth = static_cast<const unsigned char>(sizeof(uint32_t)*8);
00137
00138
00139
00140 union
00141 {
00142 struct
00143 {
00144 uint32_t x;
00145 uint32_t y;
00146 uint32_t z;
00147 };
00148 uint32_t key_[3];
00149 };
00150
00151
00152 };
00153 }
00154 }
00155
00156 #endif