[ GAMB | Source | Keywords | Summary | Ancestors | All Members | Descendants ]
public: | |
explicit | GeomHash(const unsigned short d , const float cs ); |
explicit | GeomHash(const unsigned short d, const vector< float>& cs); |
~GeomHash() ; | |
GeomHash(const GeomHash< KeyT,DataT,BucketT>&); | |
void | insert(const KeyT& key, const DataT& data); |
void | query(const KeyT& key, const float radius, Result& result) const; |
void | query(const KeyT& key, const float radius, const NormType ballType, Result& result) const; |
void | query(const KeyT& key, const vector< float>& radii, Result& result) const; |
void | query(const KeyT& key, Result& result) const; |
void | query(Result& result, bool includeEmpty ) const; |
BucketsPointerList * | getBuckets(bool includeEmpty ) const; |
const Bucket* | bucket(const KeyT& key) const; |
void | erase(); |
void | setInsertSpeed(const float speed); |
unsigned short | dimension() const; |
float | resolution(unsigned short axis ) const; |
float | insertSpeed() const; |
protected: |
GeomHash actually is a wrap for the HashLink class which does most of the work of hash table traversal, insertion and querying. The user need not know anything about HashLink to use the hash table.
Geometric hash table results are returned using an STL-like container class called HashResult. This class and its accompanying iterator class HashIterator are used to collect hash table query results and to iterate through the result elements.
Instantiation may include a grid size and a dimension. Here is an example using Vector3's as the keys, integers as the data stored in the hash table, 3 is the dimension and 1.3 is the cube size of the grid.
GeomHash<Vector3, int> gHash(3, 1.3);
Members may be inserted using the insert command. The insert command recieves a key and a data element to be inserted into the proper bucket in the hash table.
gHash.insert(Vector3(1.2, 2.3, 3.4), -1);
When querying a geometric hash table one searches for data that was inserted into the hash table using keys that were close to the query key. A radius may be given to the query defining how far the neighboring points should be. The query returns all points within that distance but will return other points that lie in neighboring grid cubes. If you wish to extract points that are within a given euclidean radius you'll have to sift through the query results.
Before running a query one must declare a HashResult container in which the results will be collected. The container is sent with the query request and results are found in the container after the query is done.
An example of querying the hash table with a key and sifting through the data to find the data's that are within a euclidean radius of the key is given. The example assumes 10000 points are given inside a Vector3 array called points and a query point is given in Vector3 q.
float radius=1.0; GeomHash<Vector3, int> gHash(3, 2*radius); // grid cube size is 2*radius for (int i=0; i<10000; i++) // insert 10000 points gHash.insert(points[i], i); Vector3 q(1,1,1); HashResult<int> result; gHash.query(q, radius, result); // radius = half of cube size. // traverse list STL iterator style. HashResult<int>::iterator it; for (it = result.begin(); it != result.end(); it++) if (q | points[*it]) <= radius cout << *it << " : " << points[*it] << '\n';
In case of more complex key, the user can specify the cube size of every axis. For example, in case of transformation: each transformation can be represented as 3 rotation parameters and 3 translation parameters. The rotation parameters are values between -PI and PI, while the translational parameters are not limited. The user may want smaller bin size for rotation then for translation.
vector<float> radii(6); radii[0]=radii[1]=radii[2]=0.1; radii[3]=radii[4]=radii[5]=2.0; GeomHash<Transformation,int> gHash(6, radii); The same idea works in query: HashResult<int> result; gHash.query(t, radii, result);
explicit GeomHash(const unsigned short d , const float cs );
The hash-table is instantiated by a given dimension (defualt 1)
and a given cube-size (default 1.0).
explicit GeomHash(const unsigned short d=1, const float cs=1.0);
explicit GeomHash(const unsigned short d, const vector< float>& cs);
The hash-table is instantiated by a given dimension and
// a given cube size for each dimension.
explicit GeomHash(const unsigned short d, const vector< float>& cs);
~GeomHash() ;
Destructor. Frees all hash table memory.
~GeomHash() ;
Function is currently defined inline.
GeomHash(const GeomHash< KeyT,DataT,BucketT>&);
Copy constructor
GeomHash(const GeomHash< KeyT,DataT,BucketT>&);
void insert(const KeyT& key, const DataT& data);
Data elements can be inserted according to keys using the insert method.
The key determines in which d-dimensional cube the data is inserted.
void insert(const KeyT& key, const DataT& data);
This feature should be useful for large but sparsely populated hash tables
In densely populated hash tables, a gain in speed should be noticed only
with the first insertions. Once the table is populated resize operations
are rare and hence the speed gain is limited.
Note that raising the parameter too high could actually cause the
insertion operations to slow down because of the overhead of managing
a large hash table. This parameter should probably not exceed 4.0.
void query(const KeyT& key, const float radius, Result& result) const;
Searches for all data elements lying in radius neighborhood to key.
Note that query will return all points lying within a given radius
but may also return extra points that were not inserted with keys
that are within a radius to the query key.
Moreover, the default norm is the infinite norm
All results are collected using a results container of type HashResult
void query(const KeyT& key, const float radius, Result& result) const;
void query(const KeyT& key, const float radius, const NormType ballType, Result& result) const;
Searches for all data elements according to a given key.
The user may specify the type of the norm: Euclidean, Manhattan or Infinite.
Note that query will return all points lying within a given radius
but may also return extra points that were not inserted with keys
that are within a radius to the query key.
All results are collected using a results container of type HashResult
void query(const KeyT& key, const float radius, const NormType ballType,
Result& result) const;
void query(const KeyT& key, const vector< float>& radii, Result& result) const;
Searches for all data elements according to a given key and a set of radii.
the size of the radii vector must be equal to dimension. Each axis is searches
with a radius specified for it.
This query may return extra points as well.
void query(const KeyT& key, const vector< float>& radii, Result& result) const;
void query(const KeyT& key, Result& result) const;
Searches for all data elements lying in radius=cube size neighborhood
to key. The query will return all data's that were inserted with keys
whose distance to the query key is less then radius. More data
elements may be returned due to the grid structure of the hash table.
All results are
collected using a results container of type HashResult
void query(const KeyT& key, Result& result) const;
void query(Result& result, bool includeEmpty ) const;
Query the hash table with an infinite radius. Calling this method
results in a hash table results container which points to all hash table
elements. There is a choice whether to collect only non empty
buckets (ehich is also the default), but if one wished to check for
sparsity of the table you can set the includeEmpty to true and receive all
the empty buckets. Notice that travesing the result must be done with caution
mind the NULLs ....
void query(Result& result, bool includeEmpty=false) const;
BucketsPointerList *getBuckets(bool includeEmpty ) const;
Return a vector of all the buckets currently used in the Hash. This is
usefull for traversing the hash one bucket at a time, and also usefull for
creating a set of all the buckets now in use for follow up checks. There
is a flag that can be set if you want to add all the empty buckets in the
last dimesion and thus check the change in the sparsity of the table.(The
Hash class never changes the buckets but only copy a constant version of the
pointers so that even after insertions and deletions in the Hash the vector
will indicate the same set of buckets).
BucketsPointerList *getBuckets(bool includeEmpty=false) const;
const Bucket* bucket(const KeyT& key) const;
Returns a pointer to a bucket at the location given by key. If no such
bucket exists a NULL pointer is returned.
const Bucket* bucket(const KeyT& key) const;
void erase();
frees all memory used by hash table elements.
void erase();
void setInsertSpeed(const float speed);
Sets the hash table insertion speed. This parameter determines how
large the hash table arrays are made when an array resize is forced.
When this parameter is set to 0, arrays will be resized to be slightly
larger then what is currently needed by the hash table. If the parameter
is set to > 0, resizes will be more generous. Array sizes will grow
causing a decrease in the number of resize operations and hence an
increase in insertion speed.
void setInsertSpeed(const float speed);
unsigned short dimension() const;
returns hash table dimension
unsigned short dimension() const;
float resolution(unsigned short axis ) const;
returns hash table resolution or cube size.
float resolution(unsigned short axis=0) const;
float insertSpeed() const;
Returns hash table insertion speed. See setInsertSpeed.
float insertSpeed() const;
All Members
public: explicit GeomHash(const unsigned short d , const float cs ); explicit GeomHash(const unsigned short d, const vector< float>& cs); void insert(const KeyT& key, const DataT& data); void query(const KeyT& key, const float radius, Result& result) const; void query(const KeyT& key, const float radius, const NormType ballType, Result& result) const; void query(const KeyT& key, const vector< float>& radii, Result& result) const; void query(const KeyT& key, Result& result) const; void query(Result& result, bool includeEmpty ) const; BucketsPointerList * getBuckets(bool includeEmpty ) const; const Bucket* bucket(const KeyT& key) const; void erase(); void setInsertSpeed(const float speed); unsigned short dimension() const; float resolution(unsigned short axis ) const; float insertSpeed() const; protected: Ancestors
Class does not inherit from any other class.Descendants
Class is not inherited by any others.
Generated from source by the Cocoon utilities on Sun Nov 15 13:35:25 2009
.