GlobeEngine
Grid.h
Go to the documentation of this file.
1 
17 #ifndef GlobeEngine_Grid_h
18 #define GlobeEngine_Grid_h
19 
20 #include "vmmlib/vector.hpp"
21 #include "AxisAlignedBoundingBox.h"
22 
23 namespace ge {
30  class Grid2D
31  {
32  public:
33  Grid2D() {};
34  virtual ~Grid2D() {};
35  virtual void clear();
36  vmml::Vector2ui getSize() const;
37  vmml::Vector2d getMidpoint() const;
38  const ge::AABB2d& getAABB() const;
39 
40  virtual vmml::Vector2ui getCellIdxForPoint(vmml::Vector2d _point) = 0;
41  virtual vmml::Vector2i getCellIdxForBound(vmml::Vector4d _point) = 0;
42 
43  protected:
45  vmml::Vector2ui sizes;
46  vmml::Vector2d midpoint;
47  };
48 
54  class CartesianGrid2D : public Grid2D
55  {
56  public:
59  void clear() override;
60 
66  void create(vmml::Vector2ui _pointCounts, double _stepsize);
67 
75  void create(const ge::AABB2d& _bound, vmml::Vector2ui _pointCounts);
76 
85  void create(const ge::AABB2d& _bound, double _stepsize);
86 
87  private:
88  double stepsize;
89  };
90 
95  class RegularGrid2D : public Grid2D
96  {
97  public:
100 
101  void clear() override;
102 
108  void create(vmml::Vector2ui _pointcount, vmml::Vector2d _stepsizes);
109 
115  void create(const ge::AABB2d& _bound, vmml::Vector2ui _pointcount);
116 
125  void create(const ge::AABB2d& _bound, vmml::Vector2d _stepsizes);
126 
127  private:
128  vmml::Vector2d stepsizes;
129  };
130 }
131 #endif
vmml::Vector2d getMidpoint() const
Definition: Grid.cpp:16
virtual void clear()
Definition: Grid.cpp:5
CartesianGrid2D()
Definition: Grid.cpp:29
ge::AABB2d bound
Definition: Grid.h:44
RegularGrid2D()
Definition: Grid.h:98
vmml::Vector2ui getSize() const
Definition: Grid.cpp:11
A cartesian grid is a uniform grid having the same distance between all points in all axis directions...
Definition: Grid.h:54
vmml::Vector2d midpoint
Definition: Grid.h:46
virtual vmml::Vector2ui getCellIdxForPoint(vmml::Vector2d _point)=0
A regular grid is a uniform grid with the same distance between all points of an axis.
Definition: Grid.h:95
vmml::Vector2ui sizes
Definition: Grid.h:45
void clear() override
Definition: Grid.cpp:33
const ge::AABB2d & getAABB() const
Definition: Grid.cpp:21
void clear() override
Definition: Grid.cpp:65
~RegularGrid2D()
Definition: Grid.h:99
Grid2D()
Definition: Grid.h:33
~CartesianGrid2D()
Definition: Grid.h:58
Definition: AvalancheTrainingSimulationEngine.h:28
void create(vmml::Vector2ui _pointCounts, double _stepsize)
Set up a cartesian grid with origin 0.0, 0.0.
Definition: Grid.cpp:37
void create(vmml::Vector2ui _pointcount, vmml::Vector2d _stepsizes)
Set up a regular grid with origin 0.0, 0.0.
Definition: Grid.cpp:70
virtual ~Grid2D()
Definition: Grid.h:34
This 2D grid class is an abstraction of properties for uniform and nonuniform grids. The defintions are according to: https://en.wikipedia.org/wiki/Regular_grid.
Definition: Grid.h:30
virtual vmml::Vector2i getCellIdxForBound(vmml::Vector4d _point)=0