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 
22 
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 
53 
58  void add(const SurgSim::Math::Aabbd& aabb, size_t objectId);
59 
60  const SurgSim::Math::Aabbd& getAabb() const;
61 
63  typedef std::pair<std::shared_ptr<AabbTreeNode>, std::shared_ptr<AabbTreeNode>> TreeNodePairType;
64 
68  std::list<TreeNodePairType> spatialJoin(const AabbTree& otherTree) const;
69 
74  void spatialJoin(std::shared_ptr<AabbTreeNode> lhsParent,
75  std::shared_ptr<AabbTreeNode> rhsParent,
76  std::list<TreeNodePairType>* result) const;
77 
78 private:
79 
82 
84  std::shared_ptr<AabbTreeNode> m_typedRoot;
85 };
86 
87 }
88 }
89 
90 #endif
Definition: DriveElementFromInputBehavior.cpp:27
std::list< TreeNodePairType > spatialJoin(const AabbTree &otherTree) const
Query to find all pairs of intersecting nodes between two aabb r-trees.
Definition: AabbTree.cpp:60
Basic tree structure.
Definition: Tree.h:32
size_t getMaxObjectsPerNode() const
Definition: AabbTree.cpp:50
const SurgSim::Math::Aabbd & getAabb() const
Definition: AabbTree.cpp:55
AabbTree is a tree that is organized by the bounding boxes of the referenced objects, the bounding box used is the Axis Aligned Bounding Box (AABB), with the extents of an AABB describing the min and max of each coordinate for the given object.
Definition: AabbTree.h:36
Eigen::AlignedBox< double, 3 > Aabbd
Wrapper around the Eigen type.
Definition: Aabb.h:30
virtual ~AabbTree()
Destructor.
Definition: AabbTree.cpp:40
size_t m_maxObjectsPerNode
Number of objects in a node that will trigger a split.
Definition: AabbTree.h:81
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
AabbTree()
Constructor.
Definition: AabbTree.cpp:26
std::pair< std::shared_ptr< AabbTreeNode >, std::shared_ptr< AabbTreeNode > > TreeNodePairType
Type indicating a relationship between two AabbTreeNodes.
Definition: AabbTree.h:63
std::shared_ptr< AabbTreeNode > m_typedRoot
A typed version of the root for access without typecasting.
Definition: AabbTree.h:84