KrisLibrary  1.0.0
Public Types | Public Member Functions | Public Attributes | List of all members
Geometry::GridHash Class Reference

An ND grid containing objects (referenced by void pointers) More...

#include <GridSubdivision.h>

Public Types

typedef IntTuple Index
 
typedef void * Value
 
typedef bool(* QueryCallback) (void *value)
 
typedef UNORDERED_MAP_TEMPLATE< Index, Value, IndexHashHashTable
 

Public Member Functions

 GridHash (int numDims, Real h=1)
 
 GridHash (const Vector &h)
 
size_t GetBucketCount () const
 
void SetBucketCount (size_t n)
 
Vector GetResolution () const
 
void SetResolution (const Vector &h)
 Changes the resolution after construction – need to have all buckets empty.
 
void SetResolution (Real h)
 Changes the resolution after construction – need to have all buckets empty.
 
void Set (const Index &i, void *data)
 Sets the data at a given index.
 
void * Get (const Index &i) const
 Retrieves the data at a given index.
 
void * Erase (const Index &i)
 Important: this method just removes the item from the hash, but does not delete its memory.
 
bool Contains (const Index &i)
 Returns true if the hash contains the given index.
 
void Clear ()
 
void Enumerate (std::vector< Value > &items) const
 
void PointToIndex (const Vector &p, Index &i) const
 
void PointToIndex (const Vector &p, Index &i, Vector &u) const
 
void IndexBucketBounds (const Index &i, Vector &bmin, Vector &bmax) const
 
void GetRange (Index &imin, Index &imax) const
 
void GetRange (Vector &bmin, Vector &bmax) const
 
bool IndexQuery (const Index &imin, const Index &imax, QueryCallback f) const
 
bool BoxQuery (const Vector &bmin, const Vector &bmax, QueryCallback f) const
 
bool BallQuery (const Vector &c, Real r, QueryCallback f) const
 
bool SegmentQuery (const Vector &a, const Vector &b, QueryCallback f) const
 
void IndexItems (const Index &imin, const Index &imax, std::vector< Value > &items) const
 
void BoxItems (const Vector &bmin, const Vector &bmax, std::vector< Value > &items) const
 
void BallItems (const Vector &c, Real r, std::vector< Value > &items) const
 
void SegmentItems (const Vector &a, const Vector &b, std::vector< Value > &items) const
 

Public Attributes

Vector hinv
 
HashTable buckets
 

Detailed Description

An ND grid containing objects (referenced by void pointers)

The map from a point x to an index is floor(x./h) where ./ indicates element-wise division, and h is the resolution parameter defined on construction (see Grid).


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