Public Types

decOctree Class Reference

Generic Octree Class. More...

#include <decOctree.h>

Inheritance diagram for decOctree:
decDefaultOctree

List of all members.

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
 decOctree (const decVector &center, const decVector &halfSize)
 Creates a new generic octree object.
virtual ~decOctree ()
 Cleans up the generic octree object.
Management
decOctreeGetParent () const
 Retrieves the parent of the octree or NULL if a root octree.
void SetParent (decOctree *parent)
 Sets the parent of the octree or NULL if a root octree.
const decVectorGetCenter () const
 Retrieves the center of the octree.
const decVectorGetHalfSize () const
 Retrieves the half size of the octree.
decOctreeGetNodeAt (int octant) const
 Retrieves one of the 8 child nodes.
void SetNodeAt (int octant, decOctree *octree)
 Sets one of the eight child nodes.
decOctreeGetNodeAtBox (const decVector &boxCenter, const decVector &boxHalfSize)
 Looks for the child node in which the given box lies.
decOctreeFindNodeAtBox (const decVector &boxCenter, const decVector &boxHalfSize) const
 Looks for the child node in which the box lies.
int FindOctantAtBox (const decVector &boxCenter, const decVector &boxHalfSize) const
 Looks for the octant in which the element lies.
bool ContainsBox (const decVector &boxCenter, const decVector &boxHalfSize) const
 Determines if the box is located completely in this node.
decOctreeFindNodeAtPoint (const decVector &point) const
 Looks for the child node in which the point lies.
int FindOctantAtPoint (const decVector &point) const
 Looks for the octant in which the point lies.
bool ContainsPoint (const decVector &point) const
 Determines if the point is located in this node.
decOctreeSearchTreeForBox (const decVector &boxCenter, const decVector &boxHalfSize) const
 Searches for the Node containing a given box.
decOctreeSearchTreeForPoint (const decVector &point) const
 Searches for the Node where the given point lies in.
void VisitNodes (decOctreeVisitor *visitor)
 Visits all nodes.
void VisitNodesColliding (decOctreeVisitor *visitor, decCollisionVolume *volume)
 Visits all nodes which collide with the given collision volume.
void VisitNodesColliding (decOctreeVisitor *visitor, const decVector &boxMinExtend, const decVector &boxMaxExtend)
 Visits all nodes which collide with the given box.
void ClearTree (bool clearNodes)
 Clears the octree.
virtual decOctreeCreateOctree (int octant) const =0
 Creates new octree for the specified octant.
virtual void ClearNodeContent ()=0
 Clears the content of this node.

Detailed Description

Generic 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.

Author:
Plüss Roland
Version:
1.0
Date:
2008

Member Enumeration Documentation

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.

Enumerator:
eoXnegYnegZneg 

Node X- Y- Z-, bitwise 000.

eoXnegYnegZpos 

Node X- Y- Z+, bitwise 001.

eoXnegYposZneg 

Node X- Y+ Z-, bitwise 010.

eoXnegYposZpos 

Node X- Y+ Z+, bitwise 011.

eoXposYnegZneg 

Node X+ Y- Z-, bitwise 100.

eoXposYnegZpos 

Node X+ Y- Z+, bitwise 101.

eoXposYposZneg 

Node X+ Y+ Z-, bitwise 110.

eoXposYposZpos 

Node X+ Y+ Z+, bitwise 111.

eoNotFound 

Special constant for searching meaning no match.

eoFrontLeftTop 

Node Front-Left-Top.

eoFrontRightTop 

Node Front-Right-Top.

eoFrontLeftBottom 

Node Front-Left-Bottom.

eoFrontRightBottom 

Node Front-Right-Bottom.

eoBackLeftTop 

Node Back-Left-Top.

eoBackRightTop 

Node Back-Right-Top.

eoBackLeftBotom 

Node Back-Left-Bottom.

eoBackRightBottom 

Node Back-Right-Bottom.


Constructor & Destructor Documentation

decOctree::decOctree ( const decVector center,
const decVector halfSize 
)

Creates a new generic octree object.

virtual decOctree::~decOctree (  ) [virtual]

Cleans up the generic octree object.


Member Function Documentation

virtual void decOctree::ClearNodeContent (  ) [pure virtual]

Clears the content of this node.

Implemented in decDefaultOctree.

void decOctree::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 decOctree::ContainsBox ( const decVector boxCenter,
const decVector boxHalfSize 
) const

Determines if the box is located completely in this node.

bool decOctree::ContainsPoint ( const decVector point ) const

Determines if the point is located in this node.

virtual decOctree* decOctree::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 decDefaultOctree.

decOctree* decOctree::FindNodeAtBox ( const decVector boxCenter,
const decVector 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.

decOctree* decOctree::FindNodeAtPoint ( const decVector 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 decOctree::FindOctantAtBox ( const decVector boxCenter,
const decVector boxHalfSize 
) const

Looks for the octant in which the element lies.

Returns eoNotFound if no octant fully contains the element.

int decOctree::FindOctantAtPoint ( const decVector point ) const

Looks for the octant in which the point lies.

const decVector& decOctree::GetCenter (  ) const [inline]

Retrieves the center of the octree.

const decVector& decOctree::GetHalfSize (  ) const [inline]

Retrieves the half size of the octree.

decOctree* decOctree::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.

decOctree* decOctree::GetNodeAtBox ( const decVector boxCenter,
const decVector 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.

decOctree* decOctree::GetParent (  ) const [inline]

Retrieves the parent of the octree or NULL if a root octree.

decOctree* decOctree::SearchTreeForBox ( const decVector boxCenter,
const decVector boxHalfSize 
) const

Searches for the Node containing a given box.

decOctree* decOctree::SearchTreeForPoint ( const decVector point ) const

Searches for the Node where the given point lies in.

void decOctree::SetNodeAt ( int  octant,
decOctree 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 decOctree::SetParent ( decOctree parent )

Sets the parent of the octree or NULL if a root octree.

void decOctree::VisitNodes ( decOctreeVisitor visitor )

Visits all nodes.

void decOctree::VisitNodesColliding ( decOctreeVisitor visitor,
const decVector boxMinExtend,
const decVector boxMaxExtend 
)

Visits all nodes which collide with the given box.

void decOctree::VisitNodesColliding ( decOctreeVisitor visitor,
decCollisionVolume volume 
)

Visits all nodes which collide with the given collision volume.


The documentation for this class was generated from the following file: