OpendTect-6_4  6.4
probdenfunc.h
Go to the documentation of this file.
1 #ifndef probdenfunc_h
2 #define probdenfunc_h
3 
4 /*
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Bert
9  Date: Jan 2010
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 
14 */
15 
16 #include "algomod.h"
17 #include "namedobj.h"
18 #include "ranges.h"
19 #include "od_iosfwd.h"
20 
21 
32 {
33 public:
34 
35  virtual ProbDenFunc* clone() const = 0;
36  virtual ~ProbDenFunc() {}
37  virtual void copyFrom(const ProbDenFunc&) = 0;
38  virtual bool isEqual(const ProbDenFunc&) const;
39 
40  virtual const char* getTypeStr() const = 0;
41  virtual int nrDims() const = 0;
42  virtual const char* dimName(int dim) const = 0;
43  virtual void setDimName(int dim,const char*) = 0;
44  virtual float averagePos(int dim) const = 0;
45  virtual float value(const TypeSet<float>&) const = 0;
46 
47  virtual bool canScale() const { return false;}
48  virtual void scale(float) {}
49  virtual float normFac() const { return 1; }
50 
51  // Used for file store/retrieve:
52  virtual void fillPar(IOPar&) const = 0;
53  virtual bool usePar(const IOPar&) = 0;
54  virtual void writeBulk(od_ostream&,bool binary) const {}
55  virtual bool readBulk(od_istream&,bool binary) { return true; }
56 
57  virtual bool isCompatibleWith(const ProbDenFunc&) const;
58  void getIndexTableFor(const ProbDenFunc& pdf,
59  TypeSet<int>& tbl) const;
61 
62  virtual void prepareRandDrawing() const {}
63  virtual void drawRandomPos(TypeSet<float>&) const = 0;
64  static const char* sKeyNrDim();
65 
66 protected:
67 
69  ProbDenFunc(const ProbDenFunc&);
70 
71  virtual bool isEq(const ProbDenFunc&) const = 0;
73 
74 };
75 
76 
82 {
83 public:
84 
85  virtual void copyFrom( const ProbDenFunc& pdf )
86  { varnm_ = pdf.dimName(0); setName(pdf.name()); }
87 
88  virtual int nrDims() const { return 1; }
89  virtual const char* dimName(int) const { return varName(); }
90  virtual void setDimName( int dim, const char* nm )
91  { if ( !dim ) varnm_ = nm; }
92 
93  virtual const char* varName() const { return varnm_; }
94 
95  virtual float averagePos(int) const { return gtAvgPos(); }
96  inline float value( float v ) const { return gtVal( v ); }
97  virtual float value( const TypeSet<float>& v ) const
98  { return gtVal( v[0] ); }
99 
100  inline void drawRandomPos( float& v ) const
101  { drwRandPos( v ); }
102  virtual void drawRandomPos( TypeSet<float>& v ) const
103  { v.setSize(1); drwRandPos( v[0] ); }
104 
106 
107 protected:
108 
109  ProbDenFunc1D( const char* vnm="" )
110  : varnm_(vnm) {}
112  : ProbDenFunc(pdf)
113  , varnm_(pdf.varnm_) {}
114 
115  virtual float gtAvgPos() const = 0;
116  virtual float gtVal(float) const = 0;
117  virtual void drwRandPos(float&) const = 0;
118 
119 };
120 
121 
127 {
128 public:
129 
130  virtual void copyFrom( const ProbDenFunc& pdf )
131  { dim0nm_ = pdf.dimName(0); dim1nm_ = pdf.dimName(1);
132  setName(pdf.name()); }
133 
134  virtual int nrDims() const { return 2; }
135  virtual const char* dimName(int) const;
136  virtual void setDimName( int dim, const char* nm )
137  { if ( dim < 2 ) (dim ? dim1nm_ : dim0nm_) = nm; }
138 
139  float value( float x1, float x2 ) const
140  { return gtVal( x1, x2 ); }
141  virtual float value( const TypeSet<float>& v ) const
142  { return gtVal( v[0], v[1] ); }
143 
144  inline void drawRandomPos( float& x1, float& x2 ) const
145  { drwRandPos( x1, x2 ); }
146  virtual void drawRandomPos( TypeSet<float>& v ) const
147  { v.setSize(2); drwRandPos( v[0], v[1] ); }
148 
151 
152 protected:
153 
154  ProbDenFunc2D( const char* vnm0="Dim 0",
155  const char* vnm1="Dim 1" )
156  : dim0nm_(vnm0), dim1nm_(vnm1) {}
158  : ProbDenFunc(pdf)
159  , dim0nm_(pdf.dim0nm_)
160  , dim1nm_(pdf.dim1nm_) {}
161  ProbDenFunc2D& operator =(const ProbDenFunc2D&);
162 
163  virtual float gtVal(float,float) const = 0;
164  virtual void drwRandPos(float&,float&) const = 0;
165 
166 };
167 
168 
169 #endif
void drawRandomPos(float &x1, float &x2) const
Definition: probdenfunc.h:144
#define mExpClass(module)
Definition: commondefs.h:160
virtual const char * dimName(int) const
Definition: probdenfunc.h:89
OD class for stream write common access to the user log file, or std::cout in batch progs...
Definition: od_ostream.h:26
Probability Density Function for one dimensional datasets.
Definition: probdenfunc.h:81
virtual void drawRandomPos(TypeSet< float > &v) const
Definition: probdenfunc.h:102
virtual ~ProbDenFunc()
Definition: probdenfunc.h:36
virtual void setDimName(int dim, const char *nm)
Definition: probdenfunc.h:90
Base class for Probability Density Functions.
Definition: probdenfunc.h:31
virtual void prepareRandDrawing() const
Definition: probdenfunc.h:62
void usePar(const IOPar &iop, ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:188
virtual void copyFrom(const ProbDenFunc &pdf)
Definition: probdenfunc.h:130
ProbDenFunc2D(const char *vnm0="Dim 0", const char *vnm1="Dim 1")
Definition: probdenfunc.h:154
virtual float value(const TypeSet< float > &v) const
Definition: probdenfunc.h:97
ProbDenFunc1D(const ProbDenFunc1D &pdf)
Definition: probdenfunc.h:111
ProbDenFunc1D(const char *vnm="")
Definition: probdenfunc.h:109
float value(float v) const
Definition: probdenfunc.h:96
virtual void drawRandomPos(TypeSet< float > &v) const
Definition: probdenfunc.h:146
OD class for stream read.
Definition: od_istream.h:24
virtual const char * dimName(int dim) const =0
void drawRandomPos(float &v) const
Definition: probdenfunc.h:100
virtual int nrDims() const
Definition: probdenfunc.h:88
BufferString dim0nm_
Definition: probdenfunc.h:149
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
virtual float value(const TypeSet< float > &v) const
Definition: probdenfunc.h:141
BufferString dim1nm_
Definition: probdenfunc.h:150
virtual bool readBulk(od_istream &, bool binary)
Definition: probdenfunc.h:55
virtual void setDimName(int dim, const char *nm)
Definition: probdenfunc.h:136
virtual float averagePos(int) const
Definition: probdenfunc.h:95
void fillPar(IOPar &iop, const ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:175
Probability Density Function for two dimensional datasets.
Definition: probdenfunc.h:126
virtual float normFac() const
Definition: probdenfunc.h:49
virtual void copyFrom(const ProbDenFunc &pdf)
Definition: probdenfunc.h:85
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
Object with a name.
Definition: namedobj.h:35
virtual bool setSize(size_type, T val=T())
Definition: typeset.h:258
virtual void scale(float)
Definition: probdenfunc.h:48
virtual const char * varName() const
Definition: probdenfunc.h:93
ProbDenFunc()
Definition: probdenfunc.h:68
ProbDenFunc2D(const ProbDenFunc2D &pdf)
Definition: probdenfunc.h:157
virtual const OD::String & name() const
Definition: namedobj.h:47
float value(float x1, float x2) const
Definition: probdenfunc.h:139
BufferString varnm_
Definition: probdenfunc.h:105
virtual bool canScale() const
Definition: probdenfunc.h:47
virtual void writeBulk(od_ostream &, bool binary) const
Definition: probdenfunc.h:54
virtual int nrDims() const
Definition: probdenfunc.h:134

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