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

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