#include <Octree.h>
Collaboration diagram for hxa7241_graphics::Octree< TYPE >:
Public Member Functions | |
Octree (const Vector3r &positionOfLowerCorner, real sizeOfCube, dword maxItemCountPerCell, dword maxLevelCount, real minCellSize) | |
standard object services --------------------------------------------------- | |
~Octree () | |
Octree (const Octree &) | |
Octree & | operator= (const Octree &) |
bool | insert (const TYPE &item, const OctreeAgent< TYPE > &agent) |
commands ------------------------------------------------------------------- | |
bool | remove (const TYPE &item, const OctreeAgent< TYPE > &agent) |
void | visit (OctreeVisitor< TYPE > &visitor) const |
queries -------------------------------------------------------------------- | |
bool | isEmpty () const |
void | getInfo (dword &byteSize, dword &leafCount, dword &itemRefCount, dword &maxDepth) const |
const Vector3r & | getPosition () const |
real | getSize () const |
dword | getMaxItemCountPerCell () const |
dword | getMaxLevelCount () const |
real | getMinCellSize () const |
Client must define concrete derivatives of OctreeAgent<ItemType> and OctreeVisitor<ItemType>.
maxItemCountPerCell is ignored where maxLevelCount or minCellSize is reached.
The octree is cubical and axis aligned, partitions are axis aligned, partitions divide in half, each level partitions the previous level in all three axiss.
Storage is contracted or expanded as needed by item insertion and removal.
(Occupies, very approximately, 20 bytes per point item. maybe...)
Octree is only an index: it points to client items, it does not manage storage of items themselves.
This template wrapper ensures the items indexed by the octree, and the agents and visitors used when accessing them are, of matching types. All algorithmic work is delegated to OctreeRoot and OctreeCell derivatives in OctreeImplementation, which work with abstract base interfaces and void pointers.
For the insertion and removal commands, the agent provides an interface for the octree to query the typeless item, and for the visit query, the visitor provides callbacks to read tree nodes for carrying out the visit operation.
hxa7241_graphics::Octree< TYPE >::Octree | ( | const Vector3r & | positionOfLowerCorner, | |
real | sizeOfCube, | |||
dword | maxItemCountPerCell, | |||
dword | maxLevelCount, | |||
real | minCellSize | |||
) | [inline] |
standard object services ---------------------------------------------------
Constructs a particular format of octree.
* sizeOfCube is desired length along a side
* maxItemCountPerCell is desired max item pointers per leaf
* maxLevelCount is desired max depth of tree
* minCellSize is desired min size of cells
hxa7241_graphics::Octree< TYPE >::~Octree | ( | ) | [inline] |
hxa7241_graphics::Octree< TYPE >::Octree | ( | const Octree< TYPE > & | ) | [inline] |
Octree< TYPE > & hxa7241_graphics::Octree< TYPE >::operator= | ( | const Octree< TYPE > & | ) | [inline] |
Can throw storage allocation exceptions. In such cases the octree is unmodified.
bool hxa7241_graphics::Octree< TYPE >::insert | ( | const TYPE & | item, | |
const OctreeAgent< TYPE > & | agent | |||
) | [inline] |
commands -------------------------------------------------------------------
Add pointer(s) to the item to the octree.
(If an item has non-zero volume, it may have pointers in multiple cells.)
bool hxa7241_graphics::Octree< TYPE >::remove | ( | const TYPE & | item, | |
const OctreeAgent< TYPE > & | agent | |||
) | [inline] |
Removes pointer(s) to the item from the octree.
(If an item has non-zero volume, it may have pointers in multiple cells.)
void hxa7241_graphics::Octree< TYPE >::visit | ( | OctreeVisitor< TYPE > & | visitor | ) | const [inline] |
queries --------------------------------------------------------------------
Execute a visit query operation.
bool hxa7241_graphics::Octree< TYPE >::isEmpty | ( | ) | const [inline] |
Reports if the octree is empty.
void hxa7241_graphics::Octree< TYPE >::getInfo | ( | dword & | byteSize, | |
dword & | leafCount, | |||
dword & | itemRefCount, | |||
dword & | maxDepth | |||
) | const [inline] |
Provides stats on the octree.
* byteSize is size in bytes
* leafCount is number of leafs
* itemRefCount is total number of item pointers in all leafs
* maxDepth is deepest depth of tree
const Vector3r & hxa7241_graphics::Octree< TYPE >::getPosition | ( | ) | const [inline] |
Gives the position supplied at construction.
real hxa7241_graphics::Octree< TYPE >::getSize | ( | ) | const [inline] |
Gives the size supplied at construction.
dword hxa7241_graphics::Octree< TYPE >::getMaxItemCountPerCell | ( | ) | const [inline] |
Gives the leaf pointer limit supplied at construction.
dword hxa7241_graphics::Octree< TYPE >::getMaxLevelCount | ( | ) | const [inline] |
Gives the depth limit supplied at construction.
real hxa7241_graphics::Octree< TYPE >::getMinCellSize | ( | ) | const [inline] |
Gives the size limit supplied at construction.