Generic Double-Precision Octree Class. More...
#include <decDOctree.h>
Public Types | |
| enum | eOctants { eoXnegYnegZneg, eoXnegYnegZpos, eoXnegYposZneg, eoXnegYposZpos, eoXposYnegZneg, eoXposYnegZpos, eoXposYposZneg, eoXposYposZpos, eoNotFound, eoFrontLeftTop = eoXnegYposZneg, eoFrontRightTop = eoXposYposZneg, eoFrontLeftBottom = eoXnegYnegZneg, eoFrontRightBottom = eoXposYnegZneg, eoBackLeftTop = eoXnegYposZpos, eoBackRightTop = eoXposYposZpos, eoBackLeftBotom = eoXnegYnegZpos, eoBackRightBottom = eoXposYnegZpos } |
Specified the constants used for the octants. More... | |
Public Member Functions | |
Constructors and Destructors | |
| decDOctree (const decDVector ¢er, const decDVector &halfSize) | |
| Creates a new generic octree object. | |
| virtual | ~decDOctree () |
| Cleans up the generic octree object. | |
Management | |
| decDOctree * | GetParent () const |
| Retrieves the parent of the octree or NULL if a root octree. | |
| void | SetParent (decDOctree *parent) |
| Sets the parent of the octree or NULL if a root octree. | |
| const decDVector & | GetCenter () const |
| Retrieves the center of the octree. | |
| const decDVector & | GetHalfSize () const |
| Retrieves the half size of the octree. | |
| decDOctree * | GetNodeAt (int octant) const |
| Retrieves one of the 8 child nodes. | |
| void | SetNodeAt (int octant, decDOctree *octree) |
| Sets one of the eight child nodes. | |
| decDOctree * | GetNodeAtBox (const decDVector &boxCenter, const decDVector &boxHalfSize) |
| Looks for the child node in which the given box lies. | |
| decDOctree * | FindNodeAtBox (const decDVector &boxCenter, const decDVector &boxHalfSize) const |
| Looks for the child node in which the box lies. | |
| int | FindOctantAtBox (const decDVector &boxCenter, const decDVector &boxHalfSize) const |
| Looks for the octant in which the element lies. | |
| bool | ContainsBox (const decDVector &boxCenter, const decDVector &boxHalfSize) const |
| Determines if the box is located completely in this node. | |
| decDOctree * | FindNodeAtPoint (const decDVector &point) const |
| Looks for the child node in which the point lies. | |
| int | FindOctantAtPoint (const decDVector &point) const |
| Looks for the octant in which the point lies. | |
| bool | ContainsPoint (const decDVector &point) const |
| Determines if the point is located in this node. | |
| decDOctree * | SearchTreeForBox (const decDVector &boxCenter, const decDVector &boxHalfSize) const |
| Searches for the Node containing a given box. | |
| decDOctree * | SearchTreeForPoint (const decDVector &point) const |
| Searches for the Node where the given point lies in. | |
| void | VisitNodes (decDOctreeVisitor *visitor) |
| Visits all nodes. | |
| void | VisitNodesColliding (decDOctreeVisitor *visitor, decDCollisionVolume *volume) |
| Visits all nodes which collide with the given collision volume. | |
| void | VisitNodesColliding (decDOctreeVisitor *visitor, const decDVector &boxMinExtend, const decDVector &boxMaxExtend) |
| Visits all nodes which collide with the given box. | |
| void | ClearTree (bool clearNodes) |
| Clears the octree. | |
| virtual decDOctree * | CreateOctree (int octant) const =0 |
| Creates new octree for the specified octant. | |
| virtual void | ClearNodeContent ()=0 |
| Clears the content of this node. | |
Generic Double-Precision Octree Class.
Provides the generic implementation of an octree algorithm. For real usage subclass this class and implement the required functions. Every Octree object is the root of an octree. The top most octree object with no parent is the real octree root and all children virtual octree roots. The subclass overwrites the node creation function to create nodes of its own class. Furthermore the subclass has to implement the management of the node content. This octree class only provides the skeleton required for an octree algorithm and does not implement any node content logic.
| enum decDOctree::eOctants |
Specified the constants used for the octants.
There exists two equal versions suitable for different types of implementations. The first set of octant definitions is classified using the axis coordinates. They are also aligned in a way that the definition value represents a bit mask. The first bit is the x axis, the second the y axis and the third the z axis. A set bit indicates positive direction and a 0 negative direction. This set is useful for implementations working with bit masks to identify octants. The second set of octant definitions uses verbal descriptions of the octants and is useful for implementations based around the logic location of an octant. Both sets include also a definition for a null octant. This is used by functions searching for octants to indicate that no matching octant could be found.
| decDOctree::decDOctree | ( | const decDVector & | center, |
| const decDVector & | halfSize | ||
| ) |
Creates a new generic octree object.
| virtual decDOctree::~decDOctree | ( | ) | [virtual] |
Cleans up the generic octree object.
| virtual void decDOctree::ClearNodeContent | ( | ) | [pure virtual] |
Clears the content of this node.
Implemented in decDefaultDOctree.
| void decDOctree::ClearTree | ( | bool | clearNodes ) |
Clears the octree.
If clearNodes is set to true all elements are cleared and nodes are reset to NULL. Otherwise only all elements are removed but the nodes stay intact.
| bool decDOctree::ContainsBox | ( | const decDVector & | boxCenter, |
| const decDVector & | boxHalfSize | ||
| ) | const |
Determines if the box is located completely in this node.
| bool decDOctree::ContainsPoint | ( | const decDVector & | point ) | const |
Determines if the point is located in this node.
| virtual decDOctree* decDOctree::CreateOctree | ( | int | octant ) | const [pure virtual] |
Creates new octree for the specified octant.
Implement this function to create a new octree of your own type. Do not set the parent of octree. The caller is responsible for this action if applicable.
Implemented in decDefaultDOctree.
| decDOctree* decDOctree::FindNodeAtBox | ( | const decDVector & | boxCenter, |
| const decDVector & | boxHalfSize | ||
| ) | const |
Looks for the child node in which the box lies.
If found the node is returned. If no node could be found NULL or the node does not exist yet NULL is returned.
| decDOctree* decDOctree::FindNodeAtPoint | ( | const decDVector & | point ) | const |
Looks for the child node in which the point lies.
If found the node is returned. If no node could be found NULL or the node does not exist yet NULL is returned.
| int decDOctree::FindOctantAtBox | ( | const decDVector & | boxCenter, |
| const decDVector & | boxHalfSize | ||
| ) | const |
Looks for the octant in which the element lies.
Returns eoNotFound if no octant fully contains the element.
| int decDOctree::FindOctantAtPoint | ( | const decDVector & | point ) | const |
Looks for the octant in which the point lies.
| const decDVector& decDOctree::GetCenter | ( | ) | const [inline] |
Retrieves the center of the octree.
| const decDVector& decDOctree::GetHalfSize | ( | ) | const [inline] |
Retrieves the half size of the octree.
| decDOctree* decDOctree::GetNodeAt | ( | int | octant ) | const |
Retrieves one of the 8 child nodes.
This is NULL if there exists no such node yet. You can use either an index from 0 to 7 inclusive or use one of the the eOctants constants.
| decDOctree* decDOctree::GetNodeAtBox | ( | const decDVector & | boxCenter, |
| const decDVector & | boxHalfSize | ||
| ) |
Looks for the child node in which the given box lies.
If the child node does not yet exist it is created. If found the node is returned. If no node could be found NULL is returned.
| decDOctree* decDOctree::GetParent | ( | ) | const [inline] |
Retrieves the parent of the octree or NULL if a root octree.
| decDOctree* decDOctree::SearchTreeForBox | ( | const decDVector & | boxCenter, |
| const decDVector & | boxHalfSize | ||
| ) | const |
Searches for the Node containing a given box.
| decDOctree* decDOctree::SearchTreeForPoint | ( | const decDVector & | point ) | const |
Searches for the Node where the given point lies in.
| void decDOctree::SetNodeAt | ( | int | octant, |
| decDOctree * | octree | ||
| ) |
Sets one of the eight child nodes.
You can use either an index from 0 to 7 inclusive or use one of the the eOctant constants. Node can be NULL to remove the child node.
| void decDOctree::SetParent | ( | decDOctree * | parent ) |
Sets the parent of the octree or NULL if a root octree.
| void decDOctree::VisitNodes | ( | decDOctreeVisitor * | visitor ) |
Visits all nodes.
| void decDOctree::VisitNodesColliding | ( | decDOctreeVisitor * | visitor, |
| const decDVector & | boxMinExtend, | ||
| const decDVector & | boxMaxExtend | ||
| ) |
Visits all nodes which collide with the given box.
| void decDOctree::VisitNodesColliding | ( | decDOctreeVisitor * | visitor, |
| decDCollisionVolume * | volume | ||
| ) |
Visits all nodes which collide with the given collision volume.
1.7.2