AabbTreeNode.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_DATASTRUCTURES_AABBTREENODE_H
17 #define SURGSIM_DATASTRUCTURES_AABBTREENODE_H
18 
21 
22 #include "SurgSim/Math/Aabb.h"
23 
24 namespace SurgSim
25 {
26 namespace DataStructures
27 {
28 
30 class AabbTreeNode : public TreeNode
31 {
32 public:
33 
34  using TreeNode::setData;
35 
37  AabbTreeNode();
38 
40  virtual ~AabbTreeNode();
41 
49  void splitNode(size_t maxNodeData = 0);
50 
54  const SurgSim::Math::Aabbd& getAabb() const;
55 
62  void addData(const SurgSim::Math::Aabbd& aabb, size_t id, size_t maxNodeData = 0);
63 
70  void setData(const std::list<AabbTreeData::Item>& items, size_t maxNodeData = 0);
71 
79  void setData(std::list<AabbTreeData::Item>&& items, size_t maxNodeData);
80 
84  void getIntersections(const SurgSim::Math::Aabbd& aabb, std::list<size_t>* result);
85 
86 protected:
87 
88  bool doAccept(TreeVisitor* visitor) override;
89 
90 private:
91 
94 
96  size_t m_axis;
97 };
98 
99 }
100 }
101 
102 #endif
SurgSim::DataStructures::AabbTreeNode::m_axis
size_t m_axis
Cache for the index of the longest axis on this node.
Definition: AabbTreeNode.h:96
TreeNode.h
SurgSim::DataStructures::AabbTreeNode::doAccept
bool doAccept(TreeVisitor *visitor) override
Private function for use with the visitor pattern, this needs to be implemented to make the correct d...
Definition: AabbTreeNode.cpp:157
SurgSim::DataStructures::AabbTreeNode::setData
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.
Definition: AabbTreeNode.cpp:137
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::DataStructures::AabbTreeNode::~AabbTreeNode
virtual ~AabbTreeNode()
Destructor.
Definition: AabbTreeNode.cpp:30
SurgSim::DataStructures::AabbTreeNode::getAabb
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...
Definition: AabbTreeNode.cpp:98
SurgSim::DataStructures::AabbTreeNode::getIntersections
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.
Definition: AabbTreeNode.cpp:162
SurgSim::Math::Aabbd
Eigen::AlignedBox< double, 3 > Aabbd
Wrapper around the Eigen type.
Definition: Aabb.h:30
AabbTreeData.h
SurgSim::DataStructures::TreeNode::setData
void setData(std::shared_ptr< TreeData > data)
Sets the data of this node.
Definition: TreeNode.cpp:57
SurgSim::DataStructures::AabbTreeNode::m_aabb
SurgSim::Math::Aabbd m_aabb
The internal bounding box for this node, it is used when the node does not have any data.
Definition: AabbTreeNode.h:93
SurgSim::DataStructures::TreeNode
Basic tree node structure.
Definition: TreeNode.h:36
Aabb.h
SurgSim::DataStructures::AabbTreeNode
Node class for the AabbTree, this handles groups of items and subdivision if the number of items gets...
Definition: AabbTreeNode.h:30
SurgSim::DataStructures::TreeVisitor
Abstract Class for visitors, this needs to be extended for other tree nodes when necessary return fal...
Definition: TreeVisitor.h:31
SurgSim::DataStructures::AabbTreeNode::splitNode
void splitNode(size_t maxNodeData=0)
Splits the data into two parts, creates two children and puts the split data into the children the aa...
Definition: AabbTreeNode.cpp:35
SurgSim::DataStructures::AabbTreeNode::AabbTreeNode
AabbTreeNode()
Constructor.
Definition: AabbTreeNode.cpp:26
SurgSim::DataStructures::AabbTreeNode::addData
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 m...
Definition: AabbTreeNode.cpp:111