OpendTect  6.3
arrayndsmoother.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: Bert
8  Date: Mar 2010
9 ________________________________________________________________________
10 
11 
12 -*/
13 
14 #include "algomod.h"
15 #include "executor.h"
16 #include "arraynd.h"
17 
27 template <class T>
30 public:
31 
33  ArrayND<T>&);
35 
36  uiString message() const { return tr("Smoothing"); }
37  od_int64 totalNr() const { return totnr_; }
38  od_int64 nrDone() const { return nrdone_; }
39  uiString nrDoneText() const { return tr("Points handled"); }
40 
41  int nextStep();
42 
43 protected:
44 
45  const ArrayND<T>& inp_;
49  const int nrdims_;
52 
53 };
54 
55 
56 template <class T>
58  ArrayND<T>& out )
59  : Executor("Data smoother")
60  , inp_(inp)
61  , out_(out)
62  , nrdims_(inp.info().getNDim())
63  , it_(inp.info())
64  , nrdone_(0)
65 {
66  totnr_ = 1;
67  for ( int idim=0; idim<nrdims_; idim++ )
68  {
69  int dimsz = inp_.info().getSize(idim);
70  maxidxs_ += dimsz - 1;
71  totnr_ *= dimsz;
72  }
73 }
74 
75 
76 template <class T>
78 {
79  const int* itpos = it_.getPos();
80  TypeSet<T> vals;
81 
82  for ( int idim=0; idim<nrdims_; idim++ )
83  {
84  for ( int idx=0; idx<2; idx++ )
85  {
86  TypeSet<int> arridxs( itpos, nrdims_ );
87  int& arridx = arridxs[idim];
88  if ( idx )
89  {
90  arridx++;
91  if ( arridx > maxidxs_[idim] ) arridx = maxidxs_[idim];
92  }
93  else
94  {
95  arridx--;
96  if ( arridx < 0 ) arridx = 0;
97  }
98  vals += inp_.getND( arridxs.arr() );
99  }
100  }
101 
102  T smval = 0; const int nrvals = vals.size();
103  const T val0 = inp_.getND( itpos );
104  for ( int idx=0; idx<nrvals; idx++ )
105  { smval += val0; smval += vals[idx]; }
106  smval /= 2 * nrvals;
107  out_.setND( itpos, smval );
108  nrdone_++;
109 
110  return it_.next() ? MoreToDo() : Finished();
111 }
ArrayND< T > & out_
Definition: arrayndsmoother.h:46
#define mODTextTranslationClass(clss)
Definition: uistring.h:37
od_int64 totnr_
Definition: arrayndsmoother.h:47
#define od_int64
Definition: plftypes.h:34
Definition: uistring.h:88
static int MoreToDo()
Definition: task.h:166
uiString nrDoneText() const
Definition: arrayndsmoother.h:39
virtual T * arr()
3rd party access
Definition: typeset.h:86
Gently smooths ArrayND by averaging with neighbours.
Definition: arrayndsmoother.h:28
static int Finished()
Definition: task.h:165
const ArrayND< T > & inp_
Definition: arrayndsmoother.h:45
virtual mODTextTranslationClass(ArrayNDGentleSmoother) public ~ArrayNDGentleSmoother()
Definition: arrayndsmoother.h:34
od_int64 nrDone() const
Definition: arrayndsmoother.h:38
od_int64 nrdone_
Definition: arrayndsmoother.h:48
An ArrayND is an array with a given number of dimensions and a size.
Definition: arraynd.h:29
Iterates through all samples in an ArrayND.
Definition: arraynd.h:175
size_type size() const
const int * getPos() const
Definition: arraynd.h:187
const int nrdims_
Definition: arrayndsmoother.h:49
od_int64 totalNr() const
Definition: arrayndsmoother.h:37
int nextStep()
Definition: arrayndsmoother.h:77
#define mClass(module)
Definition: commondefs.h:161
ArrayNDIter it_
Definition: arrayndsmoother.h:50
TypeSet< int > maxidxs_
Definition: arrayndsmoother.h:51
uiString message() const
Definition: arrayndsmoother.h:36
Specification to enable chunkwise execution of a process.
Definition: executor.h:38

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