Public Types

decDOctree Class Reference

Generic Double-Precision Octree Class. More...

#include <decDOctree.h>

Inheritance diagram for decDOctree:
decDefaultDOctree

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
 decDOctree (const decDVector &center, const decDVector &halfSize)
 Creates a new generic octree object.
virtual ~decDOctree ()
 Cleans up the generic octree object.
Management
decDOctreeGetParent () 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 decDVectorGetCenter () const
 Retrieves the center of the octree.
const decDVectorGetHalfSize () const
 Retrieves the half size of the octree.
decDOctreeGetNodeAt (int octant) const
 Retrieves one of the 8 child nodes.
void SetNodeAt (int octant, decDOctree *octree)
 Sets one of the eight child nodes.
decDOctreeGetNodeAtBox (const decDVector &boxCenter, const decDVector &boxHalfSize)
 Looks for the child node in which the given box lies.
decDOctreeFindNodeAtBox (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.
decDOctreeFindNodeAtPoint (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.
decDOctreeSearchTreeForBox (const decDVector &boxCenter, const decDVector &boxHalfSize) const
 Searches for the Node containing a given box.
decDOctreeSearchTreeForPoint (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 decDOctreeCreateOctree (int octant) const =0
 Creates new octree for the specified octant.
virtual void ClearNodeContent ()=0
 Clears the content of this node.

Detailed Description

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.

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

decDOctree::decDOctree ( const decDVector center,
const decDVector halfSize 
)

Creates a new generic octree object.

virtual decDOctree::~decDOctree (  ) [virtual]

Cleans up the generic octree object.


Member Function Documentation

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.


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