AabbTreeData.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_AABBTREEDATA_H
17 #define SURGSIM_DATASTRUCTURES_AABBTREEDATA_H
18 
20 
21 #include "SurgSim/Math/Aabb.h"
22 
23 #include <utility>
24 #include <list>
25 #include <memory>
26 
27 namespace SurgSim
28 {
29 namespace DataStructures
30 {
31 
34 class AabbTreeData : public TreeData
35 {
36 public:
37 
39  AabbTreeData();
40 
42  AabbTreeData(const AabbTreeData& data);
43 
45  ~AabbTreeData();
46 
47  typedef std::pair<SurgSim::Math::Aabbd, size_t> Item;
48 
52  void add(const SurgSim::Math::Aabbd aabb, size_t id);
53 
55  const SurgSim::Math::Aabbd& getAabb() const;
56 
58  bool isEmpty() const;
59 
61  size_t getSize() const;
62 
68  std::shared_ptr<AabbTreeData> takeLargerElements();
69 
73  bool hasIntersections(const SurgSim::Math::Aabbd& aabb) const;
74 
79  void getIntersections(const SurgSim::Math::Aabbd& aabb, std::list<size_t>* result) const;
80 
81 private:
83  void recalculateAabb();
84 
85  virtual bool isEqual(const TreeData* data) const override;
86 
89 
91  std::list<Item> m_data;
92 };
93 
94 }
95 }
96 
97 #endif
AabbTreeData()
Constructor.
Definition: AabbTreeData.cpp:25
Definition: DriveElementFromInputBehavior.cpp:27
void getIntersections(const SurgSim::Math::Aabbd &aabb, std::list< size_t > *result) const
Check all items bounding boxes against the one passed as a parameter and append items that overlap to...
Definition: AabbTreeData.cpp:113
std::pair< SurgSim::Math::Aabbd, size_t > Item
Definition: AabbTreeData.h:47
size_t getSize() const
Definition: AabbTreeData.cpp:80
Internal class to hold a list of AABBs and their respective object ids, it can calculate the elements...
Definition: AabbTreeData.h:34
const SurgSim::Math::Aabbd & getAabb() const
Definition: AabbTreeData.cpp:69
Eigen::AlignedBox< double, 3 > Aabbd
Wrapper around the Eigen type.
Definition: Aabb.h:30
std::list< Item > m_data
The items that were added to this list.
Definition: AabbTreeData.h:91
Abstract base class for data stored in a Tree.
Definition: TreeData.h:29
bool isEmpty() const
Definition: AabbTreeData.cpp:75
void recalculateAabb()
Recalculate the aabb of this class, in case items where updated.
Definition: AabbTreeData.cpp:104
std::shared_ptr< AabbTreeData > takeLargerElements()
Split the current items into two geometric halves, keep the first half and return a pointer to the se...
Definition: AabbTreeData.cpp:85
virtual bool isEqual(const TreeData *data) const override
Returns true if the trees are equal; otherwise, returns false.
Definition: AabbTreeData.cpp:35
bool hasIntersections(const SurgSim::Math::Aabbd &aabb) const
Check whether there could be any intersections with a given bounding box.
Definition: AabbTreeData.cpp:124
SurgSim::Math::Aabbd m_aabb
AABB containg all items.
Definition: AabbTreeData.h:88
~AabbTreeData()
Destructor.
Definition: AabbTreeData.cpp:30
void add(const SurgSim::Math::Aabbd aabb, size_t id)
Add an item to the data.
Definition: AabbTreeData.cpp:63