AabbTree.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_AABBTREE_H
#define SURGSIM_DATASTRUCTURES_AABBTREE_H
#include <list>
#include "SurgSim/DataStructures/Tree.h"
#include "SurgSim/DataStructures/AabbTreeData.h"
#include "SurgSim/Math/Aabb.h"
namespace SurgSim
{
namespace DataStructures
{
class AabbTreeNode;
class AabbTree : public Tree
{
public:
AabbTree();
explicit AabbTree(size_t maxObjectsPerNode);
virtual ~AabbTree();
size_t getMaxObjectsPerNode() const;
void add(const SurgSim::Math::Aabbd& aabb, size_t objectId);
void set(const std::list<AabbTreeData::Item>& items);
void set(std::list<AabbTreeData::Item>&& items);
const SurgSim::Math::Aabbd& getAabb() const;
typedef std::pair<std::shared_ptr<AabbTreeNode>, std::shared_ptr<AabbTreeNode>> TreeNodePairType;
std::list<TreeNodePairType> spatialJoin(const AabbTree& otherTree) const;
void spatialJoin(std::shared_ptr<AabbTreeNode> lhsParent,
std::shared_ptr<AabbTreeNode> rhsParent,
std::list<TreeNodePairType>* result) const;
private:
size_t m_maxObjectsPerNode;
std::shared_ptr<AabbTreeNode> m_typedRoot;
};
}
}
#endif
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::DataStructures::Tree
Basic tree structure.
Definition: Tree.h:32
Aabb.h
Tree.h
SurgSim::DataStructures::AabbTree
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
SurgSim::DataStructures::AabbTree::getAabb
const SurgSim::Math::Aabbd & getAabb() const
Definition: AabbTree.cpp:69
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
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::AabbTree::getMaxObjectsPerNode
size_t getMaxObjectsPerNode() const
Definition: AabbTree.cpp:64
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::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::AabbTree
AabbTree()
Constructor.
Definition: AabbTree.cpp:26
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::m_typedRoot
std::shared_ptr< AabbTreeNode > m_typedRoot
A typed version of the root for access without typecasting.
Definition: AabbTree.h:92