OpendTect-6_4  6.4
arrayndinfo.h
Go to the documentation of this file.
1 #ifndef arrayndinfo_h
2 #define arrayndinfo_h
3 /*
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: K. Tingdahl
8  Date: 9-3-1999
9  RCS: $Id$
10 ________________________________________________________________________
11 
12 
13 */
14 
15 #include "basicmod.h"
16 #include "gendefs.h"
17 
24 {
25 public:
26 
27  virtual ArrayNDInfo* clone() const = 0;
28  virtual ~ArrayNDInfo() {}
29 
30  virtual int getNDim() const = 0;
31  virtual int getSize(int dim) const = 0;
32  virtual bool setSize(int dim,int sz);
33 
34  virtual bool isOK() const;
35 
36  virtual od_uint64 getTotalSz() const;
37  virtual od_uint64 getOffset(const int*) const;
39  virtual bool validPos(const int*) const;
41  bool validDimPos(int dim,int pos) const;
43  virtual bool getArrayPos(od_uint64, int*) const;
46 protected:
47 
48  od_uint64 calcTotalSz() const;
49 
50 };
51 
52 
53 inline bool operator ==( const ArrayNDInfo& a1, const ArrayNDInfo& a2 )
54 {
55  int nd = a1.getNDim();
56  if ( nd != a2.getNDim() ) return false;
57  for ( int idx=0; idx<nd; idx++ )
58  if ( a1.getSize(idx) != a2.getSize(idx) ) return false;
59  return true;
60 }
61 
62 inline bool operator !=( const ArrayNDInfo& a1, const ArrayNDInfo& a2 )
63 { return !(a1 == a2); }
64 
65 
72 {
73 public:
74 
75  virtual int getNDim() const { return 1; }
76 
77  virtual od_uint64 getOffset( int pos ) const
78  { return pos; }
79  virtual bool validPos( int pos ) const
80  { return ArrayNDInfo::validPos( &pos ); }
81 
82  virtual od_uint64 getOffset( const int* iarr ) const
83  { return getOffset( *iarr ); }
84  virtual bool validPos( const int* iarr ) const
85  { return ArrayNDInfo::validPos( iarr ); }
86 
87 };
88 
89 
96 {
97 public:
98 
99  virtual int getNDim() const { return 2; }
100 
101  virtual od_uint64 getOffset(int,int) const;
103  virtual bool validPos(int,int) const;
104 
105  virtual od_uint64 getOffset( const int* iarr ) const
106  { return ArrayNDInfo::getOffset( iarr ); }
107  virtual bool validPos( const int* iarr ) const
108  { return ArrayNDInfo::validPos( iarr ); }
109 
110 };
111 
112 
119 {
120 public:
121 
122  virtual int getNDim() const { return 3; }
123 
124  virtual od_uint64 getOffset(int, int, int) const;
126  virtual bool validPos(int,int,int) const;
127 
128  virtual od_uint64 getOffset( const int* iarr ) const
129  { return ArrayNDInfo::getOffset( iarr ); }
130  virtual bool validPos( const int* iarr ) const
131  { return ArrayNDInfo::validPos( iarr ); }
132 
133 };
134 
135 
141 {
142 public:
143 
144  virtual Array1DInfo* clone() const
145  { return new Array1DInfoImpl(*this); }
146 
147  Array1DInfoImpl(int nsz=0);
148  Array1DInfoImpl(const Array1DInfo&);
149 
150  virtual int getSize(int dim) const;
151  virtual bool setSize(int dim,int nsz);
152  virtual bool isOK() const { return dimsz_>=0; }
153  virtual od_uint64 getTotalSz() const { return dimsz_; }
154 
155 protected:
156 
157  int dimsz_;
158 
159 };
160 
161 
167 {
168 public:
169 
170  virtual Array2DInfo* clone() const { return new Array2DInfoImpl(*this); }
171 
172  Array2DInfoImpl(int sz0=0, int sz1=0);
173  Array2DInfoImpl(const Array2DInfo&);
174 
175  virtual int getSize(int dim) const;
176  virtual bool setSize(int dim,int nsz);
177  virtual bool isOK() const { return cachedtotalsz_ > 0; }
178 
179  virtual od_uint64 getTotalSz() const { return cachedtotalsz_; }
180 
181 protected:
182 
183  int dimsz_[2];
185 
186 };
187 
188 
194 {
195 public:
196 
197  virtual Array3DInfo* clone() const { return new Array3DInfoImpl(*this); }
198 
199  Array3DInfoImpl(int sz0=0, int sz1=0, int sz2=0);
200  Array3DInfoImpl(const Array3DInfo&);
201 
202  virtual int getSize(int dim) const;
203  virtual bool setSize(int dim,int nsz);
204  virtual bool isOK() const { return cachedtotalsz_ > 0; }
205  virtual od_uint64 getTotalSz() const { return cachedtotalsz_; }
206 
207 protected:
208 
209  int dimsz_[3];
211 
212 };
213 
214 
220 {
221 public:
222 
223  virtual ArrayNDInfo* clone() const;
224  static ArrayNDInfo* create(int ndim);
225 
226  ArrayNDInfoImpl(int ndim);
227  ArrayNDInfoImpl(const ArrayNDInfo&);
229  ~ArrayNDInfoImpl();
230  virtual bool isOK() const { return cachedtotalsz_ > 0; }
231 
232  virtual od_uint64 getTotalSz() const { return cachedtotalsz_; }
233  virtual int getNDim() const;
234  virtual int getSize(int dim) const;
235  virtual bool setSize(int dim,int nsz);
236 
237 protected:
238 
239  int ndim_;
240  int* dimsz_;
241 
243 };
244 
245 
246 inline int Array1DInfoImpl::getSize( int dim ) const
247 {
248  return dim ? 0 : dimsz_;
249 }
250 
251 
252 inline int Array2DInfoImpl::getSize( int dim ) const
253 {
254  return dim>1 || dim<0 ? 0 : dimsz_[dim];
255 }
256 
257 
258 inline int Array3DInfoImpl::getSize( int dim ) const
259 {
260  return dim>2 || dim<0 ? 0 : dimsz_[dim];
261 }
262 
263 
264 #endif
#define mExpClass(module)
Definition: commondefs.h:160
virtual int getNDim() const =0
uint64_t cachedtotalsz_
Definition: arrayndinfo.h:242
uint64_t cachedtotalsz_
Definition: arrayndinfo.h:210
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:53
virtual int getNDim() const
Definition: arrayndinfo.h:75
virtual bool validPos(const int *) const
Contains the information about the size of Array3D, and in what order the data is stored (if accessab...
Definition: arrayndinfo.h:118
virtual bool validPos(const int *iarr) const
Definition: arrayndinfo.h:130
Implementation of ArrayNDInfo.
Definition: arrayndinfo.h:219
uint64_t cachedtotalsz_
Definition: arrayndinfo.h:184
Contains the information about the size of ArrayND, and in what order the data is stored (if accessab...
Definition: arrayndinfo.h:23
Contains the information about the size of Array1D, and in what order the data is stored (if accessab...
Definition: arrayndinfo.h:71
virtual int getSize(int dim) const
Definition: arrayndinfo.h:258
virtual int getNDim() const
Definition: arrayndinfo.h:99
RowCol getArrayPos(const EM::PosID &) const
virtual Array1DInfo * clone() const
Definition: arrayndinfo.h:144
virtual uint64_t getTotalSz() const
Definition: arrayndinfo.h:232
virtual int getSize(int dim) const =0
int ndim_
Definition: arrayndinfo.h:239
Implementation of Array3DInfo.
Definition: arrayndinfo.h:193
virtual bool isOK() const
Definition: arrayndinfo.h:177
virtual bool validPos(int pos) const
Definition: arrayndinfo.h:79
virtual bool validPos(const int *iarr) const
Definition: arrayndinfo.h:107
virtual uint64_t getOffset(int pos) const
Definition: arrayndinfo.h:77
Contains the information about the size of Array2D, and in what order the data is stored (if accessab...
Definition: arrayndinfo.h:95
bool operator!=(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:62
virtual bool isOK() const
Definition: arrayndinfo.h:204
virtual uint64_t getOffset(const int *) const
virtual int getSize(int dim) const
Definition: arrayndinfo.h:246
virtual bool isOK() const
Definition: arrayndinfo.h:230
#define od_uint64
Definition: plftypes.h:37
virtual uint64_t getTotalSz() const
Definition: arrayndinfo.h:179
virtual Array3DInfo * clone() const
Definition: arrayndinfo.h:197
virtual uint64_t getTotalSz() const
Definition: arrayndinfo.h:205
int dimsz_
Definition: arrayndinfo.h:157
static uiHor3DInterpol * create(uiParent *)
Implementation of Array1DInfo.
Definition: arrayndinfo.h:140
virtual bool isOK() const
Definition: arrayndinfo.h:152
virtual Array2DInfo * clone() const
Definition: arrayndinfo.h:170
Implementation of Array2DInfo.
Definition: arrayndinfo.h:166
int * dimsz_
Definition: arrayndinfo.h:240
virtual uint64_t getTotalSz() const
Definition: arrayndinfo.h:153
virtual uint64_t getOffset(const int *iarr) const
Definition: arrayndinfo.h:82
virtual int getSize(int dim) const
Definition: arrayndinfo.h:252
virtual uint64_t getOffset(const int *iarr) const
Definition: arrayndinfo.h:105
virtual bool validPos(const int *iarr) const
Definition: arrayndinfo.h:84
virtual ~ArrayNDInfo()
Definition: arrayndinfo.h:28
virtual uint64_t getOffset(const int *iarr) const
Definition: arrayndinfo.h:128
virtual int getNDim() const
Definition: arrayndinfo.h:122

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019