The spica renderer
hash_grid.h
1 #ifndef _SPICA_HASH_GRID_H_
2 #define _SPICA_HASH_GRID_H_
3 
4 #include <vector>
5 
6 #include "../core/point3d.h"
7 #include "../core/bounds3d.h"
8 
9 namespace spica {
10 
11 template <class T>
12 class HashGrid {
13 public:
14  HashGrid();
15  virtual ~HashGrid();
16 
23  void construct(std::vector<T>& points, const int imageW = -1, const int imageH = -1);
24 
26  void init(const int hashSize, const double hashScale, const Bounds3d& bbox);
27 
29  void add(const T& p, const Point3d& boxMin, const Point3d& boxMax);
30 
32  void clear();
33 
34  const std::vector<T>& operator[](const Point3d& v) const;
35 
36 private:
37  // Private methods
38  unsigned int hash(const int ix, const int iy, const int iz) const;
39 
40  // Private fields
41  int _hashSize;
42  Bounds3d _bbox;
43  double _hashScale;
44  std::vector<std::vector<T> > _data;
45 
46 }; // class HashGrid
47 
48 } // namespace spica
49 
50 #include "hash_grid_detail.h"
51 
52 #endif // _SPICA_HASH_GRID_H_
53 
void init(const int hashSize, const double hashScale, const Bounds3d &bbox)
Initialize grid.
Definition: hash_grid_detail.h:28
void add(const T &p, const Point3d &boxMin, const Point3d &boxMax)
Set point data for the cells inside the specifed bounding box.
Definition: hash_grid_detail.h:36
void construct(std::vector< T > &points, const int imageW=-1, const int imageH=-1)
Construct hash grid.
Definition: hash_grid_detail.h:23
void clear()
Clear grid data.
Definition: hash_grid_detail.h:57
Definition: hash_grid.h:12