opensurgsim
Public Member Functions | Protected Member Functions | List of all members
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 <AabbTreeNode.h>

Inheritance diagram for SurgSim::DataStructures::AabbTreeNode:
SurgSim::DataStructures::TreeNode

Public Member Functions

 AabbTreeNode ()
 Constructor.
 
virtual ~AabbTreeNode ()
 Destructor.
 
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 setAabb (const SurgSim::Math::Aabbd &aabb)
 
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 AabbTreeData::ItemList &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 (AabbTreeData::ItemList &&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::vector< 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.
 
virtual ~TreeNode ()
 Destructor.
 
void setData (std::shared_ptr< TreeData > data)
 Sets the data of this node. More...
 
const std::shared_ptr< TreeData > & getData () const
 
size_t getNumChildren () const
 
std::shared_ptr< TreeNode > & getChild (size_t index)
 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...
 

Detailed Description

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

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
aabbThe aabb for the item to be added.
idThe id for the item that is being added, handled by the user of this class.
maxNodeDatanumber 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)
overrideprotectedvirtual

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
visitorThe 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::vector< size_t > *  result 
)

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

Parameters
aabbThe bounding box for the query.
[out]resultlocation to receive the results of the call.

§ setData() [1/2]

void SurgSim::DataStructures::AabbTreeNode::setData ( const AabbTreeData::ItemList &  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
itemslist of AabbTreeData::Item elements that should populate the tree
maxNodeDatanumber 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 ( AabbTreeData::ItemList &&  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
itemslist of AabbTreeData::Item elements that should populate the tree
maxNodeDatanumber 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
maxNodeDatanumber 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

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