igor::iQuadtree< F > Class Template Reference

#include <iQuadtree.h>

Classes

struct  iQuadtreeNode
 
struct  iQuadtreeObject
 

Public Types

using Object = iQuadtreeObject
 
using Node = iQuadtreeNode
 
using ObjectPtr = std::shared_ptr< iQuadtreeObject >
 
using NodePtr = std::shared_ptr< iQuadtreeNode >
 
using Objects = std::vector< ObjectPtr >
 

Public Member Functions

 iQuadtree (const iaRectangle< F > &box, const uint32 splitThreshold=4, const uint32 maxDepth=16)
 
virtual ~iQuadtree ()=default
 
void insert (const std::shared_ptr< iQuadtreeObject > object)
 
void remove (const std::shared_ptr< iQuadtreeObject > object)
 
void update (const std::shared_ptr< iQuadtreeObject > object, const iaVector2< F > &position)
 
void update (const std::shared_ptr< iQuadtreeObject > object, const iaCircle< F > &circle)
 
const std::shared_ptr< iQuadtreeNode > & getRoot () const
 
void query (const iaCircle< F > &circle, std::vector< std::shared_ptr< iQuadtreeObject > > &objects)
 
void query (const iaRectangle< F > &rectangle, std::vector< std::shared_ptr< iQuadtreeObject > > &objects)
 
void clear ()
 
const iaRectangle< F > & getRootBox () const
 

Detailed Description

template<typename F>
class igor::iQuadtree< F >

quadtree implementation

Member Typedef Documentation

◆ Node

template<typename F >
using igor::iQuadtree< F >::Node = iQuadtreeNode

◆ NodePtr

template<typename F >
using igor::iQuadtree< F >::NodePtr = std::shared_ptr<iQuadtreeNode>

◆ Object

template<typename F >
using igor::iQuadtree< F >::Object = iQuadtreeObject

◆ ObjectPtr

template<typename F >
using igor::iQuadtree< F >::ObjectPtr = std::shared_ptr<iQuadtreeObject>

◆ Objects

template<typename F >
using igor::iQuadtree< F >::Objects = std::vector<ObjectPtr>

Constructor & Destructor Documentation

◆ iQuadtree()

template<typename F >
iQuadtree::iQuadtree ( const iaRectangle< F > &  box,
const uint32  splitThreshold = 4,
const uint32  maxDepth = 16 
)

creates the quadtree including the root node

Parameters
boxvolume of the whole quadtree
splitThresholdthreshold count of objects on a node before splitting the node
maxDepththe maximum depth of the tree

◆ ~iQuadtree()

template<typename F >
virtual igor::iQuadtree< F >::~iQuadtree ( )
virtualdefault

dtor

Member Function Documentation

◆ clear()

template<typename F >
void iQuadtree::clear ( )

clears the tree

◆ getRoot()

template<typename F >
const std::shared_ptr< typename iQuadtree< F >::iQuadtreeNode > & iQuadtree::getRoot ( ) const
Returns
root of tree

◆ getRootBox()

template<typename F >
const iaRectangle< F > & iQuadtree::getRootBox ( ) const
Returns
dimensions of quadtree

◆ insert()

template<typename F >
void iQuadtree::insert ( const std::shared_ptr< iQuadtreeObject object)

insert object at given position

Parameters
userDatathe user data

◆ query() [1/2]

template<typename F >
void iQuadtree::query ( const iaCircle< F > &  circle,
std::vector< std::shared_ptr< iQuadtreeObject > > &  objects 
)

queries for objects within given circle

Parameters
circlethe given circle
objectsthe resulting found objects

◆ query() [2/2]

template<typename F >
void iQuadtree::query ( const iaRectangle< F > &  rectangle,
std::vector< std::shared_ptr< iQuadtreeObject > > &  objects 
)

queries for objects within given rectangle

Parameters
rectanglethe given rectangle
objectsthe resulting found objects

◆ remove()

template<typename F >
void iQuadtree::remove ( const std::shared_ptr< iQuadtreeObject object)

remove given object

Parameters
userDatathe user data

◆ update() [1/2]

template<typename F >
void iQuadtree::update ( const std::shared_ptr< iQuadtreeObject object,
const iaCircle< F > &  circle 
)

updates position and radius of given object

Parameters
objectthe object to update
circlethe new position and radius of the object

◆ update() [2/2]

template<typename F >
void iQuadtree::update ( const std::shared_ptr< iQuadtreeObject object,
const iaVector2< F > &  position 
)

updates position of given object

Parameters
objectthe object to update
positionthe new position of the object

The documentation for this class was generated from the following files: