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

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