Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cQuadtree Class Reference

#include <cQuadtree.h>

Inheritance diagram for GrayLib::cQuadtree:
GrayLib::cQuadCommon

Public Types

typedef cArrayPtr< IQuadObject > ARRAYOBJ_t
 
- Public Types inherited from GrayLib::cQuadCommon
typedef double DVALUE_t
 
typedef cVecT2< DVALUE_tPOINTQ_t
 
typedef cRectFT< DVALUE_tRECTQ_t
 

Public Member Functions

 cQuadtree (RECTQ_t boundary)
 
 ~cQuadtree ()
 
bool isEmptyQuad () const
 
void RemoveAll ()
 
const RECTQ_tget_Boundary () const
 
bool SetBoundary (const RECTQ_t &rect, OUT ARRAYOBJ_t &aBumped)
 
bool AddObject (const RECTQ_t &rect, IQuadObject *pObj)
 
bool AddObject (IQuadObject *pObj)
 
void AddObjectGrow (IQuadObject *pObj)
 
bool RemoveObject (const RECTQ_t &rect, IQuadObject *pObj)
 
bool RemoveObject (IQuadObject *pObj)
 
bool VisitObjectsOverlap (const RECTQ_t &rect, IQuadVisit *pVisit) const
 
 UNITTEST_FRIEND (cQuadtree)
 

Protected Member Functions

RECTQ_t GetRect (size_t i, const POINTQ_t &ptCenter) const
 
bool CollapseCheck (size_t i)
 

Detailed Description

A 2d space we need to sub divide for fast access. e.g. Maps. https://en.wikipedia.org/wiki/Quadtree Similar to 3D ISpatialTest

Member Typedef Documentation

◆ ARRAYOBJ_t

Constructor & Destructor Documentation

◆ cQuadtree()

GrayLib::cQuadtree::cQuadtree ( RECTQ_t  boundary)

◆ ~cQuadtree()

GrayLib::cQuadtree::~cQuadtree ( )

Member Function Documentation

◆ AddObject() [1/2]

bool GrayLib::cQuadtree::AddObject ( const RECTQ_t rect,
IQuadObject *  pObj 
)

ASSUME object is not already here ! ASSUME object fits into parent. rect MUST be equal or fully inside this.

◆ AddObject() [2/2]

bool GrayLib::cQuadtree::AddObject ( IQuadObject *  pObj)
inline

ASSUME object is not already here ! ASSUME object fits into parent.

◆ AddObjectGrow()

void GrayLib::cQuadtree::AddObjectGrow ( IQuadObject *  pObj)

grow the boundary to fit this object.

Note
Used only at top level.

◆ CollapseCheck()

bool GrayLib::cQuadtree::CollapseCheck ( size_t  i)
protected

Collapse a branch if its empty.

◆ get_Boundary()

const RECTQ_t& GrayLib::cQuadtree::get_Boundary ( ) const
inline

◆ GetRect()

cQuadtree::RECTQ_t GrayLib::cQuadtree::GetRect ( size_t  i,
const POINTQ_t ptCenter 
) const
protected

Get my child quads.

◆ isEmptyQuad()

bool GrayLib::cQuadtree::isEmptyQuad ( ) const

◆ RemoveAll()

void GrayLib::cQuadtree::RemoveAll ( )

◆ RemoveObject() [1/2]

bool GrayLib::cQuadtree::RemoveObject ( const RECTQ_t rect,
IQuadObject *  pObj 
)

◆ RemoveObject() [2/2]

bool GrayLib::cQuadtree::RemoveObject ( IQuadObject *  pObj)
inline

◆ SetBoundary()

bool GrayLib::cQuadtree::SetBoundary ( const RECTQ_t rect,
OUT ARRAYOBJ_t aBumped 
)

Set new boundary. We must re-balance this and all its existing children ! Set the boundary bigger in order to make this more efficient on subsequent adds.

  • aBumped = reject/remove all items that didn't fit in the new boundary.

◆ UNITTEST_FRIEND()

GrayLib::cQuadtree::UNITTEST_FRIEND ( cQuadtree  )

◆ VisitObjectsOverlap()

bool GrayLib::cQuadtree::VisitObjectsOverlap ( const RECTQ_t rect,
IQuadVisit *  pVisit 
) const

Find the objects in this box (or its children).

Returns
false = pVisit indicated to stop search.

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