Classes | Public Types | Public Member Functions | Protected Types | Protected Attributes

OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type > Class Template Reference

#include <spatial_hashing_grid.h>

List of all members.

Classes

class  Cell

Public Types

typedef data_type_ data_type
typedef real_vector3::value_type real_type
typedef int_vector3 triplet_type
 Type of discretized points.
typedef real_vector3 point_type
 Type of continuous points.
typedef Cell cell_type
typedef std::vector< cell_typecell_storage
typedef cell_storage::iterator cell_iterator

Public Member Functions

cell_iterator begin ()
cell_iterator end ()
 Grid ()
 Grid (size_t size)
void resize (size_t size)
size_t size () const
void set_spacing (real_type delta)
real_type get_spacing () const
triplet_type get_triplet (point_type const &point) const
cell_typeget_cell (point_type const &p)
cell_typeget_cell (triplet_type const &triplet)
void clear ()

Protected Types

typedef std::vector< data_type * > data_ptr_container
typedef
data_ptr_container::iterator 
data_ptr_iterator
typedef
data_ptr_container::const_iterator 
const_data_ptr_iterator

Protected Attributes

size_t m_time_stamp
 Query time-stamp.
real_type m_delta
 Grid cell spacing.
hash_function_type m_hash_function
cell_storage m_cells
 Hash table cells.

Detailed Description

template<typename real_vector3, typename int_vector3, typename data_type_, typename hash_function_type>
class OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >

Hash Grid. This class stores an infinite uniform 3D grid as a 1D hash tabel. It is tailored to work in 3D. However, an end user could use it in 2D or even 1D by ignoring second or third coordinates (i.e. set them all to the same value).

The hash grid needs a hash function, a hash function must surply the following interface

size_t operator(int ,int , int)const size_t size()const void resize(size_t)

Important: The hash function is responsible for picking the proper hash table size. Thus if resize is invoked and the implemented hash function for instance implements something like:

m_size = new_size + (new_size % 10)

In which case the hash grid will automatically make sure that m_size is used to allocate the number of hash cells. The size() method is expected to return the value of m_size.

The operator(int,int,int) should convert a discretized point into a 1D hash key. The hash key value is expected to be within the interval 0..m_size-1.


Member Typedef Documentation

template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
typedef cell_storage::iterator OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::cell_iterator
template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
typedef std::vector< cell_type > OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::cell_storage
template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
typedef Cell OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::cell_type
template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
typedef data_ptr_container::const_iterator OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::const_data_ptr_iterator [protected]
template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
typedef std::vector<data_type*> OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::data_ptr_container [protected]
template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
typedef data_ptr_container::iterator OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::data_ptr_iterator [protected]
template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
typedef data_type_ OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::data_type
template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
typedef real_vector3 OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::point_type

Type of continuous points.

template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
typedef real_vector3::value_type OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::real_type
template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
typedef int_vector3 OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::triplet_type

Type of discretized points.


Constructor & Destructor Documentation

template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::Grid (  )  [inline]
template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::Grid ( size_t  size  )  [inline]

Member Function Documentation

template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
cell_iterator OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::begin (  )  [inline]
template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
void OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::clear (  )  [inline]
template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
cell_iterator OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::end (  )  [inline]
template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
cell_type& OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::get_cell ( triplet_type const &  triplet  )  [inline]

Find the hash cell containing the grid cell enclosing the discretized point.

template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
cell_type& OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::get_cell ( point_type const &  p  )  [inline]

Find the hash cell containing the grid cell enclosing the continuous point.

template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
real_type OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::get_spacing (  )  const [inline]
template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
triplet_type OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::get_triplet ( point_type const &  point  )  const [inline]

Point Discretization.

Parameters:
p A 3D point in continious space
Returns:
A discretized point identifying the grid cell (not the hash cell!) which the contineous point lies inside.
template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
void OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::resize ( size_t  size  )  [inline]
template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
void OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::set_spacing ( real_type  delta  )  [inline]

Set Grid Cell Spacing. Observe that a grid cell is not the same as a hash-cell, data inside a grid cell is mapped to a hash-cell, this is not a one-to-one mapping. In fact multiple grid cells can be mapped to the same hash-cell (this is called a hash-collision).

To reduce the chance of this, try increase the hash-table size, this will decrease the chance of hash-collisions.

For point type data, the grid spacing should usually be set to the average size of the query data used.

For volumetric data, the grid spacing should usually be set to the average size of the volumetric data.

Parameters:
delta The new grid cell spacing size, must be a positive number.
template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
size_t OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::size (  )  const [inline]

Member Data Documentation

template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
cell_storage OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::m_cells [protected]

Hash table cells.

template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
real_type OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::m_delta [protected]

Grid cell spacing.

template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
hash_function_type OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::m_hash_function [protected]
template<typename real_vector3 , typename int_vector3 , typename data_type_ , typename hash_function_type >
size_t OpenTissue::spatial_hashing::Grid< real_vector3, int_vector3, data_type_, hash_function_type >::m_time_stamp [protected]

Query time-stamp.


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