本文主要是介绍《PCL》octree_key.h,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
int 占据 2 byte 即 8 bit
故:1 为 0000001
Octree key :包含每个坐标轴的整数索引,以便寻找八叉树叶节点。
namespace pcl
{namespace octree{class OctreeKey{public:OctreeKey () : x (0), y (0), z (0){ }OctreeKey (unsigned int keyX, unsigned int keyY, unsigned int keyZ) :x (keyX), y (keyY), z (keyZ){ }OctreeKey (const OctreeKey& source){memcpy(key_, source.key_, sizeof(key_));}/// brief运算符==用于比较八叉树键。如果叶节点索引相同则返回“true”; 否则“假”。booloperator == (const OctreeKey& b) const{return ((b.x == this->x) && (b.y == this->y) && (b.z == this->z));}/// brief运算符<=用于比较八叉树键。/// 如果 key indices不大于b的 key indices,则返回“true”; 否则“假”。booloperator <= (const OctreeKey& b) const{return ((b.x >= this->x) && (b.y >= this->y) && (b.z >= this->z));}/// brief运算符> =用于比较八叉树键。/// 如果 key indices不小于b的 key indices,则返回“true”; 否则“假”。booloperator >= (const OctreeKey& b) const{return ((b.x <= this->x) && (b.y <= this->y) && (b.z <= this->z));}/// 将子节点推送到八叉树键/// param [in] childIndex要添加的子节点索引(0-7)inline voidpushBranch (unsigned char childIndex){this->x = (this->x << 1) | (!!(childIndex & (1 << 2)));this->y = (this->y << 1) | (!!(childIndex & (1 << 1)));this->z = (this->z << 1) | (!!(childIndex & (1 << 0)));}/// 从八叉树 key 弹出子节点inline voidpopBranch (){this->x >>= 1;this->y >>= 1;this->z >>= 1;}/// 使用depthMask获取子节点索引/// param [in] depthMask 在查询深度处设置单 bit 的 bit mask (比特掩码)/// return子节点索引inline unsigned chargetChildIdxWithDepthMask (unsigned int depthMask) const{return static_cast<unsigned char> (((!!(this->x & depthMask)) << 2)| ((!!(this->y & depthMask)) << 1)| (!!(this->z & depthMask)));}/// 可以寻找的最大深度static const unsigned char maxDepth = static_cast<const unsigned char>(sizeof(uint32_t)*8);/// 寻找在 点(X, Y, Z)处体素的索引。union{struct{uint32_t x; /// typedef unsigned int uint32_t;uint32_t y;uint32_t z;};uint32_t key_[3];};};}
}
这篇关于《PCL》octree_key.h的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!