OpendTect-6_4  6.4
arrayndsmoother.h
Go to the documentation of this file.
1 #ifndef arrayndsmoother_h
2 #define arrayndsmoother_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Bert
9  Date: Mar 2010
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 
14 -*/
15 
16 #include "algomod.h"
17 #include "executor.h"
18 #include "arraynd.h"
19 
29 template <class T>
32 public:
33 
35  ArrayND<T>&);
37 
38  uiString uiMessage() const { return tr("Smoothing"); }
39  od_int64 totalNr() const { return totnr_; }
40  od_int64 nrDone() const { return nrdone_; }
41  uiString uiNrDoneText() const { return tr("Points handled"); }
42 
43  int nextStep();
44 
45 protected:
46 
47  const ArrayND<T>& inp_;
51  const int nrdims_;
54 
55 };
56 
57 
58 template <class T>
60  ArrayND<T>& out )
61  : Executor("Data smoother")
62  , inp_(inp)
63  , out_(out)
64  , nrdims_(inp.info().getNDim())
65  , it_(inp.info())
66  , nrdone_(0)
67 {
68  totnr_ = 1;
69  for ( int idim=0; idim<nrdims_; idim++ )
70  {
71  int dimsz = inp_.info().getSize(idim);
72  maxidxs_ += dimsz - 1;
73  totnr_ *= dimsz;
74  }
75 }
76 
77 
78 template <class T>
80 {
81  const int* itpos = it_.getPos();
82  TypeSet<T> vals;
83 
84  for ( int idim=0; idim<nrdims_; idim++ )
85  {
86  for ( int idx=0; idx<2; idx++ )
87  {
88  TypeSet<int> arridxs( itpos, nrdims_ );
89  int& arridx = arridxs[idim];
90  if ( idx )
91  {
92  arridx++;
93  if ( arridx > maxidxs_[idim] ) arridx = maxidxs_[idim];
94  }
95  else
96  {
97  arridx--;
98  if ( arridx < 0 ) arridx = 0;
99  }
100  vals += inp_.getND( arridxs.arr() );
101  }
102  }
103 
104  T smval = 0; const int nrvals = vals.size();
105  const T val0 = inp_.getND( itpos );
106  for ( int idx=0; idx<nrvals; idx++ )
107  { smval += val0; smval += vals[idx]; }
108  smval /= 2 * nrvals;
109  out_.setND( itpos, smval );
110  nrdone_++;
111 
112  return it_.next() ? MoreToDo() : Finished();
113 }
114 
115 
116 
117 #endif
ArrayND< T > & out_
Definition: arrayndsmoother.h:48
#define mODTextTranslationClass(clss)
Definition: uistring.h:38
od_int64 totnr_
Definition: arrayndsmoother.h:49
#define od_int64
Definition: plftypes.h:36
Definition: uistring.h:89
static int MoreToDo()
Definition: task.h:143
virtual T * arr()
3rd party access
Definition: typeset.h:92
Gently smooths ArrayND by averaging with neighbours.
Definition: arrayndsmoother.h:30
static int Finished()
Definition: task.h:142
const ArrayND< T > & inp_
Definition: arrayndsmoother.h:47
virtual mODTextTranslationClass(ArrayNDGentleSmoother) public ~ArrayNDGentleSmoother()
Definition: arrayndsmoother.h:36
od_int64 nrDone() const
Definition: arrayndsmoother.h:40
od_int64 nrdone_
Definition: arrayndsmoother.h:50
out_[idx]
Definition: arrayndalgo.h:1702
An ArrayND is an array with a given number of dimensions and a size.
Definition: arraynd.h:33
Iterates through all samples in an ArrayND.
Definition: arraynd.h:179
uiString uiMessage() const
will be message() again in 7.x
Definition: arrayndsmoother.h:38
size_type size() const
const int * getPos() const
Definition: arraynd.h:191
const int nrdims_
Definition: arrayndsmoother.h:51
od_int64 totalNr() const
Definition: arrayndsmoother.h:39
int nextStep()
Definition: arrayndsmoother.h:79
#define mClass(module)
Definition: commondefs.h:164
ArrayNDIter it_
Definition: arrayndsmoother.h:52
uiString uiNrDoneText() const
will be nrDoneText() in 7.x
Definition: arrayndsmoother.h:41
TypeSet< int > maxidxs_
Definition: arrayndsmoother.h:53
Specification to enable chunkwise execution of a process.
Definition: executor.h:39

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