OpendTect-6_4  6.4
windowfunction.h
Go to the documentation of this file.
1 #ifndef windowfunction_h
2 #define windowfunction_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Kristofer
9  Date: 2007
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 
16 #include "algomod.h"
17 #include "factory.h"
18 #include "mathfunc.h"
19 
20 
28 {
29 public:
30  virtual const char* name() const = 0;
31  virtual bool hasVariable() const { return false; }
32  virtual float getVariable() const { return mUdf(float); }
33  virtual bool setVariable(float) { return true; }
34  virtual const char* variableName() const { return 0; }
35  virtual bool isAcceptableVariable(float) const { return true; }
36 
37  static const char* sKeyVariable() { return "Variable"; }
38  static const char* sKeyTaperVal() { return "taperval"; }
39  static bool hasVariable(const BufferString& wintyp);
40 
41  void fillPar(IOPar&) const;
42  bool usePar(const IOPar&);
43 
44 #define mDeclWFStdFns(nm) \
45  static void initClass(); \
46  static const char* sName() { return #nm; }\
47  static WindowFunction* create() { return new nm##Window; } \
48  const char* name() const { return #nm; } \
49  float getValue(float) const; \
50  float getValue( const float* x ) const { return getValue(*x); }
51 
52  static void addAllStdClasses(); // done by Algo/initalgo.cc
53 
54 };
55 
56 
57 #define mDeclWFSimpleClass(nm) \
58 mExpClass(Algo) nm##Window : public WindowFunction \
59 { \
60 public: \
61  mDeclWFStdFns(nm); \
62 };
63 
70 
71 
72 #define mDeclWFClassWithVariable(clss) \
73  clss##Window(); \
74  bool hasVariable() const { return true; } \
75  bool setVariable(float); \
76  bool isAcceptableVariable(float) const; \
77 
78 
83 {
84 public:
85 
86  mDeclWFStdFns(CosTaper)
88 
89  float getVariable() const { return threshold_; }
90  const char* variableName() const
91  { return "Taper length";}
92 
93  static bool isLegacyTaper(const BufferString&);
94  static float getLegacyTaperVariable(const BufferString&);
95 
96 protected:
97 
98  float threshold_;
99  float factor_;
100 };
101 
102 
108 {
109 public:
110 
113 
114  KaiserWindow(double twidth,int nrsamples);
115  bool set(double width,int nrsamples);
116  //Alternate way of setting alpha
117 
118  float getVariable() const { return (float)alpha_;}
119  const char* variableName() const { return "alpha"; }
120 
121  // Variable must be set first
122  double getWidth() const { return width_; }
123  double getError() const;
124  int getLength() const { return ns_; }
125  double getWidth(int nrsamples) const;
126  double getError(int nrsamples) const;
127 
128 protected:
129 
130  double alpha_;
131  double denom_;
132  double width_;
133  int ns_;
134 };
135 
136 
137 mDefineFactory(Algo,WindowFunction,WINFUNCS);
138 
139 
140 #endif
#define mExpClass(module)
Definition: commondefs.h:160
Kaiser Window Function.
Definition: windowfunction.h:107
virtual bool isAcceptableVariable(float) const
Definition: windowfunction.h:35
int getLength() const
Definition: windowfunction.h:124
float factor_
Definition: windowfunction.h:99
void usePar(const IOPar &iop, ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:188
double denom_
Definition: windowfunction.h:131
double alpha_
Definition: windowfunction.h:130
Mathematical function.
Definition: mathfunc.h:61
virtual bool hasVariable() const
Definition: windowfunction.h:31
int ns_
Definition: windowfunction.h:133
double getWidth() const
Definition: windowfunction.h:122
void set(T &_to, const F &fr)
template based type conversion
Definition: convert.h:29
mDefineFactory(Algo, WindowFunction, WINFUNCS)
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
static const char * sKeyTaperVal()
Definition: windowfunction.h:38
double width_
Definition: windowfunction.h:132
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:272
#define mDeclWFStdFns(nm)
Definition: windowfunction.h:44
Tapered Cosine Window Function.
Definition: windowfunction.h:82
virtual bool setVariable(float)
Definition: windowfunction.h:33
void fillPar(IOPar &iop, const ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:175
virtual const char * variableName() const
Definition: windowfunction.h:34
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
#define mDeclWFSimpleClass(nm)
Definition: windowfunction.h:57
float threshold_
Definition: windowfunction.h:98
const char * variableName() const
Definition: windowfunction.h:90
Base class for window functions. The inheriting classes will give a value between 0 and 1 in the inte...
Definition: windowfunction.h:27
#define mDeclWFClassWithVariable(clss)
Definition: windowfunction.h:72
virtual float getVariable() const
Definition: windowfunction.h:32
static const char * sKeyVariable()
Definition: windowfunction.h:37
const char * variableName() const
Definition: windowfunction.h:119

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