Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
SurgSim::DataStructures::AabbTreeData Class Reference

Internal class to hold a list of AABBs and their respective object ids, it can calculate the elements that intersect with a given aabb each node in the AABB tree holds one of these. More...

#include <SurgSim/DataStructures/AabbTreeData.h>

Inheritance diagram for SurgSim::DataStructures::AabbTreeData:
SurgSim::DataStructures::TreeData

Public Types

typedef std::pair< SurgSim::Math::Aabbd, size_t > Item
 

Public Member Functions

 AabbTreeData ()
 Constructor. More...
 
 AabbTreeData (const AabbTreeData &data)
 Copy Constructor. More...
 
 ~AabbTreeData ()
 Destructor. More...
 
void add (const SurgSim::Math::Aabbd aabb, size_t id)
 Add an item to the data. More...
 
const SurgSim::Math::AabbdgetAabb () const
 
bool isEmpty () const
 
size_t getSize () const
 
std::shared_ptr< AabbTreeDatatakeLargerElements ()
 Split the current items into two geometric halves, keep the first half and return a pointer to the second half. More...
 
bool hasIntersections (const SurgSim::Math::Aabbd &aabb) const
 Check whether there could be any intersections with a given bounding box. More...
 
void getIntersections (const SurgSim::Math::Aabbd &aabb, std::list< size_t > *result) const
 Check all items bounding boxes against the one passed as a parameter and append items that overlap to the list given as a parameter. More...
 
- Public Member Functions inherited from SurgSim::DataStructures::TreeData
 TreeData ()
 Constructor. More...
 
virtual ~TreeData ()
 Destructor. More...
 
bool operator== (const TreeData &data) const
 If the data are not of the same type, returns false; otherwise, compares with the implementation of isEqual(const TreeData&). More...
 
bool operator!= (const TreeData &data) const
 Returns true if the data are not equal; otherwise, returns false. More...
 

Private Member Functions

void recalculateAabb ()
 Recalculate the aabb of this class, in case items where updated. More...
 
virtual bool isEqual (const TreeData *data) const override
 Returns true if the trees are equal; otherwise, returns false. More...
 

Private Attributes

SurgSim::Math::Aabbd m_aabb
 AABB containg all items. More...
 
std::list< Itemm_data
 The items that were added to this list. More...
 

Detailed Description

Internal class to hold a list of AABBs and their respective object ids, it can calculate the elements that intersect with a given aabb each node in the AABB tree holds one of these.

Member Typedef Documentation

Constructor & Destructor Documentation

SurgSim::DataStructures::AabbTreeData::AabbTreeData ( )

Constructor.

SurgSim::DataStructures::AabbTreeData::AabbTreeData ( const AabbTreeData data)

Copy Constructor.

SurgSim::DataStructures::AabbTreeData::~AabbTreeData ( )

Destructor.

Member Function Documentation

void SurgSim::DataStructures::AabbTreeData::add ( const SurgSim::Math::Aabbd  aabb,
size_t  id 
)

Add an item to the data.

Parameters
aabbthe AABB of the item
idan object identifier assigned by the user of this class
const SurgSim::Math::Aabbd & SurgSim::DataStructures::AabbTreeData::getAabb ( ) const
Returns
the combined AABB of all the contained items
void SurgSim::DataStructures::AabbTreeData::getIntersections ( const SurgSim::Math::Aabbd aabb,
std::list< size_t > *  result 
) const

Check all items bounding boxes against the one passed as a parameter and append items that overlap to the list given as a parameter.

Parameters
aabbthe bounding box being queried
[out]resultlist to be used for intersecting items
size_t SurgSim::DataStructures::AabbTreeData::getSize ( ) const
Returns
the number of items
bool SurgSim::DataStructures::AabbTreeData::hasIntersections ( const SurgSim::Math::Aabbd aabb) const

Check whether there could be any intersections with a given bounding box.

Parameters
aabbbounding box to use for the intersection check.
Returns
true if the given AABB intersects with the AABB of all contained items.
bool SurgSim::DataStructures::AabbTreeData::isEmpty ( ) const
Returns
true when there are no items, false otherwise
bool SurgSim::DataStructures::AabbTreeData::isEqual ( const TreeData data) const
overrideprivatevirtual

Returns true if the trees are equal; otherwise, returns false.

Implement this method in derived classes to do the comparison.

Parameters
dataOther TreeData for comparison.
Returns
true if the data are equal; otherwise, returns false.

Implements SurgSim::DataStructures::TreeData.

void SurgSim::DataStructures::AabbTreeData::recalculateAabb ( )
private

Recalculate the aabb of this class, in case items where updated.

std::shared_ptr< AabbTreeData > SurgSim::DataStructures::AabbTreeData::takeLargerElements ( )

Split the current items into two geometric halves, keep the first half and return a pointer to the second half.

The split is done along the longest axis of the enclosing aabb, the center of this axis is the point where the split occurs. This object will keep items that have a smaller coordinate than the center, the result will receive all items that have a larger coordinate on the determined axis.

Returns
AabbTreeData with the items to the right of the center of the longest axis.

Member Data Documentation

SurgSim::Math::Aabbd SurgSim::DataStructures::AabbTreeData::m_aabb
private

AABB containg all items.

std::list<Item> SurgSim::DataStructures::AabbTreeData::m_data
private

The items that were added to this list.


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