34 #ifndef OCTOMAP_OCTREE_KEY_H 35 #define OCTOMAP_OCTREE_KEY_H 47 #if defined(__GNUC__) && ! defined(_LIBCPP_VERSION) 48 #include <tr1/unordered_set> 49 #include <tr1/unordered_map> 54 #include <unordered_set> 55 #include <unordered_map> 72 OcTreeKey (
unsigned short int a,
unsigned short int b,
unsigned short int c)
73 {
k[0] = a;
k[1] = b;
k[2] = c; }
75 k[0] = other.
k[0];
k[1] = other.
k[1];
k[2] = other.
k[2];
78 return ((
k[0] == other[0]) && (
k[1] == other[1]) && (
k[2] == other[2]));
81 return( (
k[0] != other[0]) || (
k[1] != other[1]) || (
k[2] != other[2]) );
84 k[0] = other.
k[0];
k[1] = other.
k[1];
k[2] = other.
k[2];
87 const unsigned short int&
operator[] (
unsigned int i)
const {
94 unsigned short int k[3];
102 return size_t(key.
k[0]) + 1447*size_t(key.
k[1]) + 345637*size_t(key.
k[2]);
114 typedef unordered_ns::unordered_set<OcTreeKey, OcTreeKey::KeyHash>
KeySet;
121 typedef unordered_ns::unordered_map<OcTreeKey, bool, OcTreeKey::KeyHash>
KeyBoolMap;
132 end_of_ray = begin();
135 assert(end_of_ray != ray.end());
140 size_t size()
const {
return end_of_ray - ray.begin(); }
147 iterator
begin() {
return ray.begin(); }
148 iterator
end() {
return end_of_ray; }
149 const_iterator
begin()
const {
return ray.begin(); }
150 const_iterator
end()
const {
return end_of_ray; }
152 reverse_iterator
rbegin() {
return (reverse_iterator) end_of_ray; }
153 reverse_iterator
rend() {
return ray.rend(); }
157 std::vector<OcTreeKey>
ray;
170 inline void computeChildKey (
const unsigned int& pos,
const unsigned short int& center_offset_key,
173 if (pos & 1) child_key[0] = parent_key[0] + center_offset_key;
174 else child_key[0] = parent_key[0] - center_offset_key - (center_offset_key ? 0 : 1);
176 if (pos & 2) child_key[1] = parent_key[1] + center_offset_key;
177 else child_key[1] = parent_key[1] - center_offset_key - (center_offset_key ? 0 : 1);
179 if (pos & 4) child_key[2] = parent_key[2] + center_offset_key;
180 else child_key[2] = parent_key[2] - center_offset_key - (center_offset_key ? 0 : 1);
185 unsigned char pos = 0;
186 if (key.
k[0] & (1 << depth)) pos += 1;
187 if (key.
k[1] & (1 << depth)) pos += 2;
188 if (key.
k[2] & (1 << depth)) pos += 4;
203 unsigned short int mask = 65535 << level;
Provides a hash function on Keys.
std::vector< OcTreeKey > ray
unsigned char computeChildIdx(const OcTreeKey &key, int depth)
generate child index (between 0 and 7) from key at given tree depth
bool operator!=(const OcTreeKey &other) const
OcTreeKey & operator=(const OcTreeKey &other)
std::vector< OcTreeKey >::iterator end_of_ray
unordered_ns::unordered_map< OcTreeKey, bool, OcTreeKey::KeyHash > KeyBoolMap
void computeChildKey(const unsigned int &pos, const unsigned short int ¢er_offset_key, const OcTreeKey &parent_key, OcTreeKey &child_key)
const_iterator begin() const
OcTreeKey(const OcTreeKey &other)
std::vector< OcTreeKey >::iterator iterator
size_t operator()(const OcTreeKey &key) const
const_iterator end() const
const unsigned short int & operator[](unsigned int i) const
std::vector< OcTreeKey >::const_iterator const_iterator
unordered_ns::unordered_set< OcTreeKey, OcTreeKey::KeyHash > KeySet
void addKey(OcTreeKey &k)
reverse_iterator rbegin()
bool operator==(const OcTreeKey &other) const
OcTreeKey(unsigned short int a, unsigned short int b, unsigned short int c)
std::vector< OcTreeKey >::reverse_iterator reverse_iterator
OcTreeKey computeIndexKey(unsigned short int level, const OcTreeKey &key)