Flumy [Free API]
Process based model for meandering chanelized systems
GridParams.hpp
1 #ifndef GRID_PARAMS_HH
2 #define GRID_PARAMS_HH
3 
4 #include "MCRCProgramming.hpp"
5 #include "flumy_export.hpp"
6 
7 #include "Point3D.hpp"
8 #include "Point2D.hpp"
9 
10 class ConvexPolyedra2D;
11 
28 class FLUMY_EXPORT GridParams {
29 
30 public:
34  GridParams(const MP_real & dx,
35  const MP_real & dy,
36  const MP_int & nx,
37  const MP_int & ny,
38  const MP_real & ox = 0.,
39  const MP_real & oy = 0.);
41  GridParams(const MP_real & dx,
42  const MP_real & dy,
43  const MP_real & dz,
44  const MP_int & nx,
45  const MP_int & ny,
46  const MP_int & nz,
47  const MP_real & ox = 0.,
48  const MP_real & oy = 0.,
49  const MP_real & oz = 0.);
51  GridParams(const GridParams& grid);
53  virtual ~GridParams() {}
57  virtual void reset(const GridParams & grid);
59  void reset(const MP_real & dx,
60  const MP_real & dy,
61  const MP_int & nx,
62  const MP_int & ny,
63  const MP_real & ox = 0.,
64  const MP_real & oy = 0.);
66  void reset(const MP_real & dx,
67  const MP_real & dy,
68  const MP_real & dz,
69  const MP_int & nx,
70  const MP_int & ny,
71  const MP_int & nz,
72  const MP_real & ox = 0.,
73  const MP_real & oy = 0.,
74  const MP_real & oz = 0.);
76  MP_real getDx() const { return _dx; }
78  MP_real getDy() const { return _dy; }
80  MP_real getDz() const { return _dz; }
82  MP_int getNx() const { return _nx; }
84  MP_int getNy() const { return _ny; }
86  MP_int getNz() const { return _nz; }
88  MP_real getOx() const { return _ox; }
90  MP_real getOy() const { return _oy; }
92  MP_real getOz() const { return _oz; }
94  Point2D getOrigin() const;
96  MP_int getNbNodes() const { return _nx * _ny * _nz; }
98  void getApexRel(Point2D& p1, Point2D& p2, Point2D& p3, Point2D& p4) const;
100  void setLocation(const MP_real & x,
101  const MP_real & y,
102  const MP_real & z = 0.);
104  void setLocation(const Point3D & location);
106  void setLocation(const Point2D & location);
108  const Point3D & getLocation() const;
110  MP_real getZLoc() const { return _location.get_elevation(); }
112  void setRotation(const MP_real& rot);
113  // Return the rotation of the grid
114  MP_real getRotation() const;
117  MP_real getLength() const { return (_nx-1) * _dx; }
120  MP_real getWidth() const { return (_ny-1) * _dy; }
123  MP_real getHeight() const { return is3D() ? (_nz-1) * _dz : MP_MAX_REAL_VALUE; }
125  bool is3D() const { return (_nz > 1 && _dz < MP_MAX_REAL_VALUE); }
127  bool isCompatibleWith(const GridParams & grid, bool check_geo = false) const;
128 
129 #ifndef SWIG
131  friend std::ostream & operator <<(std::ostream & os, const GridParams & grid);
132 #endif
133 
134  // 2D Point conversion
135  Point2D & rel2Geo (Point2D & point) const;
136  Point2D & rel2Grid(Point2D & point, bool round = true) const;
137  Point2D & geo2Rel (Point2D & point) const;
138  Point2D & geo2Grid(Point2D & point, bool round = true) const;
139  Point2D & grid2Rel(Point2D & point) const;
140  Point2D grid2Rel(const MP_int & ix, const MP_int & iy) const;
141  Point2D grid2Geo(const MP_int & ix, const MP_int & iy) const;
142 
143  // 3D points conversion
144  Point3D & rel2Geo(Point3D & point) const;
145  Point3D & geo2Rel(Point3D & point) const;
146 
147  // 2D Polyedra conversion
148  ConvexPolyedra2D & rel2Grid(ConvexPolyedra2D & polyedra) const;
149  ConvexPolyedra2D & grid2Rel(ConvexPolyedra2D & polyedra) const;
150 
151  // For all following methods : the given point is assumed to be already put on grid
152  bool is_on_grid(const Point2D & point) const;
153  bool is_on_grid_nearest(const Point2D & point) const;
154 
155 protected:
156 
158  MP_real _dx;
160  MP_real _dy;
162  MP_real _dz;
164  MP_int _nx;
166  MP_int _ny;
168  MP_int _nz;
170  MP_real _ox;
172  MP_real _oy;
174  MP_real _oz;
176  Point3D _location;
179  MP_real _rotation;
181  MP_real _cosrot;
183  MP_real _sinrot;
184 };
185 
186 
187 
188 #endif /* GRID_PARAMS_HH */
Base class for 3D grid description.
Definition: GridParams.hpp:28
Point2D grid2Geo(const MP_int &ix, const MP_int &iy) const
MP_real getOy() const
Assessor get to protected member variable _oy.
Definition: GridParams.hpp:90
MP_int getNbNodes() const
Return the number of grid nodes.
Definition: GridParams.hpp:96
virtual ~GridParams()
Destructor.
Definition: GridParams.hpp:53
MP_real getOx() const
Assessor get to protected member variable _ox.
Definition: GridParams.hpp:88
MP_int _nx
Number of nodes along abscissa axis Ox (must be greater than 0)
Definition: GridParams.hpp:164
GridParams()
Default constructor.
MP_int _nz
Number of nodes along elevation axis Oz (must be greater than 0)
Definition: GridParams.hpp:168
MP_real _dy
Mesh size (m) along ordinate axis Oy (must be greater than 0)
Definition: GridParams.hpp:160
bool is_on_grid_nearest(const Point2D &point) const
bool is3D() const
Return true if the grid has 3 dimensions (nz > 1 and dz < MP_MAX_REAL_VALUE)
Definition: GridParams.hpp:125
void setLocation(const Point3D &location)
Localize the grid in the geographical system.
GridParams & operator=(const GridParams &)
Operator =.
Point3D & geo2Rel(Point3D &point) const
MP_real getLength() const
Return total length of the grid (in meters). It corresponds to the grid size along abscissa axis Ox.
Definition: GridParams.hpp:117
MP_real getOz() const
Assessor get to protected member variable _oz.
Definition: GridParams.hpp:92
Point2D grid2Rel(const MP_int &ix, const MP_int &iy) const
bool is_on_grid(const Point2D &point) const
bool isCompatibleWith(const GridParams &grid, bool check_geo=false) const
Return true if the given grid has same parameters.
GridParams(const MP_real &dx, const MP_real &dy, const MP_int &nx, const MP_int &ny, const MP_real &ox=0., const MP_real &oy=0.)
Constructor from 2D grid parameters.
MP_real getHeight() const
Return total height of the grid (in meters). It corresponds to the grid size along elevation axis Oz...
Definition: GridParams.hpp:123
MP_real _rotation
Definition: GridParams.hpp:179
MP_real _cosrot
Definition: GridParams.hpp:181
MP_real getZLoc() const
Assessor get location elevation.
Definition: GridParams.hpp:110
ConvexPolyedra2D & grid2Rel(ConvexPolyedra2D &polyedra) const
MP_real _sinrot
Definition: GridParams.hpp:183
MP_real _oz
Origin offset along z-axis (m)
Definition: GridParams.hpp:174
MP_int getNx() const
Assessor get to protected member variable _nx.
Definition: GridParams.hpp:82
MP_real getWidth() const
Return total width of the grid (in meters). It corresponds to the grid size along ordinate axis Oy.
Definition: GridParams.hpp:120
MP_real getDy() const
Assessor get to protected member variable _dy.
Definition: GridParams.hpp:78
Point2D & geo2Grid(Point2D &point, bool round=true) const
MP_int getNz() const
Assessor get to protected member variable _nz.
Definition: GridParams.hpp:86
void reset(const MP_real &dx, const MP_real &dy, const MP_int &nx, const MP_int &ny, const MP_real &ox=0., const MP_real &oy=0.)
Reset 2D grid parameters to new values.
virtual void reset(const GridParams &grid)
Reset 2D grid parameters to new values.
MP_real _dx
Mesh size (m) along abscissa axis Ox (must be greater than 0)
Definition: GridParams.hpp:158
Point2D & rel2Grid(Point2D &point, bool round=true) const
Point3D _location
Front bottom left corner (m) of the grid (Geographical Location)
Definition: GridParams.hpp:176
ConvexPolyedra2D & rel2Grid(ConvexPolyedra2D &polyedra) const
void setLocation(const Point2D &location)
Localize the grid in the geographical system.
MP_real getRotation() const
Point2D & grid2Rel(Point2D &point) const
Point2D getOrigin() const
Assessor get to origin 2D point _ox,_oy.
MP_real _dz
Mesh size (m) along elevation axis Oz (must be greater than 0)
Definition: GridParams.hpp:162
void getApexRel(Point2D &p1, Point2D &p2, Point2D &p3, Point2D &p4) const
Return the 4 apex relative points.
void reset(const MP_real &dx, const MP_real &dy, const MP_real &dz, const MP_int &nx, const MP_int &ny, const MP_int &nz, const MP_real &ox=0., const MP_real &oy=0., const MP_real &oz=0.)
Reset 3D grid parameters to new values.
void setLocation(const MP_real &x, const MP_real &y, const MP_real &z=0.)
Localize the grid in the geographical system.
Point2D & geo2Rel(Point2D &point) const
Point2D & rel2Geo(Point2D &point) const
MP_real _ox
Origin offset along x-axis (m)
Definition: GridParams.hpp:170
MP_real getDz() const
Assessor get to protected member variable _dz.
Definition: GridParams.hpp:80
MP_int _ny
Number of nodes along ordinate axis Oy (must be greater than 0)
Definition: GridParams.hpp:166
MP_int getNy() const
Assessor get to protected member variable _ny.
Definition: GridParams.hpp:84
Point3D & rel2Geo(Point3D &point) const
MP_real _oy
Origin offset along y-axis (m)
Definition: GridParams.hpp:172
GridParams(const MP_real &dx, const MP_real &dy, const MP_real &dz, const MP_int &nx, const MP_int &ny, const MP_int &nz, const MP_real &ox=0., const MP_real &oy=0., const MP_real &oz=0.)
Constructor from 3D grid parameters.
const Point3D & getLocation() const
Return the location of the grid.
MP_real getDx() const
Assessor get to protected member variable _dx.
Definition: GridParams.hpp:76
GridParams(const GridParams &grid)
Copy constructor.
void setRotation(const MP_real &rot)
Rotate the grid around z-axis in the geographical system.
Storage class for 2D points.
Definition: Point2D.hpp:13