NCBI C++ ToolKit
Public Types | Public Member Functions | Protected Attributes | List of all members
CSpatialHash2D< T > Class Template Reference

Search Toolkit Book for CSpatialHash2D

class CSpatialHash2D Class for simple 2D spatial organization that allows for some collision checking and visibility determination. More...

#include <gui/opengl/spatialhash2d.hpp>

+ Inheritance diagram for CSpatialHash2D< T >:
+ Collaboration diagram for CSpatialHash2D< T >:

Public Types

typedef CVect2< float > TVecf
 floating point type for actual (real) positions of data More...
 
typedef CVect2< intTVeci
 Storage index in table. More...
 
typedef T TElemType
 Element type stored in table (e.g. indices or pointers to user data) More...
 
typedef vector< TElemTypeTTableType
 Storage table type. More...
 

Public Member Functions

 CSpatialHash2D ()
 
virtual ~CSpatialHash2D ()
 
int GetTableIdx (const TVeci &item) const
 
void Resize ()
 
void ResizeFast ()
 
void Clear ()
 
TElemTypeGet (const TVeci &item)
 
const TElemTypeGet (const TVeci &item) const
 
TElemType GetSafe (const TVeci &item) const
 Return an empty TElemType if index is out of range. More...
 
bool InBounds (const TVeci &item) const
 Return true if the index falls within the current table. More...
 
TTableTypeGetTable ()
 
const TTableTypeGetTable () const
 
void SetMin (TVeci &idx)
 
void SetMax (TVeci &idx)
 
void ResizeGrid (const CGlPane &pane, float resolution, bool tilex=true, bool tiley=true)
 
const TVeciGetMin ()
 Get min/max indices for current (whole) grid. More...
 
const TVeciGetMax ()
 
TVeci GetMinVisIndex () const
 Get min/max visible indices for grid (as per UpdateVisibility) More...
 
TVeci GetMaxVisIndex () const
 
int GetWidth () const
 Get width/height of grid. More...
 
int GetHeight () const
 
TVecfGetMinPos ()
 Get min/max model coords spanned by the grid. More...
 
TVecfGetMaxPos ()
 
virtual void UpdateVisibility (const TModelRect &)
 
const CVect2< float > & GetScale () const
 

Protected Attributes

CVect2< float > m_PrevVisMin
 Visible rectangle area from previous call to UpdateVisibility. More...
 
CVect2< float > m_PrevVisMax
 
CVect2< intm_VisMinIdx
 Range of visible indices from previous call to UpdateVisibility. More...
 
CVect2< intm_VisMaxIdx
 
TTableType m_GridTable
 Hashtable that stores the data elements. More...
 
TVeci m_MinIdx
 Min/Max indicies in the table. More...
 
TVeci m_MaxIdx
 
TVecf m_MinPos
 Geometric region subdivided by this data structure. More...
 
TVecf m_MaxPos
 
int m_Width
 Width and heigt of table (m_MaxIdx-m_MinIdx) More...
 
int m_Height
 
CVect2< float > m_Scale
 Current scaling factor of model for viewing in x and y. More...
 
float m_ResolutionX
 Divisor for dividing model-space resolution into table indices. More...
 
float m_ResolutionY
 
float m_ResolutionScaler
 

Detailed Description

template<class T>
class CSpatialHash2D< T >

class CSpatialHash2D Class for simple 2D spatial organization that allows for some collision checking and visibility determination.

Not really a hash-table since it seems to make more sense in 2D to go with a dense array rather than a hash table where unuused regions would not have a node in the array.

Addressing into the spatial datastructure is done simply by subtracting the lower left position of the bounded area from the point (moving it to 0) and then dividing by the resolution to get an index into the table.

Definition at line 63 of file spatialhash2d.hpp.

Member Typedef Documentation

◆ TElemType

template<class T >
typedef T CSpatialHash2D< T >::TElemType

Element type stored in table (e.g. indices or pointers to user data)

Definition at line 71 of file spatialhash2d.hpp.

◆ TTableType

template<class T >
typedef vector<TElemType> CSpatialHash2D< T >::TTableType

Storage table type.

Definition at line 73 of file spatialhash2d.hpp.

◆ TVecf

template<class T >
typedef CVect2<float> CSpatialHash2D< T >::TVecf

floating point type for actual (real) positions of data

Definition at line 67 of file spatialhash2d.hpp.

◆ TVeci

template<class T >
typedef CVect2<int> CSpatialHash2D< T >::TVeci

