OpendTect  6.6
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  RCS: $Id$
10 ________________________________________________________________________
11 
12 -*/
13 
14 
19 //TODO: Write more info
21 {
22 public:
23  void setDimMap(int srcdim,int targetdim)
24  { dimmap_[srcdim] = targetdim; }
25 
26  virtual void init() = 0;
27  virtual bool isOK() const = 0;
28 
29 protected:
31  { dimmap_.setSize( info.getNDim(), 0 ); }
32 
34 };
35 
36 
37 
42 template <class T>
44 {
45 public:
47  ~Array3DWrapper();
48 
49  void init();
50  bool isOK() const;
51 
52  void set(int,int,int,T);
53  T get(int,int,int) const;
54 
55  const Array3DInfo& info() const { return info_; }
56 
57 protected:
58 
61 };
62 
63 
64 
65 template <class T>
67  : ArrayNDWrapper(arr.info())
68  , srcarr_(arr)
69  , info_(*new Array3DInfoImpl(1,1,1))
70 {
71 }
72 
73 template <class T>
75 { delete &info_; }
76 
77 
78 template <class T>
80 {
81  for ( int idx=0; idx<dimmap_.size(); idx++ )
82  info_.setSize( dimmap_[idx], srcarr_.info().getSize(idx) );
83 }
84 
85 
86 template <class T>
88 { return srcarr_.info().getNDim() < 3; }
89 
90 
91 template <class T>
92 void Array3DWrapper<T>::set( int i0, int i1, int i2, T val )
93 {
94  int pos3d[] = { i0, i1, i2 };
95  TypeSet<int> posnd;
96  for ( int idx=0; idx<dimmap_.size(); idx++ )
97  posnd += pos3d[ dimmap_[idx] ];
98 
99  srcarr_.setND( posnd.arr(), val );
100 }
101 
102 
103 template <class T>
104 T Array3DWrapper<T>::get( int i0, int i1, int i2 ) const
105 {
106  int pos3d[] = { i0, i1, i2 };
107  TypeSet<int> posnd;
108  for ( int idx=0; idx<dimmap_.size(); idx++ )
109  posnd += pos3d[ dimmap_[idx] ];
110 
111  return srcarr_.getND( posnd.arr() );
112 }
113 
Strat::init
void init()
Array3DWrapper::info_
Array3DInfo & info_
Definition: arrayndwrapper.h:59
ArrayNDInfo
Contains the information about the size of ArrayND, and in what order the data is stored (if accessab...
Definition: arrayndinfo.h:25
Array3DWrapper
Subclass of ArrayNDWrapper.
Definition: arrayndwrapper.h:44
ArrayNDWrapper::setDimMap
void setDimMap(int srcdim, int targetdim)
Definition: arrayndwrapper.h:23
ArrayNDWrapper::init
virtual void init()=0
ArrayNDWrapper::isOK
virtual bool isOK() const =0
Array3DWrapper::init
void init()
Definition: arrayndwrapper.h:79
Array3DWrapper::~Array3DWrapper
~Array3DWrapper()
Definition: arrayndwrapper.h:74
Array3D
Array3D ( Subclass of ArrayND ) is a three dimensional array.
Definition: arraynd.h:162
ArrayNDWrapper::dimmap_
TypeSet< int > dimmap_
Definition: arrayndwrapper.h:33
Array3DWrapper::isOK
bool isOK() const
Definition: arrayndwrapper.h:87
mClass
#define mClass(module)
Definition: commondefs.h:181
Array3DWrapper::info
const Array3DInfo & info() const
Definition: arrayndwrapper.h:55
ArrayNDWrapper::ArrayNDWrapper
ArrayNDWrapper(const ArrayNDInfo &info)
Definition: arrayndwrapper.h:30
Conv::set
void set(T &_to, const F &fr)
template based type conversion
Definition: convert.h:27
Array3DInfo
Contains the information about the size of Array3D, and in what order the data is stored (if accessab...
Definition: arrayndinfo.h:147
Array3DWrapper::srcarr_
ArrayND< T > & srcarr_
Definition: arrayndwrapper.h:60
Array3DInfoImpl
Implementation of Array3DInfo.
Definition: arrayndinfo.h:239
Array3DWrapper::get
T get(int, int, int) const
Definition: arrayndwrapper.h:104
ArrayND
An ArrayND is an array with a given number of dimensions and a size.
Definition: arraynd.h:33
ArrayNDInfo::getNDim
virtual int getNDim() const =0
Array3DWrapper::Array3DWrapper
Array3DWrapper(ArrayND< T > &)
Definition: arrayndwrapper.h:66
Array3DWrapper::set
void set(int, int, int, T)
Definition: arrayndwrapper.h:92
ArrayNDWrapper
Access tool to another array with a lower number of dimensions.
Definition: arrayndwrapper.h:21
TypeSet< int >

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