UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
u3d_abstract_prgrid2d.hpp
1 /* u3d_abstract_prgrid2d.hpp */
2 /* $Id: u3d_abstract_prgrid2d.hpp,v 1.3 2008/10/28 08:12:30 hasher Exp $ */
3 #ifndef __u3d_abstract_prgrid2d_hpp
4 #define __u3d_abstract_prgrid2d_hpp
5 
6 #include <mth/u_base_math.hpp>
7 #include <mth/u3d_point.hpp>
8 #include <mth/u3d_box.hpp>
9 
12 {
13 public:
14 
17 
21  U3dAbstractPRGrid2d(const U3dPointsAr &points, double g_step, U3dBox *area = NULL);
22 
23  U3dAbstractPRGrid2d(const U3dPoints &points, double g_step, U3dBox *area = NULL);
24 
25  U3dAbstractPRGrid2d(const U3dPoints &points,
26  double g_step_x,
27  double g_step_y,
28  U3dBox *area = NULL);
29 
30  U3dAbstractPRGrid2d(const U3dPointsAr &points,
31  double g_step_x,
32  double g_step_y,
33  U3dBox *area = NULL);
34 
37 
39  virtual ~U3dAbstractPRGrid2d();
40 
42  virtual U3dAbstractPRGrid2d* clone();
43 
44  //------------------------------------------------------------------------------------------
45 
49  virtual void construct(const U3dPointsAr &points, double g_step, U3dBox *area = NULL);
50 
51  virtual void construct(const U3dPoints &points, double g_step, U3dBox *area = NULL);
52 
55  void setMinGridStepX(double eps) {
56  minGridEpsX = (eps < 0.)?(0.):(eps);
57  }
58 
59  void setMinGridStepY(double eps) {
60  minGridEpsY = (eps < 0.)?(0.):(eps);
61  }
62 
65  double getMinGridStepX() {
66  return minGridEpsX;
67  }
68 
69  double getMinGridStepY() {
70  return minGridEpsX;
71  }
72 
74  void getGridArea(U3dPoint &min, U3dPoint &max) {
75  min.setXYZ(m_area3d.xmn, m_area3d.ymn, m_area3d.zmn);
76  max.setXYZ(m_area3d.xmx, m_area3d.ymx, m_area3d.zmx);
77  }
78 
79  //------------------------------------------------------------------------------------------
80 
82  int getGridXSize() const {
83  return m_grd_x.size();
84  }
85 
87  int getGridYSize() const {
88  return m_grd_y.size();
89  }
90 
95  int getGridPoint(int i, int j, U3dPoint &p) const;
96 
97  int setGridPointZ(int i, int j, double z);
98 
100  U3dPointsAr& getInitialPoints() {
101  return m_ips;
102  }
103 
104  //------------------------------------------------------------------------------------------
105 
107  virtual void addPoint(U3dPoint*){;};
108 
111  virtual bool removePoint(int /*ind*/){return false;};
112 
113  // ------------------------------------------------------------------------------------------
114 
116  struct GridCell
117  {
119  GridCell(int i_ind, double i_z) {
120  ip_ind = i_ind;
121  z = i_z;
122  }
123 
124  int ip_ind;
125  double z;
126  };
127 
129  typedef std::vector<GridCell> GridLine;
130 
132  typedef std::vector<GridLine> GridMatrix;
133 
135  struct Area3d
136  {
137  double xmn,xmx,ymn,ymx,zmn,zmx;
138  };
139 
140 protected:
141 
143  U3dPointsAr m_ips;
144 
147  double minGridEpsX;
148  double minGridEpsY;
149 
151  std::vector<double> m_grd_x, m_grd_y;
152 
155 
158 
160  static void correct_id(int &id, int size) {
161  if (id < 0)
162  id = 0;
163  else if (id >= size)
164  id = size - 1;
165  }
166 
167 private:
168 
169 };
170 
171 #endif /* u3d_abstract_prgrid2d.hpp */
GridCell(int i_ind, double i_z)
Definition: u3d_abstract_prgrid2d.hpp:119
int ip_ind
Definition: u3d_abstract_prgrid2d.hpp:124
Definition: u3d_abstract_prgrid2d.hpp:135
void setMinGridStepX(double eps)
Definition: u3d_abstract_prgrid2d.hpp:55
void setXYZ(double x, double y, double z)
Definition: u3d_point.hpp:147
void getGridArea(U3dPoint &min, U3dPoint &max)
Definition: u3d_abstract_prgrid2d.hpp:74
int getGridXSize() const
Definition: u3d_abstract_prgrid2d.hpp:82
std::vector< GridLine > GridMatrix
Definition: u3d_abstract_prgrid2d.hpp:132
Definition: u3d_box.hpp:24
Area3d m_area3d
Definition: u3d_abstract_prgrid2d.hpp:157
virtual U3dAbstractPRGrid2d * clone()
U3dPointsAr m_ips
Definition: u3d_abstract_prgrid2d.hpp:143
GridMatrix m_grid
Definition: u3d_abstract_prgrid2d.hpp:154
U3dPointsAr & getInitialPoints()
Definition: u3d_abstract_prgrid2d.hpp:100
double minGridEpsX
Definition: u3d_abstract_prgrid2d.hpp:147
virtual ~U3dAbstractPRGrid2d()
static void correct_id(int &id, int size)
Definition: u3d_abstract_prgrid2d.hpp:160
Definition: u3d_point.hpp:16
double getMinGridStepX()
Definition: u3d_abstract_prgrid2d.hpp:65
std::vector< GridCell > GridLine
Definition: u3d_abstract_prgrid2d.hpp:129
virtual void addPoint(U3dPoint *)
Definition: u3d_abstract_prgrid2d.hpp:107
Definition: u3d_abstract_prgrid2d.hpp:116
int getGridYSize() const
Definition: u3d_abstract_prgrid2d.hpp:87
int getGridPoint(int i, int j, U3dPoint &p) const
virtual bool removePoint(int)
Definition: u3d_abstract_prgrid2d.hpp:111
double z
Definition: u3d_abstract_prgrid2d.hpp:125
virtual void construct(const U3dPointsAr &points, double g_step, U3dBox *area=NULL)
std::vector< double > m_grd_x
Definition: u3d_abstract_prgrid2d.hpp:151
Definition: u3d_abstract_prgrid2d.hpp:11