VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
DtOctree< T > Class Template Reference

template<class T>
class DtOctree< T >

DtOctree class.

DtOctree implements an octree, for storing arbitary objects with extents in a way that makes it fast to enumerate objects that intersect a specified extent.

Currently there's some sloppiness in the implementation which will make it difficult to specialize this template to objects other than DtSimObjects, but it's good to keep that sloppiness to a minimum, as this class would be useful for other things (notably terrain triangles).

The outer octree class does attempt to deal with objects which are outside the octree's defined region, but it does not do so efficiently.

Inheritance diagram for DtOctree< T >:
Inheritance graph
[legend]

Public Types

typedef std::map< T
*, DtOctreeMember< T > * > 
MemberContainer
 
typedef std::map< T
*, DtOctreeMember< T >
* >::iterator 
MemberIterator
 
typedef std::list< T * > OutsideAreaContainer
 
typedef std::list< T * >::iterator OutsideAreaIterator
 
typedef
DtSpatialSelectionFunctorTemplate
< T > 
SpatialSelectionFunctor
 

Public Member Functions

 DtOctree (const DtExtent &region)
 
virtual ~DtOctree ()
 
virtual void visitObjects (const DtExtent &extent, DtSpatialSelectionFunctorTemplate< T > &callback)
 
virtual void addObject (T *object, const DtExtent &extent)
 
virtual void removeObject (T *object, bool needsLock=true)
 
virtual void updatePositions ()
 
bool containsObject (T *object)
 
int numObjects ()
 
int numObjectsOutside ()
 

Protected Member Functions

bool removeObjectOutsideArea (T *object)
 

Protected Attributes

tbb::spin_rw_mutex myMutex
 
DtOctreeNode< T > * myRootNode
 
OutsideAreaContainer myObjectsOutsideArea
 
MemberContainer myMemberMap
 
tbb::atomic< unsigned intmySearchKey
 

Member Typedef Documentation

template<class T>
typedef std::map<T*, DtOctreeMember<T>*> DtOctree< T >::MemberContainer

Container and iterator typedefs for the STL structures used.

template<class T>
typedef std::map<T*, DtOctreeMember<T>*>::iterator DtOctree< T >::MemberIterator
template<class T>
typedef std::list<T*> DtOctree< T >::OutsideAreaContainer
template<class T>
typedef std::list<T*>::iterator DtOctree< T >::OutsideAreaIterator

Constructor & Destructor Documentation

template<class T>
DtOctree< T >::DtOctree ( const DtExtent region)
inline

Constructor. The extent covered by an octree may not be changed once the octree is created.

template<class T>
virtual DtOctree< T >::~DtOctree ( )
inlinevirtual

Destructor. Deletes the octree and any members in it (though not the corresponding objects).

Member Function Documentation

template<class T>
virtual void DtOctree< T >::visitObjects ( const DtExtent extent,
DtSpatialSelectionFunctorTemplate< T > &  callback 
)
inlinevirtual

Call the given functor for every member that shares a node with the specified extent. This does not test for exact intersection; it only iterates over any objects that might intersect the given extent (i.e. there may be extras).

template<class T>
virtual void DtOctree< T >::addObject ( T *  object,
const DtExtent extent 
)
inlinevirtual

TODO: Add search key to outside octree list so that objects which fall completely outside the octree region can be filtered out of searches completely within.

Add a member to the octree.

template<class T>
virtual void DtOctree< T >::removeObject ( T *  object,
bool  needsLock = true 
)
inlinevirtual

Remove a member from the octree.

Referenced by DtOctree< const DtSimObject >::updatePositions().

template<class T>
virtual void DtOctree< T >::updatePositions ( )
inlinevirtual

Process any updates to the objects' positions that have happened since they were added to the octree. If members' extents change, they will still be returned from visitMembers() as if they held the old position until this function is called. Once this function is called, objects will intersect using the newly-specified positions (until the function is called again, obviously).

template<class T>
bool DtOctree< T >::containsObject ( T *  object)
inline
template<class T>
int DtOctree< T >::numObjects ( )
inline
template<class T>
int DtOctree< T >::numObjectsOutside ( )
inline
template<class T>
bool DtOctree< T >::removeObjectOutsideArea ( T *  object)
inlineprotected

Member Data Documentation

template<class T>
tbb::spin_rw_mutex DtOctree< T >::myMutex
protected
template<class T>
DtOctreeNode<T>* DtOctree< T >::myRootNode
protected
template<class T>
OutsideAreaContainer DtOctree< T >::myObjectsOutsideArea
protected
template<class T>
MemberContainer DtOctree< T >::myMemberMap
protected
template<class T>
tbb::atomic<unsigned int> DtOctree< T >::mySearchKey
protected

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

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)