Support Forum       G3D Web Page     
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
G3D::FastPointHashGrid< Value, PosFunc > Class Template Reference

A multiset of values (i.e., with duplicates allowed) indexed efficiently by spatial location. More...

Classes

class  BoxIterator
 
class  CellIterator
 
class  Iterator
 
class  SphereIterator
 

Public Types

enum  { CURRENT = 0 }
 
typedef Array< Value, 15 > ValueArray
 

Public Member Functions

 FastPointHashGrid (float gatherRadiusHint=0.5f, int expectedNumCells=16)
 
Iterator begin () const
 
BoxIterator begin (const AABox &box) const
 
SphereIterator begin (const Sphere &sphere) const
 Iterates over all values that are contained within the sphere. More...
 
CellIterator beginCell ()
 Iterates over non-empty cells, each of which contains a ValueArray. More...
 
float cellWidth () const
 
void clear (float gatherRadiusHint=CURRENT, int newExpectedNumCells=CURRENT)
 
void debugPrintStatistics () const
 
void fastClear ()
 Removes all elements but does not release the underlying structure. More...
 
void insert (const Value &v)
 If the same value is inserted multiple times, it will appear multiple times (which is usually desirable). More...
 
void insert (const Array< Value > &array)
 
int numCells () const
 Actual number of grid cells currently allocated. More...
 
int size () const
 Returns the number of elements. More...
 
TableTypeunderlyingTable () const
 

Protected Types

typedef FastPODTable< Vector4int16, ValueArray, HashTrait< Vector4int16 >, EqualsTrait< Vector4int16 >, false > TableType
 

Protected Member Functions

Vector4int16 toCell (const Vector3 &pos) const
 

Static Protected Member Functions

static float gatherRadiusToCellWidth (float r)
 Increase this value if the cost of iterating over cells seems high. More...
 

Protected Attributes

float m_cellsPerMeter
 
float m_metersPerCell
 
int m_size
 
TableTypem_table
 

Detailed Description

template<typename Value, class PosFunc = PositionTrait<Value>>
class G3D::FastPointHashGrid< Value, PosFunc >

A multiset of values (i.e., with duplicates allowed) indexed efficiently by spatial location.

This is optimized for 64-bit processors. It generally performs at least as well as PointHashGrid (although it does not support remove operations), is about 2x faster to build, and has a simpler structure that is more amenable to serialization.

See also
PointHashGrid, PointKDTree, FastPODTable

Member Typedef Documentation

◆ TableType

template<typename Value, class PosFunc = PositionTrait<Value>>
typedef FastPODTable<Vector4int16, ValueArray, HashTrait<Vector4int16>, EqualsTrait<Vector4int16>, false> G3D::FastPointHashGrid< Value, PosFunc >::TableType
protected

◆ ValueArray

template<typename Value, class PosFunc = PositionTrait<Value>>
typedef Array<Value, 15> G3D::FastPointHashGrid< Value, PosFunc >::ValueArray

Member Enumeration Documentation

◆ anonymous enum

template<typename Value, class PosFunc = PositionTrait<Value>>
anonymous enum
Enumerator
CURRENT 

Constructor & Destructor Documentation

◆ FastPointHashGrid()

template<typename Value, class PosFunc = PositionTrait<Value>>
G3D::FastPointHashGrid< Value, PosFunc >::FastPointHashGrid ( float  gatherRadiusHint = 0.5f,
int  expectedNumCells = 16 
)
inline

Member Function Documentation

◆ begin() [1/3]

template<typename Value, class PosFunc = PositionTrait<Value>>
Iterator G3D::FastPointHashGrid< Value, PosFunc >::begin ( ) const
inline

◆ begin() [2/3]

template<typename Value, class PosFunc = PositionTrait<Value>>
BoxIterator G3D::FastPointHashGrid< Value, PosFunc >::begin ( const AABox box) const
inline

◆ begin() [3/3]

template<typename Value, class PosFunc = PositionTrait<Value>>
SphereIterator G3D::FastPointHashGrid< Value, PosFunc >::begin ( const Sphere sphere) const
inline

Iterates over all values that are contained within the sphere.

◆ beginCell()

