Public Member Functions | |
Octree (int size, const T &emptyValue=T(0)) | |
Octree (const Octree< T, AS > &o) | |
~Octree () | |
int | size () const |
const T & | emptyValue () const |
unsigned long | bytes () const |
int | nodes () const |
int | nodesAtSize (int size) const |
void | setEmptyValue (const T &emptyValue) |
void | swap (Octree< T, AS > &o) |
Octree< T, AS > & | operator= (Octree< T, AS > o) |
T & | operator() (int x, int y, int z) |
const T & | operator() (int x, int y, int z) const |
const T & | at (int x, int y, int z) const |
void | set (int x, int y, int z, const T &value) |
void | erase (int x, int y, int z) |
Array2D< T > | zSlice (int z) const |
void | writeBinary (std::ostream &out) const |
void | readBinary (std::istream &in) |
Static Public Member Functions | |
unsigned long | branchBytes () |
unsigned long | aggregateBytes () |
unsigned long | leafBytes () |
Protected Member Functions | |
Node *& | root () |
const Node * | root () const |
Static Protected Member Functions | |
void | deleteNode (Node **node) |
T | Type of the contained data. Requirements on type: must be copyable and default-constructible. | |
AS | Short for "aggregate size." As an optimization, leaves can be aggregated so that the relative size of pointers is diminished. This is 1 by default, but should be set higher when the size of T is small. Must be a power of two. |
|
|
|
Performs a deep copy of an octree. All branch pointers will be followed recursively and new nodes will be allocated.
|
|
Recursively deletes all nodes by following branch pointers. |
|
|
|
for ( int z = 0; z < ...; ++z ) { for ( int y = 0; y < ...; ++y ) { for ( int x = 0; x < ...; ++x ) { ... = octree.at(x,y,z); } } } However, zSlice() provides an even faster way. |
|
|
|
|
|
Deletes a node polymorphically. If the node is a branch node, it will delete all its subtree recursively. |
|
|
|
Erases the node at index (x,y,z). After the call, This function will free as much memory as possible. For example, when erasing the single child of a branch node, the branch node itself will be erased and replaced by a null pointer in its parent. This will percolate to the top of the tree if necessary. |
|
|
|
|
|
|
|
Synonym of at(). |
|
|
|
Assigns to this octree the contents of octree o. |
|
Reads the octree from in. It must previously have been written using writeBinary(). |
|
Const version of above. |
|
|
|
Sets the value of the node at (x, y, z) to value. If value is the empty value, the node is erased. Otherwise, the node is created if it did not already exist and its value is set to value. |
|
Sets the value of empty nodes to emptyValue.
|
|
|
|
Swaps the octree's contents with another's. This is a cheap operation as only the root pointers are swapped, not the whole structure. |
|
Writes the octree in binary form to the output stream out. This should be fast, but note that the type T will be written as it appears in memory. That is, if it is a complex type containing pointers, the pointer addresses will be written instead of the data pointed at. For complex types, you should roll your own function. |
|
for ( int z = 0; z < ...; ++z ) { tmp = octree.zSlice(z); for ( int y = 0; y < ...; ++y ) { for ( int x = 0; x < ...; ++x ) { ... = tmp(y,x); } } } |