SurgSim::DataStructures::AabbTreeNode Class Reference

Node class for the AabbTree, this handles groups of items and subdivision if the number of items gets too big. More...

`#include <SurgSim/DataStructures/AabbTreeNode.h>`

Inheritance diagram for SurgSim::DataStructures::AabbTreeNode:

## Public Member Functions

| AabbTreeNode ()
| Constructor. More...
virtual | ~AabbTreeNode ()
| Destructor. More...
void | splitNode (size_t maxNodeData=0)
| Splits the data into two parts, creates two children and puts the split data into the children the aabb of this node does not change, the data of this node will be empty after this. More...
const SurgSim::Math::Aabbd & | getAabb () const
| Get the aabb of this node, it is the union of the aabb of all the items in the data when the node has data, or all the union of the aabb trees of all the sub-nodes. More...
void | addData (const SurgSim::Math::Aabbd &aabb, size_t id, size_t maxNodeData=0)
| Add data to this node, if maxNodeData is >0 the node will split if the number of data items exceeds maxNodeData. More...
void | setData (const std::list< AabbTreeData::Item > &items, size_t maxNodeData=0)
| Set the data on this node, the node needs to be empty and not have any children for this to work. More...
void | setData (std::list< AabbTreeData::Item > &&items, size_t maxNodeData)
| Set the data on this node, rvalue reference version, the node needs to be empty and not have any children for this to work. More...
void | getIntersections (const SurgSim::Math::Aabbd &aabb, std::list< size_t > *result)
| Fetch a list of items that have AABBs intersecting with the given AABB. More...
Public Member Functions inherited from SurgSim::DataStructures::TreeNode
| TreeNode ()
| Constructor. After construction, the node has no children, and the data is null. More...
virtual | ~TreeNode ()
| Destructor. More...
void | setData (std::shared_ptr< TreeData > data)
| Sets the data of this node. More...
std::shared_ptr< TreeData > | getData () const
size_t | getNumChildren () const
std::shared_ptr< TreeNode > | getChild (size_t index) const
| Returns the specified child of this node. More...
void | accept (TreeVisitor *visitor)
| Public entry point for visitor, currently this performs pre-order traversal of the tree. More...
bool | operator== (const TreeNode &node) const
| Returns true if the nodes are equal; otherwise, returns false. More...
bool | operator!= (const TreeNode &node) const
| Returns true if the nodes are not equal; otherwise, returns false. More...

## Protected Member Functions

bool | doAccept (TreeVisitor *visitor) override
| Private function for use with the visitor pattern, this needs to be implemented to make the correct double dispatch call to the dynamic type of this class. More...
Protected Member Functions inherited from SurgSim::DataStructures::TreeNode
virtual bool | isEqual (const TreeNode &node) const
| Returns true if the nodes are equal; otherwise, returns false. More...
void | setNumChildren (size_t numChildren)
| Sets the number of children of this node. More...
void | addChild (const std::shared_ptr< TreeNode > &node)
| Add a child to this node. More...
void | addChild (const std::shared_ptr< TreeNode > &&node)
| Add a child to this node. More...
void | setChild (size_t index, const std::shared_ptr< TreeNode > &node)
| Set a specific child of this node. More...

## Private Attributes

SurgSim::Math::Aabbd | m_aabb
| The internal bounding box for this node, it is used when the node does not have any data. More...
size_t | m_axis
| Cache for the index of the longest axis on this node. More...

## Detailed Description

Node class for the AabbTree, this handles groups of items and subdivision if the number of items gets too big.

## Constructor & Destructor Documentation

## AabbTreeNode()

SurgSim::DataStructures::AabbTreeNode::AabbTreeNode | ( |  | ) |

Constructor.

## ~AabbTreeNode()

SurgSim::DataStructures::AabbTreeNode::~AabbTreeNode | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## addData()

void SurgSim::DataStructures::AabbTreeNode::addData | ( | const SurgSim::Math::Aabbd & | aabb,
|  | size_t | id,
|  | size_t | maxNodeData = `0`
| ) |  |

Add data to this node, if maxNodeData is >0 the node will split if the number of data items exceeds maxNodeData.

Parameters

  aabb | The aabb for the item to be added.
  id | The id for the item that is being added, handled by the user of this class.
  maxNodeData | number of maximum items of data in this node, if more, the node will split, if 0 the node will not be split until it is no longer possible, the structure will approach a binary tree.

## doAccept()

bool SurgSim::DataStructures::AabbTreeNode::doAccept | ( | TreeVisitor * | visitor | ) |

override protected virtual

Private function for use with the visitor pattern, this needs to be implemented to make the correct double dispatch call to the dynamic type of this class.

Parameters

  visitor | The visitor that is trying to traverse the tree.

Returns
  true to indicate proceeding with the visitor, false indicates to abort the traversal.

Implements SurgSim::DataStructures::TreeNode.

## getAabb()

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

Get the aabb of this node, it is the union of the aabb of all the items in the data when the node has data, or all the union of the aabb trees of all the sub-nodes.

Returns
  The aabb box of this node.

## getIntersections()

void SurgSim::DataStructures::AabbTreeNode::getIntersections | ( | const SurgSim::Math::Aabbd & | aabb,
|  | std::list< size_t > * | result
| ) |  |

Fetch a list of items that have AABBs intersecting with the given AABB.

Parameters

  | aabb | The bounding box for the query.
  [out] | result | location to receive the results of the call.

## setData() [1/2]

void SurgSim::DataStructures::AabbTreeNode::setData | ( | const std::list< AabbTreeData::Item > & | items,
|  | size_t | maxNodeData = `0`
| ) |  |

Set the data on this node, the node needs to be empty and not have any children for this to work.

Nodes will be split until there are only maxNodeData elements in one node

Parameters

  items | list of AabbTreeData::Item elements that should populate the tree
  maxNodeData | number of maximum items of data in this node, if more, the node will split, if 0 the node will not be split until it is no longer possible, the structure will approach a binary tree.

## setData() [2/2]

void SurgSim::DataStructures::AabbTreeNode::setData | ( | std::list< AabbTreeData::Item > && | items,
|  | size_t | maxNodeData
| ) |  |

Set the data on this node, rvalue reference version, the node needs to be empty and not have any children for this to work.

Nodes will be split until there are only maxNodeData elements in one node

Parameters

  items | list of AabbTreeData::Item elements that should populate the tree
  maxNodeData | number of maximum items of data in this node, if more, the node will split, if 0 the node will not be split until it is no longer possible, the structure will approach a binary tree.

## splitNode()

void SurgSim::DataStructures::AabbTreeNode::splitNode | ( | size_t | maxNodeData = `0` | ) |

Splits the data into two parts, creates two children and puts the split data into the children the aabb of this node does not change, the data of this node will be empty after this.

Parameters

  maxNodeData | number of maximum items of data in this node, if more, the node will split, if 0 the node will not be split until it is no longer possible, the structure will approach a binary tree.

Note
  Sometimes the current mechanism to split the list of AABBs along the longest axis will fail to actually split the list, if the size of the list is greater than 3 * maxNodeData a warning will be generated

## Member Data Documentation

## m_aabb

SurgSim::Math::Aabbd SurgSim::DataStructures::AabbTreeNode::m_aabb

private

The internal bounding box for this node, it is used when the node does not have any data.

## m_axis

size_t SurgSim::DataStructures::AabbTreeNode::m_axis

private

Cache for the index of the longest axis on this node.

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

- SurgSim/DataStructures/AabbTreeNode.h
- SurgSim/DataStructures/AabbTreeNode.cpp