AabbTreeData.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_DATASTRUCTURES_AABBTREEDATA_H
#define SURGSIM_DATASTRUCTURES_AABBTREEDATA_H
#include "SurgSim/DataStructures/TreeData.h"
#include "SurgSim/Math/Aabb.h"
#include <utility>
#include <list>
#include <memory>
namespace SurgSim
{
namespace DataStructures
{
class AabbTreeData : public TreeData
{
public:
typedef std::pair<SurgSim::Math::Aabbd, size_t> Item;
AabbTreeData();
AabbTreeData(const AabbTreeData& data);
explicit AabbTreeData(const std::list<Item>& data);
explicit AabbTreeData(std::list<Item>&& data);
~AabbTreeData();
void add(const SurgSim::Math::Aabbd aabb, size_t id);
const SurgSim::Math::Aabbd& getAabb() const;
bool isEmpty() const;
size_t getSize() const;
std::shared_ptr<AabbTreeData> takeLargerElements();
bool hasIntersections(const SurgSim::Math::Aabbd& aabb) const;
void getIntersections(const SurgSim::Math::Aabbd& aabb, std::list<size_t>* result) const;
private:
void recalculateAabb();
bool isEqual(const TreeData* data) const override;
SurgSim::Math::Aabbd m_aabb;
std::list<Item> m_data;
};
}
}
#endif
SurgSim::DataStructures::AabbTreeData::AabbTreeData
AabbTreeData()
Constructor.
Definition: AabbTreeData.cpp:26
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::DataStructures::AabbTreeData::Item
std::pair< SurgSim::Math::Aabbd, size_t > Item
Definition: AabbTreeData.h:38
SurgSim::DataStructures::AabbTreeData
Internal class to hold a list of AABBs and their respective object ids, it can calculate the elements...
Definition: AabbTreeData.h:34
Aabb.h
SurgSim::DataStructures::AabbTreeData::hasIntersections
bool hasIntersections(const SurgSim::Math::Aabbd &aabb) const
Check whether there could be any intersections with a given bounding box.
Definition: AabbTreeData.cpp:144
SurgSim::DataStructures::AabbTreeData::getAabb
const SurgSim::Math::Aabbd & getAabb() const
Definition: AabbTreeData.cpp:80
SurgSim::DataStructures::AabbTreeData::isEmpty
bool isEmpty() const
Definition: AabbTreeData.cpp:86
TreeData.h
SurgSim::DataStructures::AabbTreeData::getSize
size_t getSize() const
Definition: AabbTreeData.cpp:91
SurgSim::Math::Aabbd
Eigen::AlignedBox< double, 3 > Aabbd
Wrapper around the Eigen type.
Definition: Aabb.h:30
SurgSim::DataStructures::AabbTreeData::m_data
std::list< Item > m_data
The items that were added to this list.
Definition: AabbTreeData.h:98
SurgSim::DataStructures::TreeData
Abstract base class for data stored in a Tree.
Definition: TreeData.h:29
SurgSim::DataStructures::AabbTreeData::recalculateAabb
void recalculateAabb()
Recalculate the aabb of this class, in case items where updated.
Definition: AabbTreeData.cpp:124
SurgSim::DataStructures::AabbTreeData::getIntersections
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:133
SurgSim::DataStructures::AabbTreeData::takeLargerElements
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:96
SurgSim::DataStructures::AabbTreeData::isEqual
bool isEqual(const TreeData *data) const override
Returns true if the trees are equal; otherwise, returns false.
Definition: AabbTreeData.cpp:46
SurgSim::DataStructures::AabbTreeData::m_aabb
SurgSim::Math::Aabbd m_aabb
AABB containg all items.
Definition: AabbTreeData.h:95
SurgSim::DataStructures::AabbTreeData::~AabbTreeData
~AabbTreeData()
Destructor.
Definition: AabbTreeData.cpp:41
SurgSim::DataStructures::AabbTreeData::add
void add(const SurgSim::Math::Aabbd aabb, size_t id)
Add an item to the data.
Definition: AabbTreeData.cpp:74