ARGoS  3
A parallel, multi-engine simulator for swarm robotics
argos::CAbstractSpaceHash< ENTITY > Class Template Reference

The abstract definition of a space hash. More...

#include <space_hash.h>

+ Inheritance diagram for argos::CAbstractSpaceHash< ENTITY >:

List of all members.

Public Types

typedef CSet< ENTITY * > TEntityList
 Type definition for the list of entities held by the space hash.

Public Member Functions

 CAbstractSpaceHash ()
 Class constructor.
virtual ~CAbstractSpaceHash ()
 Class destructor.
virtual void AddEntity (ENTITY &c_entity)
 Adds an entity to the space hash.
TEntityListGetEntities ()
 Returns the list of entities held by this space hash.
virtual void RemoveEntity (ENTITY &c_entity)
 Remove an entity from the space hash.
size_t GetSize ()
 Returns the size of the space hash.
virtual void SetSize (size_t un_size)
 Sets the size of the space hash.
CVector3GetCellSize ()
 Returns the size of the cells of the space hash.
CVector3GetInvCellSize ()
 Returns the inverse size of the cells of the space hash.
virtual void SetCellSize (const CVector3 &c_cell_size)
 Sets the size of the cells of the space hash.
virtual void Update ()=0
 Updates the entire space hash.
virtual void UpdateCell (SInt32 n_x, SInt32 n_y, SInt32 n_z, ENTITY &c_entity)=0
 Adds an entity to a cell of the space hash.
virtual SInt32 SpaceToHashTable (Real f_coord, UInt32 un_axis)
 Converts a single space coordinate into a space hash cell coordinate.
virtual Real HashTableToSpace (SInt32 n_coord, UInt32 un_axis)
 Converts a single space hash cell coordinate into a space coordinate.
virtual void SpaceToHashTable (SInt32 &n_i, SInt32 &n_j, SInt32 &n_k, const CVector3 &c_pos)
 Converts a space position into a space hash cell The values are written into n_i, n_j, and n_k.
virtual bool CheckCell (SInt32 n_i, SInt32 n_j, SInt32 n_k, TEntityList &t_entities)=0
 Looks for entities to process in a cell.
virtual void Dump (CARGoSLog &c_os)=0

Protected Member Functions

UInt32 CoordinateHash (SInt32 n_i, SInt32 n_j, SInt32 n_k)
 Calculates the hash of a space hash coordinate.

Detailed Description

template<class ENTITY>
class argos::CAbstractSpaceHash< ENTITY >

The abstract definition of a space hash.

This template class defines all the basic functionality of a space hash. This class is used only internally. To define your own space hash, you have to subclass CSpaceHash.

Parameters:
ENTITYThe type of the entity held by the space hash
See also:
CSpaceHash

Definition at line 34 of file space_hash.h.


Member Typedef Documentation

template<class ENTITY>
typedef CSet<ENTITY*> argos::CAbstractSpaceHash< ENTITY >::TEntityList

Type definition for the list of entities held by the space hash.

Definition at line 41 of file space_hash.h.


Constructor & Destructor Documentation

template<class ENTITY>
argos::CAbstractSpaceHash< ENTITY >::CAbstractSpaceHash ( ) [inline]

Class constructor.

The size of the space hash (the number of buckets) is set to zero. To be able to use the space hash, you first must set the size to an appropriate value.

See also:
SetSize()

Definition at line 52 of file space_hash.h.

template<class ENTITY>
virtual argos::CAbstractSpaceHash< ENTITY >::~CAbstractSpaceHash ( ) [inline, virtual]

Class destructor.

Definition at line 57 of file space_hash.h.


Member Function Documentation

template<class ENTITY>
virtual void argos::CAbstractSpaceHash< ENTITY >::AddEntity ( ENTITY &  c_entity) [inline, virtual]

Adds an entity to the space hash.

Parameters:
c_entityThe entity to add.

Implements argos::CPositionalIndex< ENTITY >.

Definition at line 63 of file space_hash.h.

template<class ENTITY>
virtual bool argos::CAbstractSpaceHash< ENTITY >::CheckCell ( SInt32  n_i,
SInt32  n_j,
SInt32  n_k,
TEntityList t_entities 
) [pure virtual]

Looks for entities to process in a cell.

Parameters:
n_iThe X coordinate of the space hash cell.
n_jThe Y coordinate of the space hash cell.
n_kThe Z coordinate of the space hash cell.
t_entitiesThe resulting list of entities to process.
Returns:
true if new entities were added to t_entities.
template<class ENTITY>
UInt32 argos::CAbstractSpaceHash< ENTITY >::CoordinateHash ( SInt32  n_i,
SInt32  n_j,
SInt32  n_k 
) [inline, protected]

Calculates the hash of a space hash coordinate.