template<typename Value, class PosFunc = PositionTrait<Value>>
CellIterator G3D::FastPointHashGrid< Value, PosFunc >::beginCell ( )
inline

Iterates over non-empty cells, each of which contains a ValueArray.

◆ cellWidth()

template<typename Value, class PosFunc = PositionTrait<Value>>
float G3D::FastPointHashGrid< Value, PosFunc >::cellWidth ( ) const
inline

◆ clear()

template<typename Value, class PosFunc = PositionTrait<Value>>
void G3D::FastPointHashGrid< Value, PosFunc >::clear ( float  gatherRadiusHint = CURRENT,
int  newExpectedNumCells = CURRENT 
)
inline
Parameters
gatherRadiusHintIf CURRENT, use the current cell width
newExpectedNumCellsIf CURRENT, use the current expected number of cells

Referenced by G3D::FastPointHashGrid< Value, PosFunc >::FastPointHashGrid().

◆ debugPrintStatistics()

template<typename Value, class PosFunc = PositionTrait<Value>>
void G3D::FastPointHashGrid< Value, PosFunc >::debugPrintStatistics ( ) const
inline

◆ fastClear()

template<typename Value, class PosFunc = PositionTrait<Value>>
void G3D::FastPointHashGrid< Value, PosFunc >::fastClear ( )
inline

Removes all elements but does not release the underlying structure.

◆ gatherRadiusToCellWidth()

template<typename Value, class PosFunc = PositionTrait<Value>>
static float G3D::FastPointHashGrid< Value, PosFunc >::gatherRadiusToCellWidth ( float  r)
inlinestaticprotected

Increase this value if the cost of iterating over cells seems high.

Decrease this value if the cost of rejecting points that are outside of a box seems high

Currently the best sphere gather performance seems to be when the cell width is slightly smaller than the radius of the gather sphere, so that one can expect between 27 and 64 cells to be gathered.

Referenced by G3D::FastPointHashGrid< Value, PosFunc >::clear().

◆ insert() [1/2]

template<typename Value, class PosFunc = PositionTrait<Value>>
void G3D::FastPointHashGrid< Value, PosFunc >::insert ( const Value &  v)
inline

If the same value is inserted multiple times, it will appear multiple times (which is usually desirable).

Referenced by G3D::FastPointHashGrid< Value, PosFunc >::insert().

◆ insert() [2/2]

template<typename Value, class PosFunc = PositionTrait<Value>>
void G3D::FastPointHashGrid< Value, PosFunc >::insert ( const Array< Value > &  array)
inline

◆ numCells()

template<typename Value, class PosFunc = PositionTrait<Value>>
int G3D::FastPointHashGrid< Value, PosFunc >::numCells ( ) const
inline

Actual number of grid cells currently allocated.

See also
size()

◆ size()

template<typename Value, class PosFunc = PositionTrait<Value>>
int G3D::FastPointHashGrid< Value, PosFunc >::size ( ) const
inline

Returns the number of elements.

See also
numCells

◆ toCell()

template<typename Value, class PosFunc = PositionTrait<Value>>
Vector4int16 G3D::FastPointHashGrid< Value, PosFunc >::toCell ( const Vector3 pos) const
inlineprotected

◆ underlyingTable()

template<typename Value, class PosFunc = PositionTrait<Value>>
TableType* G3D::FastPointHashGrid< Value, PosFunc >::underlyingTable ( ) const
inline

Member Data Documentation

◆ m_cellsPerMeter

template<typename Value, class PosFunc = PositionTrait<Value>>
float G3D::FastPointHashGrid< Value, PosFunc >::m_cellsPerMeter
protected

◆ m_metersPerCell

template<typename Value, class PosFunc = PositionTrait<Value>>
float G3D::FastPointHashGrid< Value, PosFunc >::m_metersPerCell
protected

◆ m_size

template<typename Value, class PosFunc = PositionTrait<Value>>
int G3D::FastPointHashGrid< Value, PosFunc >::m_size
protected

◆ m_table

template<typename Value, class PosFunc = PositionTrait<Value>>
TableType* G3D::FastPointHashGrid< Value, PosFunc >::m_table
protected

documentation generated on Wed Nov 24 2021 08:01:55 using doxygen 1.8.15