AabbTree.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_AABBTREE_H
17 #define SURGSIM_DATASTRUCTURES_AABBTREE_H
18 
19 #include <list>
20 
23 #include "SurgSim/Math/Aabb.h"
24 
25 namespace SurgSim
26 {
27 
28 namespace DataStructures
29 {
30 
31 class AabbTreeNode;
32 
36 class AabbTree : public Tree
37 {
38 public:
39 
41  AabbTree();
42 
45  explicit AabbTree(size_t maxObjectsPerNode);
46 
48  virtual ~AabbTree();
49 
51  size_t getMaxObjectsPerNode() const;
52 
57  void add(const SurgSim::Math::Aabbd& aabb, size_t objectId);
58 
61  void set(const std::list<AabbTreeData::Item>& items);
62 
65  void set(std::list<AabbTreeData::Item>&& items);
66 
68  const SurgSim::Math::Aabbd& getAabb() const;
69 
71  typedef std::pair<std::shared_ptr<AabbTreeNode>, std::shared_ptr<AabbTreeNode>> TreeNodePairType;
72 
76  std::list<TreeNodePairType> spatialJoin(const AabbTree& otherTree) const;
77 
82  void spatialJoin(std::shared_ptr<AabbTreeNode> lhsParent,
83  std::shared_ptr<AabbTreeNode> rhsParent,
84  std::list<TreeNodePairType>* result) const;
85 
86 private:
87 
90 
92  std::shared_ptr<AabbTreeNode> m_typedRoot;
93 };
94 
95 }
96 }
97 
98 #endif
SurgSim::DataStructures::AabbTree::set
void set(const std::list< AabbTreeData::Item > &items)
Create the tree from a list of tree items, all the tree information will be deleted.
Definition: AabbTree.cpp:50
SurgSim::DataStructures::AabbTree::add
void add(const SurgSim::Math::Aabbd &aabb, size_t objectId)
Add a give object identified by objectId to the tree, this id should be unqiue on the users side,...
Definition: AabbTree.cpp:45
SurgSim::DataStructures::AabbTree::spatialJoin
std::list< TreeNodePairType > spatialJoin(const AabbTree &otherTree) const
Query to find all pairs of intersecting nodes between two aabb r-trees.
Definition: AabbTree.cpp:74
SurgSim::DataStructures::Tree
Basic tree structure.
Definition: Tree.h:33
SurgSim
Definition: CompoundShapeToGraphics.cpp:30
SurgSim::Math::Aabbd
Eigen::AlignedBox< double, 3 > Aabbd
Wrapper around the Eigen type.
Definition: Aabb.h:30
SurgSim::DataStructures::AabbTree::~AabbTree
virtual ~AabbTree()
Destructor.
Definition: AabbTree.cpp:40
AabbTreeData.h
SurgSim::DataStructures::AabbTree::TreeNodePairType
std::pair< std::shared_ptr< AabbTreeNode >, std::shared_ptr< AabbTreeNode > > TreeNodePairType
Type indicating a relationship between two AabbTreeNodes.
Definition: AabbTree.h:71
SurgSim::DataStructures::AabbTree::AabbTree
AabbTree()
Constructor.
Definition: AabbTree.cpp:26
SurgSim::DataStructures::AabbTree::m_maxObjectsPerNode
size_t m_maxObjectsPerNode
Number of objects in a node that will trigger a split.
Definition: AabbTree.h:89
SurgSim::DataStructures::AabbTree::getAabb
const SurgSim::Math::Aabbd & getAabb() const
Definition: AabbTree.cpp:69
Aabb.h
Tree.h
SurgSim::DataStructures::AabbTree::m_typedRoot
std::shared_ptr< AabbTreeNode > m_typedRoot
A typed version of the root for access without typecasting.
Definition: AabbTree.h:92
SurgSim::DataStructures::AabbTree::getMaxObjectsPerNode
size_t getMaxObjectsPerNode() const
Definition: AabbTree.cpp:64
SurgSim::DataStructures::AabbTree
AabbTree is a tree that is organized by the bounding boxes of the referenced objects,...
Definition: AabbTree.h:37