#include <OcTreeBaseImpl.h>
Public Types | |
typedef leaf_iterator | iterator |
typedef NODE | NodeType |
Make the templated NODE type available from the outside. More... | |
Public Member Functions | |
OcTreeKey | adjustKeyAtDepth (const OcTreeKey &key, unsigned int depth) const |
unsigned short int | adjustKeyAtDepth (unsigned short int key, unsigned int depth) const |
iterator | begin (unsigned char maxDepth=0) const |
leaf_iterator | begin_leafs (unsigned char maxDepth=0) const |
leaf_bbx_iterator | begin_leafs_bbx (const OcTreeKey &min, const OcTreeKey &max, unsigned char maxDepth=0) const |
leaf_bbx_iterator | begin_leafs_bbx (const point3d &min, const point3d &max, unsigned char maxDepth=0) const |
tree_iterator | begin_tree (unsigned char maxDepth=0) const |
size_t | calcNumNodes () const |
Traverses the tree to calculate the total number of nodes. More... | |
void | clear () |
Deletes the complete tree structure. More... | |
bool | computeRay (const point3d &origin, const point3d &end, std::vector< point3d > &ray) |
bool | computeRayKeys (const point3d &origin, const point3d &end, KeyRay &ray) const |
unsigned short int | coordToKey (double coordinate) const |
Converts from a single coordinate into a discrete key. More... | |
unsigned short int | coordToKey (double coordinate, unsigned depth) const |
Converts from a single coordinate into a discrete key at a given depth. More... | |
OcTreeKey | coordToKey (const point3d &coord) const |
Converts from a 3D coordinate into a 3D addressing key. More... | |
OcTreeKey | coordToKey (double x, double y, double z) const |
Converts from a 3D coordinate into a 3D addressing key. More... | |
OcTreeKey | coordToKey (const point3d &coord, unsigned depth) const |
Converts from a 3D coordinate into a 3D addressing key at a given depth. More... | |
OcTreeKey | coordToKey (double x, double y, double z, unsigned depth) const |
Converts from a 3D coordinate into a 3D addressing key at a given depth. More... | |
bool | coordToKeyChecked (const point3d &coord, OcTreeKey &key) const |
bool | coordToKeyChecked (const point3d &coord, unsigned depth, OcTreeKey &key) const |
bool | coordToKeyChecked (double x, double y, double z, OcTreeKey &key) const |
bool | coordToKeyChecked (double x, double y, double z, unsigned depth, OcTreeKey &key) const |
bool | coordToKeyChecked (double coordinate, unsigned short int &key) const |
bool | coordToKeyChecked (double coordinate, unsigned depth, unsigned short int &key) const |
bool | deleteNode (double x, double y, double z, unsigned int depth=0) |
bool | deleteNode (const point3d &value, unsigned int depth=0) |
bool | deleteNode (const OcTreeKey &key, unsigned int depth=0) |
const iterator | end () const |
const leaf_iterator | end_leafs () const |
const leaf_bbx_iterator | end_leafs_bbx () const |
const tree_iterator | end_tree () const |
virtual void | expand () |
virtual void | getMetricMax (double &x, double &y, double &z) |
maximum value of the bounding box of all known space in x, y, z More... | |
void | getMetricMax (double &x, double &y, double &z) const |
maximum value of the bounding box of all known space in x, y, z More... | |
virtual void | getMetricMin (double &x, double &y, double &z) |
minimum value of the bounding box of all known space in x, y, z More... | |
void | getMetricMin (double &x, double &y, double &z) const |
minimum value of the bounding box of all known space in x, y, z More... | |
virtual void | getMetricSize (double &x, double &y, double &z) |
Size of OcTree (all known space) in meters for x, y and z dimension. More... | |
virtual void | getMetricSize (double &x, double &y, double &z) const |
Size of OcTree (all known space) in meters for x, y and z dimension. More... | |
double | getNodeSize (unsigned depth) const |
size_t | getNumLeafNodes () const |
Traverses the tree to calculate the total number of leaf nodes. More... | |
double | getResolution () const |
NODE * | getRoot () const |
unsigned int | getTreeDepth () const |
std::string | getTreeType () const |
void | getUnknownLeafCenters (point3d_list &node_centers, point3d pmin, point3d pmax, unsigned int depth=0) const |
return centers of leafs that do NOT exist (but could) in a given bounding box More... | |
double | keyToCoord (unsigned short int key, unsigned depth) const |
double | keyToCoord (unsigned short int key) const |
point3d | keyToCoord (const OcTreeKey &key) const |
point3d | keyToCoord (const OcTreeKey &key, unsigned depth) const |
unsigned long long | memoryFullGrid () const |
virtual size_t | memoryUsage () const |
virtual size_t | memoryUsageNode () const |
OcTreeBaseImpl (double resolution) | |
OcTreeBaseImpl (const OcTreeBaseImpl< NODE, INTERFACE > &rhs) | |
Deep copy constructor. More... | |
bool | operator== (const OcTreeBaseImpl< NODE, INTERFACE > &rhs) const |
virtual void | prune () |
std::istream & | readData (std::istream &s) |
NODE * | search (double x, double y, double z, unsigned int depth=0) const |
NODE * | search (const point3d &value, unsigned int depth=0) const |
NODE * | search (const OcTreeKey &key, unsigned int depth=0) const |
void | setResolution (double r) |
virtual size_t | size () const |
void | swapContent (OcTreeBaseImpl< NODE, INTERFACE > &rhs) |
double | volume () |
std::ostream & | writeData (std::ostream &s) const |
virtual | ~OcTreeBaseImpl () |
Protected Member Functions | |
void | calcMinMax () |
recalculates min and max in x, y, z. Does nothing when tree size didn't change. More... | |
void | calcNumNodesRecurs (NODE *node, size_t &num_nodes) const |
bool | deleteNodeRecurs (NODE *node, unsigned int depth, unsigned int max_depth, const OcTreeKey &key) |
recursive call of deleteNode() More... | |
void | expandRecurs (NODE *node, unsigned int depth, unsigned int max_depth) |
recursive call of expand() More... | |
size_t | getNumLeafNodesRecurs (const NODE *parent) const |
void | init () |
initialize non-trivial members, helper for constructors More... | |
OcTreeBaseImpl (double resolution, unsigned int tree_depth, unsigned int tree_max_val) | |
void | pruneRecurs (NODE *node, unsigned int depth, unsigned int max_depth, unsigned int &num_pruned) |
recursive call of prune() More... | |
Protected Attributes | |
std::vector< KeyRay > | keyrays |
data structure for ray casting, array for multithreading More... | |
const leaf_bbx_iterator | leaf_iterator_bbx_end |
const leaf_iterator | leaf_iterator_end |
double | max_value [3] |
max in x, y, z More... | |
double | min_value [3] |
double | resolution |
in meters More... | |
double | resolution_factor |
= 1. / resolution More... | |
NODE * | root |
Pointer to the root NODE, NULL for empty tree. More... | |
bool | size_changed |
flag to denote whether the octree extent changed (for lazy min/max eval) More... | |
std::vector< double > | sizeLookupTable |
contains the size of a voxel at level i (0: root node). tree_depth+1 levels (incl. 0) More... | |
point3d | tree_center |
const unsigned int | tree_depth |
Maximum tree depth is fixed to 16 currently. More... | |
const tree_iterator | tree_iterator_end |
const unsigned int | tree_max_val |
size_t | tree_size |
Private Member Functions | |
OcTreeBaseImpl< NODE, INTERFACE > & | operator= (const OcTreeBaseImpl< NODE, INTERFACE > &) |
OcTree base class, to be used with with any kind of OcTreeDataNode.
This tree implementation currently has a maximum depth of 16 nodes. For this reason, coordinates values have to be, e.g., below +/- 327.68 meters (2^15) at a maximum resolution of 0.01m.
This limitation enables the use of an efficient key generation method which uses the binary representation of the data point coordinates.
NODE | Node class to be used in tree (usually derived from OcTreeDataNode) |
INTERFACE | Interface to be derived from, should be either AbstractOcTree or AbstractOccupancyOcTree |
Definition at line 72 of file OcTreeBaseImpl.h.
typedef leaf_iterator octomap::OcTreeBaseImpl< NODE, INTERFACE >::iterator |
Definition at line 262 of file OcTreeBaseImpl.h.
typedef NODE octomap::OcTreeBaseImpl< NODE, INTERFACE >::NodeType |
Make the templated NODE type available from the outside.
Definition at line 76 of file OcTreeBaseImpl.h.
octomap::OcTreeBaseImpl< NODE, INTERFACE >::OcTreeBaseImpl | ( | double | resolution | ) |
|
virtual |
octomap::OcTreeBaseImpl< NODE, INTERFACE >::OcTreeBaseImpl | ( | const OcTreeBaseImpl< NODE, INTERFACE > & | rhs | ) |
Deep copy constructor.
|
protected |
Constructor to enable derived classes to change tree constants. This usually requires a re-implementation of some core tree-traversal functions as well!
|
inline |
Adjusts a 3D key from the lowest level to correspond to a higher depth (by shifting the key values)
key | Input key, at the lowest tree level |
depth | Target depth level for the new key |
Definition at line 337 of file OcTreeBaseImpl.h.
unsigned short int octomap::OcTreeBaseImpl< NODE, INTERFACE >::adjustKeyAtDepth | ( | unsigned short int | key, |
unsigned int | depth | ||
) | const |
Adjusts a single key value from the lowest level to correspond to a higher depth (by shifting the key value)
key | Input key, at the lowest tree level |
depth | Target depth level for the new key |
|
inline |
Definition at line 265 of file OcTreeBaseImpl.h.
|
inline |
Definition at line 270 of file OcTreeBaseImpl.h.
|
inline |
Definition at line 275 of file OcTreeBaseImpl.h.
|
inline |
Definition at line 279 of file OcTreeBaseImpl.h.
|
inline |
Definition at line 286 of file OcTreeBaseImpl.h.
|
protected |
recalculates min and max in x, y, z. Does nothing when tree size didn't change.
size_t octomap::OcTreeBaseImpl< NODE, INTERFACE >::calcNumNodes | ( | ) | const |
Traverses the tree to calculate the total number of nodes.
|
protected |
void octomap::OcTreeBaseImpl< NODE, INTERFACE >::clear | ( | ) |
Deletes the complete tree structure.
bool octomap::OcTreeBaseImpl< NODE, INTERFACE >::computeRay | ( | const point3d & | origin, |
const point3d & | end, | ||
std::vector< point3d > & | ray | ||
) |
Traces a ray from origin to end (excluding), returning the coordinates of all nodes traversed by the beam. You still need to check if a node at that coordinate exists (e.g. with search()).
origin | start coordinate of ray |
end | end coordinate of ray |
ray | KeyRay structure that holds the keys of all nodes traversed by the ray, excluding "end" |
bool octomap::OcTreeBaseImpl< NODE, INTERFACE >::computeRayKeys | ( | const point3d & | origin, |
const point3d & | end, | ||
KeyRay & | ray | ||
) | const |
Traces a ray from origin to end (excluding), returning an OcTreeKey of all nodes traversed by the beam. You still need to check if a node at that coordinate exists (e.g. with search()).
origin | start coordinate of ray |
end | end coordinate of ray |
ray | KeyRay structure that holds the keys of all nodes traversed by the ray, excluding "end" |
|
inline |
Converts from a single coordinate into a discrete key.
Definition at line 295 of file OcTreeBaseImpl.h.
unsigned short int octomap::OcTreeBaseImpl< NODE, INTERFACE >::coordToKey | ( | double | coordinate, |
unsigned | depth | ||
) | const |
Converts from a single coordinate into a discrete key at a given depth.
|
inline |
Converts from a 3D coordinate into a 3D addressing key.
Definition at line 304 of file OcTreeBaseImpl.h.
|
inline |
Converts from a 3D coordinate into a 3D addressing key.
Definition at line 309 of file OcTreeBaseImpl.h.
|
inline |
Converts from a 3D coordinate into a 3D addressing key at a given depth.
Definition at line 314 of file OcTreeBaseImpl.h.
|
inline |
Converts from a 3D coordinate into a 3D addressing key at a given depth.
Definition at line 322 of file OcTreeBaseImpl.h.
bool octomap::OcTreeBaseImpl< NODE, INTERFACE >::coordToKeyChecked | ( | const point3d & | coord, |
OcTreeKey & | key | ||
) | const |
Converts a 3D coordinate into a 3D OcTreeKey, with boundary checking.
coord | 3d coordinate of a point |
key | values that will be computed, an array of fixed size 3. |
bool octomap::OcTreeBaseImpl< NODE, INTERFACE >::coordToKeyChecked | ( | const point3d & | coord, |
unsigned | depth, | ||
OcTreeKey & | key | ||
) | const |
Converts a 3D coordinate into a 3D OcTreeKey at a certain depth, with boundary checking.
coord | 3d coordinate of a point |
depth | level of the key from the top |
key | values that will be computed, an array of fixed size 3. |
bool octomap::OcTreeBaseImpl< NODE, INTERFACE >::coordToKeyChecked | ( | double | x, |
double | y, | ||
double | z, | ||
OcTreeKey & | key | ||
) | const |
Converts a 3D coordinate into a 3D OcTreeKey, with boundary checking.
x | |
y | |
z | |
key | values that will be computed, an array of fixed size 3. |
bool octomap::OcTreeBaseImpl< NODE, INTERFACE >::coordToKeyChecked | ( | double | x, |
double | y, | ||
double | z, | ||
unsigned | depth, | ||
OcTreeKey & | key | ||
) | const |
Converts a 3D coordinate into a 3D OcTreeKey at a certain depth, with boundary checking.
x | |
y | |
z | |
depth | level of the key from the top |
key | values that will be computed, an array of fixed size 3. |
bool octomap::OcTreeBaseImpl< NODE, INTERFACE >::coordToKeyChecked | ( | double | coordinate, |
unsigned short int & | key | ||
) | const |
Converts a single coordinate into a discrete addressing key, with boundary checking.
coordinate | 3d coordinate of a point |
key | discrete 16 bit adressing key, result |
bool octomap::OcTreeBaseImpl< NODE, INTERFACE >::coordToKeyChecked | ( | double | coordinate, |
unsigned | depth, | ||
unsigned short int & | key | ||
) | const |
Converts a single coordinate into a discrete addressing key, with boundary checking.
coordinate | 3d coordinate of a point |
depth | level of the key from the top |
key | discrete 16 bit adressing key, result |
bool octomap::OcTreeBaseImpl< NODE, INTERFACE >::deleteNode | ( | double | x, |
double | y, | ||
double | z, | ||
unsigned int | depth = 0 |
||
) |
Delete a node (if exists) given a 3d point. Will always delete at the lowest level unless depth !=0, and expand pruned inner nodes as needed. Pruned nodes at level "depth" will directly be deleted as a whole.
bool octomap::OcTreeBaseImpl< NODE, INTERFACE >::deleteNode | ( | const point3d & | value, |
unsigned int | depth = 0 |
||
) |
Delete a node (if exists) given a 3d point. Will always delete at the lowest level unless depth !=0, and expand pruned inner nodes as needed. Pruned nodes at level "depth" will directly be deleted as a whole.
bool octomap::OcTreeBaseImpl< NODE, INTERFACE >::deleteNode | ( | const OcTreeKey & | key, |
unsigned int | depth = 0 |
||
) |
Delete a node (if exists) given an addressing key. Will always delete at the lowest level unless depth !=0, and expand pruned inner nodes as needed. Pruned nodes at level "depth" will directly be deleted as a whole.
|
protected |
recursive call of deleteNode()
|
inline |
Definition at line 267 of file OcTreeBaseImpl.h.
|
inline |
Definition at line 272 of file OcTreeBaseImpl.h.
|
inline |
Definition at line 283 of file OcTreeBaseImpl.h.
|
inline |
Definition at line 288 of file OcTreeBaseImpl.h.
|
virtual |
Expands all pruned nodes (reverse of prune())
|
protected |
recursive call of expand()
|
virtual |
maximum value of the bounding box of all known space in x, y, z
void octomap::OcTreeBaseImpl< NODE, INTERFACE >::getMetricMax | ( | double & | x, |
double & | y, | ||
double & | z | ||
) | const |
maximum value of the bounding box of all known space in x, y, z
|
virtual |
minimum value of the bounding box of all known space in x, y, z
void octomap::OcTreeBaseImpl< NODE, INTERFACE >::getMetricMin | ( | double & | x, |
double & | y, | ||
double & | z | ||
) | const |
minimum value of the bounding box of all known space in x, y, z
|
virtual |
Size of OcTree (all known space) in meters for x, y and z dimension.
|
virtual |
Size of OcTree (all known space) in meters for x, y and z dimension.
|
inline |
Definition at line 110 of file OcTreeBaseImpl.h.
size_t octomap::OcTreeBaseImpl< NODE, INTERFACE >::getNumLeafNodes | ( | ) | const |
Traverses the tree to calculate the total number of leaf nodes.
|
protected |
|
inline |
Definition at line 106 of file OcTreeBaseImpl.h.
|
inline |
Definition at line 117 of file OcTreeBaseImpl.h.
|
inline |
Definition at line 108 of file OcTreeBaseImpl.h.
|
inline |
Definition at line 101 of file OcTreeBaseImpl.h.
void octomap::OcTreeBaseImpl< NODE, INTERFACE >::getUnknownLeafCenters | ( | point3d_list & | node_centers, |
point3d | pmin, | ||
point3d | pmax, | ||
unsigned int | depth = 0 |
||
) | const |
return centers of leafs that do NOT exist (but could) in a given bounding box
|
protected |
initialize non-trivial members, helper for constructors
double octomap::OcTreeBaseImpl< NODE, INTERFACE >::keyToCoord | ( | unsigned short int | key, |
unsigned | depth | ||
) | const |
converts from a discrete key at a given depth into a coordinate corresponding to the key's center
|
inline |
converts from a discrete key at the lowest tree level into a coordinate corresponding to the key's center
Definition at line 422 of file OcTreeBaseImpl.h.
|
inline |
converts from an addressing key at the lowest tree level into a coordinate corresponding to the key's center
Definition at line 428 of file OcTreeBaseImpl.h.
|
inline |
converts from an addressing key at a given depth into a coordinate corresponding to the key's center
Definition at line 434 of file OcTreeBaseImpl.h.
unsigned long long octomap::OcTreeBaseImpl< NODE, INTERFACE >::memoryFullGrid | ( | ) | const |
|
virtual |
|
inlinevirtual |
Definition at line 185 of file OcTreeBaseImpl.h.
|
private |
Assignment operator is private: don't (re-)assign octrees (const-parameters can't be changed) - use the copy constructor instead.
bool octomap::OcTreeBaseImpl< NODE, INTERFACE >::operator== | ( | const OcTreeBaseImpl< NODE, INTERFACE > & | rhs | ) | const |
Comparison between two octrees, all meta data, all nodes, and the structure must be identical
|
virtual |
Lossless compression of the octree: A node will replace all of its eight children if they have identical values. You usually don't have to call prune() after a regular occupancy update, updateNode() incrementally prunes all affected nodes.
|
protected |
recursive call of prune()
std::istream& octomap::OcTreeBaseImpl< NODE, INTERFACE >::readData | ( | std::istream & | s | ) |
Read all nodes from the input stream (without file header), for this the tree needs to be already created. For general file IO, you should probably use AbstractOcTree::read() instead.
NODE* octomap::OcTreeBaseImpl< NODE, INTERFACE >::search | ( | double | x, |
double | y, | ||
double | z, | ||
unsigned int | depth = 0 |
||
) | const |
Search node at specified depth given a 3d point (depth=0: search full tree depth). You need to check if the returned node is NULL, since it can be in unknown space.
NODE* octomap::OcTreeBaseImpl< NODE, INTERFACE >::search | ( | const point3d & | value, |
unsigned int | depth = 0 |
||
) | const |
Search node at specified depth given a 3d point (depth=0: search full tree depth) You need to check if the returned node is NULL, since it can be in unknown space.
NODE* octomap::OcTreeBaseImpl< NODE, INTERFACE >::search | ( | const OcTreeKey & | key, |
unsigned int | depth = 0 |
||
) | const |
Search a node at specified depth given an addressing key (depth=0: search full tree depth) You need to check if the returned node is NULL, since it can be in unknown space.
void octomap::OcTreeBaseImpl< NODE, INTERFACE >::setResolution | ( | double | r | ) |
Change the resolution of the octree, scaling all voxels. This will not preserve the (metric) scale!
|
inlinevirtual |
Definition at line 179 of file OcTreeBaseImpl.h.
void octomap::OcTreeBaseImpl< NODE, INTERFACE >::swapContent | ( | OcTreeBaseImpl< NODE, INTERFACE > & | rhs | ) |
Swap contents of two octrees, i.e., only the underlying pointer / tree structure. You have to ensure yourself that the metadata (resolution etc) matches. No memory is cleared in this function
double octomap::OcTreeBaseImpl< NODE, INTERFACE >::volume | ( | ) |
std::ostream& octomap::OcTreeBaseImpl< NODE, INTERFACE >::writeData | ( | std::ostream & | s | ) | const |
Write complete state of tree to stream (without file header) unmodified. Pruning the tree first produces smaller files (lossless compression)
|
protected |
data structure for ray casting, array for multithreading
Definition at line 489 of file OcTreeBaseImpl.h.
|
protected |
Definition at line 492 of file OcTreeBaseImpl.h.
|
protected |
Definition at line 491 of file OcTreeBaseImpl.h.
|
protected |
max in x, y, z
Definition at line 483 of file OcTreeBaseImpl.h.
|
protected |
min in x, y, z
Definition at line 484 of file OcTreeBaseImpl.h.
|
protected |
in meters
Definition at line 474 of file OcTreeBaseImpl.h.
|
protected |
= 1. / resolution
Definition at line 475 of file OcTreeBaseImpl.h.
|
protected |
Pointer to the root NODE, NULL for empty tree.
Definition at line 469 of file OcTreeBaseImpl.h.
|
protected |
flag to denote whether the octree extent changed (for lazy min/max eval)
Definition at line 479 of file OcTreeBaseImpl.h.
|
protected |
contains the size of a voxel at level i (0: root node). tree_depth+1 levels (incl. 0)
Definition at line 486 of file OcTreeBaseImpl.h.
|
protected |
Definition at line 481 of file OcTreeBaseImpl.h.
|
protected |
Maximum tree depth is fixed to 16 currently.
Definition at line 472 of file OcTreeBaseImpl.h.
|
protected |
Definition at line 493 of file OcTreeBaseImpl.h.
|
protected |
Definition at line 473 of file OcTreeBaseImpl.h.
|
protected |
number of nodes in tree
Definition at line 477 of file OcTreeBaseImpl.h.