Storage index in table.

Definition at line 69 of file spatialhash2d.hpp.

Constructor & Destructor Documentation

◆ CSpatialHash2D()

template<class T >
CSpatialHash2D< T >::CSpatialHash2D

Definition at line 171 of file spatialhash2d.hpp.

◆ ~CSpatialHash2D()

template<class T >
CSpatialHash2D< T >::~CSpatialHash2D
virtual

Definition at line 185 of file spatialhash2d.hpp.

Member Function Documentation

◆ Clear()

template<class T >
void CSpatialHash2D< T >::Clear ( void  )
inline

Definition at line 82 of file spatialhash2d.hpp.

Referenced by CPhyloTreeDataSource::Clean(), and CPhyloTreePS::x_UpdateVoxels().

◆ Get() [1/2]

template<class T >
TElemType& CSpatialHash2D< T >::Get ( const TVeci item)
inline

◆ Get() [2/2]

template<class T >
const TElemType& CSpatialHash2D< T >::Get ( const TVeci item) const
inline

Definition at line 86 of file spatialhash2d.hpp.

◆ GetHeight()

template<class T >
int CSpatialHash2D< T >::GetHeight ( ) const
inline

Definition at line 121 of file spatialhash2d.hpp.

Referenced by CPhyloTreePS::x_ApplyRepulsiveForcesHashed().

◆ GetMax()

template<class T >
const TVeci& CSpatialHash2D< T >::GetMax ( void  )
inline

Definition at line 113 of file spatialhash2d.hpp.

Referenced by CPhyloTreePS::x_ApplyRepulsiveForcesHashed().

◆ GetMaxPos()

template<class T >
TVecf& CSpatialHash2D< T >::GetMaxPos ( )
inline

Definition at line 125 of file spatialhash2d.hpp.

◆ GetMaxVisIndex()

template<class T >
TVeci CSpatialHash2D< T >::GetMaxVisIndex ( ) const
inline

Definition at line 117 of file spatialhash2d.hpp.

Referenced by CTreeGraphicsModel::x_RenderNodes().

◆ GetMin()

template<class T >
const TVeci& CSpatialHash2D< T >::GetMin ( void  )
inline

Get min/max indices for current (whole) grid.

Definition at line 112 of file spatialhash2d.hpp.

Referenced by CPhyloTreePS::x_ApplyRepulsiveForcesHashed().

◆ GetMinPos()

template<class T >
TVecf& CSpatialHash2D< T >::GetMinPos ( )
inline

Get min/max model coords spanned by the grid.

Definition at line 124 of file spatialhash2d.hpp.

◆ GetMinVisIndex()

template<class T >
TVeci CSpatialHash2D< T >::GetMinVisIndex ( ) const
inline

Get min/max visible indices for grid (as per UpdateVisibility)

Definition at line 116 of file spatialhash2d.hpp.

Referenced by CTreeGraphicsModel::x_RenderNodes().

◆ GetSafe()

template<class T >
T CSpatialHash2D< T >::GetSafe ( const TVeci item) const

Return an empty TElemType if index is out of range.

Definition at line 190 of file spatialhash2d.hpp.

◆ GetScale()

template<class T >
const CVect2<float>& CSpatialHash2D< T >::GetScale ( ) const
inline

Definition at line 129 of file spatialhash2d.hpp.

Referenced by IPhyloTreeRender::x_SetElementVisibility().

◆ GetTable() [1/2]

template<class T >
TTableType& CSpatialHash2D< T >::GetTable ( )
inline

Definition at line 94 of file spatialhash2d.hpp.

◆ GetTable() [2/2]

template<class T >
const TTableType& CSpatialHash2D< T >::GetTable ( ) const
inline

Definition at line 95 of file spatialhash2d.hpp.

◆ GetTableIdx()

template<class T >
int CSpatialHash2D< T >::GetTableIdx ( const TVeci item) const
inline

Definition at line 78 of file spatialhash2d.hpp.

Referenced by CSpatialHash2D< std::vector< int > >::Get().

◆ GetWidth()

template<class T >
int CSpatialHash2D< T >::GetWidth ( ) const
inline

Get width/height of grid.

Definition at line 120 of file spatialhash2d.hpp.

Referenced by CPhyloTreePS::x_ApplyRepulsiveForcesHashed().

◆ InBounds()

template<class T >
bool CSpatialHash2D< T >::InBounds ( const TVeci item) const

Return true if the index falls within the current table.

Definition at line 201 of file spatialhash2d.hpp.