Parameters:
n_iThe X coordinate of the space hash cell.
n_jThe Y coordinate of the space hash cell.
n_kThe Z coordinate of the space hash cell.
Returns:
The hash of a space hash coordinate.

Definition at line 220 of file space_hash.h.

template<class ENTITY>
virtual void argos::CAbstractSpaceHash< ENTITY >::Dump ( CARGoSLog c_os) [pure virtual]
template<class ENTITY>
CVector3& argos::CAbstractSpaceHash< ENTITY >::GetCellSize ( ) [inline]

Returns the size of the cells of the space hash.

The size is returned in meters.

Returns:
The size of the cells of the space hash.

Definition at line 112 of file space_hash.h.

template<class ENTITY>
TEntityList& argos::CAbstractSpaceHash< ENTITY >::GetEntities ( ) [inline]

Returns the list of entities held by this space hash.

Returns:
The list of entities held by this space hash.

Definition at line 71 of file space_hash.h.

template<class ENTITY>
CVector3& argos::CAbstractSpaceHash< ENTITY >::GetInvCellSize ( ) [inline]

Returns the inverse size of the cells of the space hash.

It is used to convert measures of the space into cells of the space hash.

Returns:
The size of the cells of the space hash.
See also:
SpaceToHashTable

Definition at line 122 of file space_hash.h.

template<class ENTITY>
size_t argos::CAbstractSpaceHash< ENTITY >::GetSize ( ) [inline]

Returns the size of the space hash.

The size corresponds to the number of buckets.

Returns:
The size of the space hash.

Definition at line 94 of file space_hash.h.

template<class ENTITY>
virtual Real argos::CAbstractSpaceHash< ENTITY >::HashTableToSpace ( SInt32  n_coord,
UInt32  un_axis 
) [inline, virtual]

Converts a single space hash cell coordinate into a space coordinate.

Parameters:
n_coordThe value of the X/Y/Z space hash coordinate.
un_axisthe axis: 0 -> X, 1 -> Y, 2 -> Z.
Returns:
The X/Y/Z coordinate in the space.

Definition at line 174 of file space_hash.h.

template<class ENTITY>
virtual void argos::CAbstractSpaceHash< ENTITY >::RemoveEntity ( ENTITY &  c_entity) [inline, virtual]

Remove an entity from the space hash.

Parameters:
c_entityThe entity to remove.

Implements argos::CPositionalIndex< ENTITY >.

Definition at line 79 of file space_hash.h.

template<class ENTITY>
virtual void argos::CAbstractSpaceHash< ENTITY >::SetCellSize ( const CVector3 c_cell_size) [inline, virtual]

Sets the size of the cells of the space hash.

The size is measured in meters.

Parameters:
c_cell_sizeThe new size for the cells of the space hash.

Definition at line 131 of file space_hash.h.

template<class ENTITY>
virtual void argos::CAbstractSpaceHash< ENTITY >::SetSize ( size_t  un_size) [inline, virtual]

Sets the size of the space hash.

The size corresponds to the number of buckets.

Parameters:
un_sizeThe size of the space hash.

Reimplemented in argos::CSpaceHashNative< Element, Updater >.

Definition at line 103 of file space_hash.h.

template<class ENTITY>
virtual SInt32 argos::CAbstractSpaceHash< ENTITY >::SpaceToHashTable ( Real  f_coord,
UInt32  un_axis 
) [inline, virtual]

Converts a single space coordinate into a space hash cell coordinate.

Parameters:
f_coordThe value of the X/Y/Z coordinate in meters.
un_axisthe axis: 0 -> X, 1 -> Y, 2 -> Z.
Returns:
The X/Y/Z coordinate of the corresponding space hash cell.

Definition at line 163 of file space_hash.h.

template<class ENTITY>
virtual void argos::CAbstractSpaceHash< ENTITY >::SpaceToHashTable ( SInt32 n_i,
SInt32 n_j,
SInt32 n_k,
const CVector3 c_pos 
) [inline, virtual]

Converts a space position into a space hash cell The values are written into n_i, n_j, and n_k.

Parameters:
n_iThe X coordinate of the space hash cell.
n_jThe Y coordinate of the space hash cell.
n_kThe Z coordinate of the space hash cell.
c_posThe value position in meters.

Definition at line 187 of file space_hash.h.

template<class ENTITY>
virtual void argos::CAbstractSpaceHash< ENTITY >::Update ( ) [pure virtual]
template<class ENTITY>
virtual void argos::CAbstractSpaceHash< ENTITY >::UpdateCell ( SInt32  n_x,
SInt32  n_y,
SInt32  n_z,
ENTITY &  c_entity 
) [pure virtual]

Adds an entity to a cell of the space hash.

Parameters:
n_xThe x coordinate of the cell.
n_yThe y coordinate of the cell.
n_zThe z coordinate of the cell.
c_entityThe entity to add.

Implemented in argos::CSpaceHashNative< Element, Updater >.


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