OpendTect-6_4  6.4
arrayndwrapper.h
Go to the documentation of this file.
1 #ifndef arrayndwrapper_h
2 #define arrayndwrapper_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Nanne Hemstra
9  Date: October 2007
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 
20 //TODO: Write more info
22 {
23 public:
24  void setDimMap(int srcdim,int targetdim)
25  { dimmap_[srcdim] = targetdim; }
26 
27  virtual void init() = 0;
28  virtual bool isOK() const = 0;
29 
30 protected:
32  { dimmap_.setSize( info.getNDim(), 0 ); }
33 
35 };
36 
37 
38 
43 template <class T>
44 mClass(Basic) Array3DWrapper : public Array3D<T>, public ArrayNDWrapper
45 {
46 public:
48  ~Array3DWrapper();
49 
50  void init();
51  bool isOK() const;
52 
53  void set(int,int,int,T);
54  T get(int,int,int) const;
55 
56  const Array3DInfo& info() const { return info_; }
57 
58 protected:
59 
62 };
63 
64 
65 
66 template <class T>
68  : ArrayNDWrapper(arr.info())
69  , srcarr_(arr)
70  , info_(*new Array3DInfoImpl(1,1,1))
71 {
72 }
73 
74 template <class T>
76 { delete &info_; }
77 
78 
79 template <class T>
81 {
82  for ( int idx=0; idx<dimmap_.size(); idx++ )
83  info_.setSize( dimmap_[idx], srcarr_.info().getSize(idx) );
84 }
85 
86 
87 template <class T>
89 { return srcarr_.info().getNDim() < 3; }
90 
91 
92 template <class T>
93 void Array3DWrapper<T>::set( int i0, int i1, int i2, T val )
94 {
95  int pos3d[] = { i0, i1, i2 };
96  TypeSet<int> posnd;
97  for ( int idx=0; idx<dimmap_.size(); idx++ )
98  posnd += pos3d[ dimmap_[idx] ];
99 
100  srcarr_.setND( posnd.arr(), val );
101 }
102 
103 
104 template <class T>
105 T Array3DWrapper<T>::get( int i0, int i1, int i2 ) const
106 {
107  int pos3d[] = { i0, i1, i2 };
108  TypeSet<int> posnd;
109  for ( int idx=0; idx<dimmap_.size(); idx++ )
110  posnd += pos3d[ dimmap_[idx] ];
111 
112  return srcarr_.getND( posnd.arr() );
113 }
114 
115 #endif
virtual int getNDim() const =0
void init()
Definition: arrayndwrapper.h:80
ArrayND< T > & srcarr_
Definition: arrayndwrapper.h:61
T get(int, int, int) const
Definition: arrayndwrapper.h:105
Contains the information about the size of Array3D, and in what order the data is stored (if accessab...
Definition: arrayndinfo.h:118
virtual bool setSize(int dim, int sz)
bool init()
Contains the information about the size of ArrayND, and in what order the data is stored (if accessab...
Definition: arrayndinfo.h:23
TypeSet< int > dimmap_
Definition: arrayndwrapper.h:34
~Array3DWrapper()
Definition: arrayndwrapper.h:75
virtual T * arr()
3rd party access
Definition: typeset.h:92
Implementation of Array3DInfo.
Definition: arrayndinfo.h:193
void setDimMap(int srcdim, int targetdim)
Definition: arrayndwrapper.h:24
Access tool to another array with a lower number of dimensions.
Definition: arrayndwrapper.h:21
bool isOK() const
Definition: arrayndwrapper.h:88
void set(int, int, int, T)
Definition: arrayndwrapper.h:93
An ArrayND is an array with a given number of dimensions and a size.
Definition: arraynd.h:33
Subclass of ArrayNDWrapper.
Definition: arrayndwrapper.h:44
size_type size() const
Definition: typeset.h:254
Array3DWrapper(ArrayND< T > &)
Definition: arrayndwrapper.h:67
#define mClass(module)
Definition: commondefs.h:164
Array3D ( Subclass of ArrayND ) is a three dimensional array.
Definition: arraynd.h:153
const Array3DInfo & info() const
Definition: arrayndwrapper.h:56
Array3DInfo & info_
Definition: arrayndwrapper.h:60
ArrayNDWrapper(const ArrayNDInfo &info)
Definition: arrayndwrapper.h:31

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