Referenced by CTreeGraphicsModel::x_RenderNodes().

◆ Resize()

template<class T >
void CSpatialHash2D< T >::Resize ( void  )
inline

Definition at line 80 of file spatialhash2d.hpp.

◆ ResizeFast()

template<class T >
void CSpatialHash2D< T >::ResizeFast ( )
inline

Definition at line 81 of file spatialhash2d.hpp.

Referenced by CPhyloTreePS::x_UpdateVoxels().

◆ ResizeGrid()

template<class T >
void CSpatialHash2D< T >::ResizeGrid ( const CGlPane pane,
float  resolution,
bool  tilex = true,
bool  tiley = true 
)

◆ SetMax()

template<class T >
void CSpatialHash2D< T >::SetMax ( TVeci idx)
inline

Definition at line 102 of file spatialhash2d.hpp.

Referenced by CPhyloTreePS::x_UpdateVoxels().

◆ SetMin()

template<class T >
void CSpatialHash2D< T >::SetMin ( TVeci idx)
inline

Definition at line 97 of file spatialhash2d.hpp.

Referenced by CPhyloTreePS::x_UpdateVoxels().

◆ UpdateVisibility()

template<class T >
virtual void CSpatialHash2D< T >::UpdateVisibility ( const TModelRect )
inlinevirtual

Reimplemented in CTreeCollisionModel2D.

Definition at line 127 of file spatialhash2d.hpp.

Member Data Documentation

◆ m_GridTable

template<class T >
TTableType CSpatialHash2D< T >::m_GridTable
protected

◆ m_Height

template<class T >
int CSpatialHash2D< T >::m_Height
protected

◆ m_MaxIdx

template<class T >
TVeci CSpatialHash2D< T >::m_MaxIdx
protected

◆ m_MaxPos

template<class T >
TVecf CSpatialHash2D< T >::m_MaxPos
protected

Definition at line 150 of file spatialhash2d.hpp.

Referenced by CSpatialHash2D< std::vector< int > >::GetMaxPos().

◆ m_MinIdx

template<class T >
TVeci CSpatialHash2D< T >::m_MinIdx
protected

◆ m_MinPos

template<class T >
TVecf CSpatialHash2D< T >::m_MinPos
protected

Geometric region subdivided by this data structure.

Definition at line 149 of file spatialhash2d.hpp.

Referenced by CSpatialHash2D< std::vector< int > >::GetMinPos().

◆ m_PrevVisMax

template<class T >
CVect2<float> CSpatialHash2D< T >::m_PrevVisMax
protected

Definition at line 135 of file spatialhash2d.hpp.

◆ m_PrevVisMin

template<class T >
CVect2<float> CSpatialHash2D< T >::m_PrevVisMin
protected

Visible rectangle area from previous call to UpdateVisibility.

Definition at line 134 of file spatialhash2d.hpp.

◆ m_ResolutionScaler

template<class T >
float CSpatialHash2D< T >::m_ResolutionScaler
protected

Definition at line 165 of file spatialhash2d.hpp.

◆ m_ResolutionX

template<class T >
float CSpatialHash2D< T >::m_ResolutionX
protected

Divisor for dividing model-space resolution into table indices.

Definition at line 162 of file spatialhash2d.hpp.

◆ m_ResolutionY

template<class T >
float CSpatialHash2D< T >::m_ResolutionY
protected

Definition at line 163 of file spatialhash2d.hpp.

◆ m_Scale

template<class T >
CVect2<float> CSpatialHash2D< T >::m_Scale
protected

Current scaling factor of model for viewing in x and y.

This is needed to determine where to place elements with pixel-based sizes in model.

Definition at line 159 of file spatialhash2d.hpp.

Referenced by CSpatialHash2D< std::vector< int > >::GetScale().

◆ m_VisMaxIdx

template<class T >
CVect2<int> CSpatialHash2D< T >::m_VisMaxIdx
protected

◆ m_VisMinIdx

template<class T >
CVect2<int> CSpatialHash2D< T >::m_VisMinIdx
protected

Range of visible indices from previous call to UpdateVisibility.

Definition at line 138 of file spatialhash2d.hpp.

Referenced by CSpatialHash2D< std::vector< int > >::GetMinVisIndex().

◆ m_Width

template<class T >
int CSpatialHash2D< T >::m_Width
protected

The documentation for this class was generated from the following file:
Modified on Mon Feb 26 04:00:41 2024 by modify_doxy.py rev. 669887