#include <octree.h>
Public Member Functions | |
void | clear () |
unsigned int | count () const |
Object * | getSimilarObject (const Object *object) |
Object * | getSimilarObject (const Object *object, Node *node, Box box, unsigned int depth=0) |
unsigned int | insert (Object *object) |
unsigned int | insertOnFit (Object *object) |
unsigned int | insertOnInterfere (Object *object, Node *node, Box box, unsigned int depth=0) |
unsigned int | insertUpdate (Object *object) |
unsigned int | insertUpdate2 (Object *object) |
unsigned int | insertUpdateOnInterfere (Object *object, Node *node, Box box, bool &inserted, unsigned int depth=0) |
bool | isPositionFree (float x, float y, float z) |
unsigned int | maxId () const |
void | nodes (std::list< Box > &nodesList, std::set< Object * > &objectList, const Filter *filter) |
void | nodes (std::list< Box > &nodesList, std::set< Object * > &objectList, const Filter *filter, Box dim, Node *node) |
const Object * | object (unsigned int id) const |
void | objects (std::set< Object * > &objectList, const Filter *filter) |
const std::map< unsigned int, Object * > & | objectsAll () const |
Octree (unsigned int maxDepth=DEFAULT_MAX_DEPTH) | |
Octree (const Box &rootSize, unsigned int maxDepth=DEFAULT_MAX_DEPTH) | |
bool | removeObject (unsigned int id) |
Node * | root () const |
~Octree () | |
Static Public Attributes | |
static const unsigned int | DEFAULT_MAX_DEPTH = 4 |
Private Attributes | |
unsigned int | m_maxDepth |
unsigned int | m_maxId |
std::map< unsigned int, Object * > | m_objects |
Node * | m_root |
Box | m_rootSize |
Main objtree class. Provides interface for working with octree.
objtree::Octree::Octree | ( | unsigned int | maxDepth = DEFAULT_MAX_DEPTH | ) |
Default constructor. Creates octree with default sized root node (16.0 x 16.0 x 16.0).
maxDepth | maximum octree depth |
Definition at line 41 of file octree.cpp.
objtree::Octree::Octree | ( | const Box & | rootSize, |
unsigned int | maxDepth = DEFAULT_MAX_DEPTH |
||
) |
A constructor. Creates octree with custom sized root node.
rootSize | root node bounding box |
maxDepth | maximum octree depth |
Definition at line 55 of file octree.cpp.
A destructor
Definition at line 66 of file octree.cpp.
void objtree::Octree::clear | ( | void | ) |
Clears all objects in octree. Resets octree to default state.
Definition at line 74 of file octree.cpp.
unsigned int objtree::Octree::count | ( | ) | const |
Returns number of objects in octree.
Definition at line 520 of file octree.cpp.
Object * objtree::Octree::getSimilarObject | ( | const Object * | object | ) |
Returns similar object to selected one.
object | object to compare |
Definition at line 310 of file octree.cpp.
Object * objtree::Octree::getSimilarObject | ( | const Object * | object, |
Node * | node, | ||
Box | box, | ||
unsigned int | depth = 0 |
||
) |
Returns similar object to selected one.
object | object to compare |
node | current node in recursion |
box | bounding box of current node |
depth | current depth |
Definition at line 256 of file octree.cpp.
unsigned int objtree::Octree::insert | ( | Object * | object | ) |
Inserts object into octree.
object | object to insert |
Definition at line 320 of file octree.cpp.
unsigned int objtree::Octree::insertOnFit | ( | Object * | object | ) |
Inserts object into the biggest node that fits entire object.
object | object to insert |
Definition at line 88 of file octree.cpp.
unsigned int objtree::Octree::insertOnInterfere | ( | Object * | object, |
Node * | node, | ||
Box | box, | ||
unsigned int | depth = 0 |
||
) |
Inserts object into all intersected leaf nodes.
object | object to insert |
node | current node in recursion |
box | bounding box of current node |
depth | current depth |
Definition at line 124 of file octree.cpp.
unsigned int objtree::Octree::insertUpdate | ( | Object * | object | ) |
Inserts or updates object into octree. Update object if there exists a similar object. Inserts otherwise.
object | object to insert |
Definition at line 341 of file octree.cpp.
unsigned int objtree::Octree::insertUpdate2 | ( | Object * | object | ) |
Inserts or updates object into octree, second variant. Update object if there exists a similar object. Inserts otherwise. This variant first find a similar object instead of finding it in inserting loop.
object | object to insert |
Definition at line 354 of file octree.cpp.
unsigned int objtree::Octree::insertUpdateOnInterfere | ( | Object * | object, |
Node * | node, | ||
Box | box, | ||
bool & | inserted, | ||
unsigned int | depth = 0 |
||
) |
Inserts or updates object into all intersected leaf nodes. Updates object if there exists a similar object. Inserts otherwise.
object | object to insert |
node | current node in recursion |
box | bounding box of current node |
depth | current depth |
inserted | has been new object inserted? |
Definition at line 158 of file octree.cpp.
bool objtree::Octree::isPositionFree | ( | float | x, |
float | y, | ||
float | z | ||
) |
Check if there is a free space in selected point.
x | |
y | |
z |
Definition at line 381 of file octree.cpp.
unsigned int objtree::Octree::maxId | ( | ) | const |
Returns maximum internal object id.
Definition at line 511 of file octree.cpp.
void objtree::Octree::nodes | ( | std::list< Box > & | nodesList, |
std::set< Object * > & | objectList, | ||
const Filter * | filter | ||
) |
Returns nodes and objects in area filtered by filter.
nodesList | output list of nodes |
objectList | output set of objects |
filter | pointer to a filter class |
Definition at line 420 of file octree.cpp.
void objtree::Octree::nodes | ( | std::list< Box > & | nodesList, |
std::set< Object * > & | objectList, | ||
const Filter * | filter, | ||
Box | dim, | ||
Node * | node | ||
) |
Returns nodes and objects in area filtered by filter.
nodesList | output list of nodes |
objectList | output set of objects |
filter | pointer to a filter class |
dim | recursion node bounding box |
node | recursion node |
Definition at line 433 of file octree.cpp.
const Object * objtree::Octree::object | ( | unsigned int | id | ) | const |
Definition at line 468 of file octree.cpp.
void objtree::Octree::objects | ( | std::set< Object * > & | objectList, |
const Filter * | filter | ||
) |
Returns objects in area filtered by filter.
nodesList | output list of nodes |
filter | pointer to a filter class |
Definition at line 462 of file octree.cpp.
const std::map< unsigned int, Object * > & objtree::Octree::objectsAll | ( | ) | const |
bool objtree::Octree::removeObject | ( | unsigned int | id | ) |
Removes object with selected id from octree.
id | object id |
Definition at line 481 of file octree.cpp.
Node * objtree::Octree::root | ( | void | ) | const |
const unsigned int objtree::Octree::DEFAULT_MAX_DEPTH = 4 [static] |
unsigned int objtree::Octree::m_maxDepth [private] |
unsigned int objtree::Octree::m_maxId [private] |
std::map<unsigned int, Object*> objtree::Octree::m_objects [private] |
Node* objtree::Octree::m_root [private] |
Box objtree::Octree::m_rootSize [private] |