KrisLibrary  1.0.0
Grid.h
1 #ifndef GEOMETRY_GRID_H
2 #define GEOMETRY_GRID_H
3 
4 #include <KrisLibrary/utils/IntTuple.h>
5 #include <KrisLibrary/math/vector.h>
6 
7 namespace Geometry {
8 
9 using namespace Math;
10 
19 class Grid
20 {
21 public:
22  typedef IntTuple Index;
24  typedef bool (*QueryCallback)(const Index& index);
25 
26  explicit Grid(int numDims,Real h=1);
27  explicit Grid(const Vector& h);
28 
29  //returns the index of the point
30  void PointToIndex(const Vector& p,Index& i) const;
31  //same, but with the local coordinates in the cell [0,1]^n
32  void PointToIndex(const Vector& p,Index& i,Vector& u) const;
33  //returns the lower/upper corner of the cell
34  void CellBounds(const Index& i,Vector& bmin,Vector& bmax) const;
35  //returns the lower corner of the cell
36  void CellCorner(const Index& index,Vector& bmin) const;
37  //returns the center of the cell
38  void CellCenter(const Index& index,Vector& c) const;
39 
40  //range imin to imax
41  bool IndexQuery(const Index& imin,const Index& imax,QueryCallback f) const;
42  //bounding box from bmin to bmax
43  bool BoxQuery(const Vector& bmin,const Vector& bmax,QueryCallback f) const;
44  //ball with center c, radius r
45  bool BallQuery(const Vector& c,Real r,QueryCallback f) const;
46  //segment from a to b
47  bool SegmentQuery(const Vector& a,const Vector& b,QueryCallback f) const;
48 
49  Vector h;
50 };
51 
52 } //namespace Geometry
53 
54 #endif
A gridding of n-dimensional space.
Definition: Grid.h:19
An integer tuple class.
Definition: IntTuple.h:14
Contains all definitions in the Math package.
Definition: WorkspaceBound.h:12
Contains all definitions in the Geometry package.
Definition: AnyGeometry.cpp:26