34 #ifndef OCTOMAP_OCTREE_KEY_H 35 #define OCTOMAP_OCTREE_KEY_H 48 #if defined(__GNUC__) && ! defined(_LIBCPP_VERSION) 49 #include <tr1/unordered_set> 50 #include <tr1/unordered_map> 55 #include <unordered_set> 56 #include <unordered_map> 88 return ((
k[0] == other[0]) && (
k[1] == other[1]) && (
k[2] == other[2]));
92 return( (
k[0] != other[0]) || (
k[1] != other[1]) || (
k[2] != other[2]) );
96 k[0] = other.
k[0];
k[1] = other.
k[1];
k[2] = other.
k[2];
116 return size_t(key.
k[0]) + 1447*size_t(key.
k[1]) + 345637*size_t(key.
k[2]);
128 typedef unordered_ns::unordered_set<OcTreeKey, OcTreeKey::KeyHash>
KeySet;
135 typedef unordered_ns::unordered_map<OcTreeKey, bool, OcTreeKey::KeyHash>
KeyBoolMap;
148 size_t dSize = other.
end() - other.
begin();
149 end_of_ray = ray.begin() + dSize;
153 end_of_ray = begin();
157 assert(end_of_ray != ray.end());
162 size_t size()
const {
return end_of_ray - ray.begin(); }
169 iterator
begin() {
return ray.begin(); }
170 iterator
end() {
return end_of_ray; }
171 const_iterator
begin()
const {
return ray.begin(); }
172 const_iterator
end()
const {
return end_of_ray; }
174 reverse_iterator
rbegin() {
return (reverse_iterator) end_of_ray; }
175 reverse_iterator
rend() {
return ray.rend(); }
178 std::vector<OcTreeKey>
ray;
180 const static size_t maxSize = 100000;
195 if (pos & 1) child_key[0] = parent_key[0] + center_offset_key;
196 else child_key[0] = parent_key[0] - center_offset_key - (center_offset_key ? 0 : 1);
198 if (pos & 2) child_key[1] = parent_key[1] + center_offset_key;
199 else child_key[1] = parent_key[1] - center_offset_key - (center_offset_key ? 0 : 1);
201 if (pos & 4) child_key[2] = parent_key[2] + center_offset_key;
202 else child_key[2] = parent_key[2] - center_offset_key - (center_offset_key ? 0 : 1);
208 if (key.
k[0] & (1 << depth))
211 if (key.
k[1] & (1 << depth))
214 if (key.
k[2] & (1 << depth))
231 key_type mask = 65535 << level;
OcTreeKey(key_type a, key_type b, key_type c)
Provides a hash function on Keys.
std::vector< OcTreeKey > ray
bool operator!=(const OcTreeKey &other) const
void addKey(const OcTreeKey &k)
OcTreeKey & operator=(const OcTreeKey &other)
std::vector< OcTreeKey >::iterator end_of_ray
unordered_ns::unordered_map< OcTreeKey, bool, OcTreeKey::KeyHash > KeyBoolMap
const key_type & operator[](unsigned int i) const
KeyRay(const KeyRay &other)
const_iterator begin() const
OcTreeKey(const OcTreeKey &other)
std::vector< OcTreeKey >::iterator iterator
uint8_t computeChildIdx(const OcTreeKey &key, int depth)
generate child index (between 0 and 7) from key at given tree depth
size_t operator()(const OcTreeKey &key) const
const_iterator end() const
std::vector< OcTreeKey >::const_iterator const_iterator
unordered_ns::unordered_set< OcTreeKey, OcTreeKey::KeyHash > KeySet
reverse_iterator rbegin()
bool operator==(const OcTreeKey &other) const
void computeChildKey(unsigned int pos, key_type center_offset_key, const OcTreeKey &parent_key, OcTreeKey &child_key)
OcTreeKey computeIndexKey(key_type level, const OcTreeKey &key)
std::vector< OcTreeKey >::reverse_iterator reverse_iterator