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:

## 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 (const std::list< Item > &data)
| Constructor with list of items. More...
| AabbTreeData (std::list< Item > &&data)
| Constructor with moveable list of items. More...
| ~AabbTreeData ()
| Destructor. More...
void | add (const SurgSim::Math::Aabbd aabb, size_t id)
| Add an item to the data. More...
const SurgSim::Math::Aabbd & | getAabb () const
bool | isEmpty () const
size_t | getSize () const
std::shared_ptr< AabbTreeData > | takeLargerElements ()
| 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...
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< Item > | m_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

## Item

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

## Constructor & Destructor Documentation

## AabbTreeData() [1/4]

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

Constructor.

## AabbTreeData() [2/4]

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

Copy Constructor.

## AabbTreeData() [3/4]

SurgSim::DataStructures::AabbTreeData::AabbTreeData | ( | const std::list< Item > & | data | ) |

explicit

Constructor with list of items.

## AabbTreeData() [4/4]

SurgSim::DataStructures::AabbTreeData::AabbTreeData | ( | std::list< Item > && | data | ) |

explicit

Constructor with moveable list of items.

## ~AabbTreeData()

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

Destructor.

## Member Function Documentation

## add()

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

Add an item to the data.

Parameters

  aabb | the AABB of the item
  id | an object identifier assigned by the user of this class

## getAabb()

const SurgSim::Math::Aabbd & SurgSim::DataStructures::AabbTreeData::getAabb | ( |  | ) | const

Returns
  the combined AABB of all the contained items

## getIntersections()

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

  | aabb | the bounding box being queried
  [out] | result | list to be used for intersecting items

## getSize()

size_t SurgSim::DataStructures::AabbTreeData::getSize | ( |  | ) | const

Returns
  the number of items

## hasIntersections()

bool SurgSim::DataStructures::AabbTreeData::hasIntersections | ( | const SurgSim::Math::Aabbd & | aabb | ) | const

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

Parameters

  aabb | bounding box to use for the intersection check.

Returns
  true if the given AABB intersects with the AABB of all contained items.

## isEmpty()

bool SurgSim::DataStructures::AabbTreeData::isEmpty | ( |  | ) | const

Returns
  true when there are no items, false otherwise

## isEqual()

bool SurgSim::DataStructures::AabbTreeData::isEqual | ( | const TreeData * | data | ) | const

override private virtual

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

Implement this method in derived classes to do the comparison.

Parameters

  data | Other TreeData for comparison.

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

Implements SurgSim::DataStructures::TreeData.

## recalculateAabb()

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

private

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

## takeLargerElements()

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

## m_aabb

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

private

AABB containg all items.

## m_data

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:

- SurgSim/DataStructures/AabbTreeData.h
- SurgSim/DataStructures/AabbTreeData.cpp