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> 87 return ((
k[0] == other[0]) && (
k[1] == other[1]) && (
k[2] == other[2]));
91 return( (
k[0] != other[0]) || (
k[1] != other[1]) || (
k[2] != other[2]) );
95 k[0] = other.
k[0];
k[1] = other.
k[1];
k[2] = other.
k[2];
115 return static_cast<size_t>(key.
k[0])
116 + 1447*static_cast<size_t>(key.
k[1])
117 + 345637*
static_cast<size_t>(key.
k[2]);
129 typedef unordered_ns::unordered_set<OcTreeKey, OcTreeKey::KeyHash>
KeySet;
136 typedef unordered_ns::unordered_map<OcTreeKey, bool, OcTreeKey::KeyHash>
KeyBoolMap;
149 size_t dSize = other.
end() - other.
begin();
150 end_of_ray = ray.begin() + dSize;
154 end_of_ray = begin();
158 assert(end_of_ray != ray.end());
163 size_t size()
const {
return end_of_ray - ray.begin(); }
170 iterator
begin() {
return ray.begin(); }
171 iterator
end() {
return end_of_ray; }
172 const_iterator
begin()
const {
return ray.begin(); }
173 const_iterator
end()
const {
return end_of_ray; }
175 reverse_iterator
rbegin() {
return (reverse_iterator) end_of_ray; }
176 reverse_iterator
rend() {
return ray.rend(); }
179 std::vector<OcTreeKey>
ray;
181 const static size_t maxSize = 100000;
196 if (pos & 1) child_key[0] = parent_key[0] + center_offset_key;
197 else child_key[0] = parent_key[0] - center_offset_key - (center_offset_key ? 0 : 1);
199 if (pos & 2) child_key[1] = parent_key[1] + center_offset_key;
200 else child_key[1] = parent_key[1] - center_offset_key - (center_offset_key ? 0 : 1);
202 if (pos & 4) child_key[2] = parent_key[2] + center_offset_key;
203 else child_key[2] = parent_key[2] - center_offset_key - (center_offset_key ? 0 : 1);
209 if (key.
k[0] & (1 << depth))
212 if (key.
k[1] & (1 << depth))
215 if (key.
k[2] & (1 << depth))
232 key_type mask = 65535 << level;
OcTreeKey(key_type a, key_type b, key_type c)
size_t operator()(const OcTreeKey &key) const
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
const_iterator begin() const
unordered_ns::unordered_map< OcTreeKey, bool, OcTreeKey::KeyHash > KeyBoolMap
bool operator==(const OcTreeKey &other) const
KeyRay(const KeyRay &other)
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
std::vector< OcTreeKey >::const_iterator const_iterator
const_iterator end() const
unordered_ns::unordered_set< OcTreeKey, OcTreeKey::KeyHash > KeySet
reverse_iterator rbegin()
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
const key_type & operator[](unsigned int i) const