Number5
Visualisierung 2 Project - Florian Schober (0828151, f.schober@live.com), Andreas Walch (0926780, walch.andreas89@gmail.com)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
QuadTree Class Reference

#include <QuadTree.hpp>

Classes

class  Level
 

Public Member Functions

 QuadTree (Application *app, uvec2 const &size, uint const maxDistance)
 
void resize (uvec2 const &size)
 
template<typename tFnc >
void fill (tFnc readIds)
 
bool findNear (uvec2 const &pos, OUT id_t &foundId, OUT uvec2 &foundPos, OUT float &foundDistance)
 
void maxDistance (uint const distance)
 
uint const maxDistance () const
 

Private Types

typedef Level< id_tDataLevel
 
typedef Level< BOOLEAN > MidLevel
 

Private Member Functions

void updateLayersParallel ()
 
void updateLayersSerial ()
 
void updateLayersBaseCell (uint const layer, uint const x, uint const y)
 
template<typename TBaseLayer , typename TCurrentLayer >
void updateLayerArea (TBaseLayer base, TCurrentLayer current, uint const offset_x, uint const offset_y, uint size)
 
template<typename TBaseLayer , typename TCurrentLayer >
void updateLayerCell (TBaseLayer base, TCurrentLayer current, uint const x, uint const y)
 

Private Attributes

Applicationm_app
 
DataLevel m_data
 
vector< MidLevelm_levels
 
uint m_maxDistance
 
array< auto_reset_event, 4 > m_updateLayersParallelMutex
 

Detailed Description

QuadTree hosts a quadtree-structure where the base-layer represents the data. It creates an image-pyramid where the next levels value is 0 for non-existing data underneath it, and 1 for existing data.

Definition at line 9 of file QuadTree.hpp.

Member Typedef Documentation

typedef Level<id_t> DataLevel
private

Definition at line 107 of file QuadTree.hpp.

typedef Level<BOOLEAN> MidLevel
private

Definition at line 108 of file QuadTree.hpp.

Constructor & Destructor Documentation

QuadTree ( Application app,
uvec2 const &  size,
uint const  maxDistance 
)

Constructs a QuadTree-object

Parameters
appThe global application object
sizeThe data-layer-size
maxDistanceThe max-distance in which to look for pickable objects

Definition at line 3 of file QuadTree.cpp.

Member Function Documentation

void fill ( tFnc  readIds)
inline

Fills the data-layer with values and rebuilds the image-pyramid.

Parameters
readIdsA function that is executed to fill the data-layer. It is supposed to take 1 parameter of the type id_t*.

Definition at line 138 of file QuadTree.hpp.

bool findNear ( uvec2 const &  pos,
OUT id_t foundId,
OUT uvec2 &  foundPos,
OUT float &  foundDistance 
)

Finds the nearest object to the given position.

Parameters
posThe position at which to look
foundIdThe found id
foundPosThe found position
foundDistanceThe found distance
Returns
Wheter an id was found or not

Definition at line 35 of file QuadTree.cpp.

void maxDistance ( uint const  distance)

Accessor to the max-distance in which to look for pickable objects

Parameters
distanceThe new max-distance in which to look for pickable objects

Definition at line 159 of file QuadTree.cpp.

uint const maxDistance ( ) const

Accessor to the max-distance in which to look for pickable objects

Returns
The max-distance in which to look for pickable objects

Definition at line 163 of file QuadTree.cpp.

void resize ( uvec2 const &  size)

Resizes the data-layer of the quad-tree and extends the image-pyramid by some layers if necessary.

Parameters
sizeThe new data-layer-size.

Definition at line 14 of file QuadTree.cpp.

void updateLayerArea ( TBaseLayer  base,
TCurrentLayer  current,
uint const  offset_x,
uint const  offset_y,
uint  size 
)
inlineprivate

Update an area of a layer based on the next larger layer.

Parameters
baseThe next larger layer
currentThe current layer
offset_xThe areas left border
offset_yThe areas top border
sizeThe size of the area (in x and y)

Definition at line 204 of file QuadTree.hpp.

void updateLayerCell ( TBaseLayer  base,
TCurrentLayer  current,
uint const  x,
uint const  y 
)
inlineprivate

Update a single cell of a layer based on the next larger layer

Parameters
baseThe next larger layer
currentThe current layer
xThe x-coordinate of the cell
yThe y-coordinate of the cell

Definition at line 219 of file QuadTree.hpp.

void updateLayersBaseCell ( uint const  layer,
uint const  x,
uint const  y 
)
private

Updates the image-pyramid "under" one cell.

Parameters
layerThe layer of this cell
xThe x-coordinate of this cell (in the layer)
yThe y-coordinate of this cell (in the layer)

Definition at line 169 of file QuadTree.cpp.

void updateLayersParallel ( )
private

Updates the image-pyramid multi-threaded.

Definition at line 193 of file QuadTree.cpp.

void updateLayersSerial ( )
private

Updates the image-pyramid single-threaded.

Definition at line 207 of file QuadTree.cpp.

Member Data Documentation

Application* m_app
private

The global application

Definition at line 111 of file QuadTree.hpp.

DataLevel m_data
private

The data-layer

Definition at line 112 of file QuadTree.hpp.

vector<MidLevel> m_levels
private

The image-pyramid

Definition at line 113 of file QuadTree.hpp.

uint m_maxDistance
private

The max-distance in which to look for pickable objects

Definition at line 114 of file QuadTree.hpp.

array<auto_reset_event, 4> m_updateLayersParallelMutex
private

Synchronization structures for parallel processing

Definition at line 115 of file QuadTree.hpp.


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