OpendTect-6_4  6.4
statdirdata.h
Go to the documentation of this file.
1 #ifndef statdirdata_h
2 #define statdirdata_h
3 /*+
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: Bert Bril
8  Date: Mar 2009
9  RCS: $Id$
10 ________________________________________________________________________
11 
12 -*/
13 
14 #include "algomod.h"
15 #include "manobjectset.h"
16 #include "angles.h"
17 #include "ranges.h"
18 
19 namespace Stats
20 {
21 
27 {
28 public:
29 
30  SectorPartData( float v=0, float p=0.5, int cnt=0 )
31  : val_(v), pos_(p), count_(cnt) {}
32  bool operator ==( const SectorPartData& spd ) const
33  { return pos_ == spd.pos_; }
34 
35  float pos_;
36  float val_;
37  int count_;
38 
39 };
40 
41 
43 
44 
55 mClass(Algo) DirectionalData : public ManagedObjectSet<SectorData>
56 {
57 public:
58 
59  mClass(Algo) Setup
60  {
61  public:
63  : usrposrg_(0,1)
64  , angle0_(0)
65  , angletype_(Angle::UsrDeg) {}
66 
68  float angle0_;
70  };
71 
72  DirectionalData(int nrsectors=0,int nrparts=0);
73 
74  void init(int nrsectors,int nrparts);
75 
76  SectorPartData& get( int isect, int ipart )
77  { return (*((*this)[isect]))[ipart]; }
78  const SectorPartData& get( int isect, int ipart ) const
79  { return (*((*this)[isect]))[ipart]; }
80  inline int nrSectors() const
81  { return size(); }
82  inline int nrParts( int isect ) const
83  { return ((*this)[isect])->size(); }
84  inline float angle(int isect,int bound=0) const;
85  inline float angle(int isect,Angle::Type,int bound=0) const;
87  int sector(float ang) const;
88  int sector(float ang,Angle::Type) const;
89  int part(int isect,float pos) const;
90 
92 
93 };
94 
95 
96 inline float DirectionalData::angle( int isect, int bound ) const
97 {
98  if ( isEmpty() )
99  return mUdf(float);
100 
101  float fullc; Angle::getFullCircle( setup_.angletype_, fullc );
102  const float angstep = fullc / size();
103  const float centerang = setup_.angle0_ + angstep * isect;
104  return centerang + bound * angstep * .5f;
105 }
106 
107 
108 inline float DirectionalData::angle( int isect, Angle::Type t, int bound ) const
109 {
110  const float ang = angle( isect, bound );
111  return Angle::convert( setup_.angletype_, ang, t );
112 }
113 
114 
115 inline int DirectionalData::sector( float ang, Angle::Type t ) const
116 {
117  return sector( Angle::convert(t,ang,setup_.angletype_) );
118 }
119 
120 
121 inline int DirectionalData::sector( float ang ) const
122 {
123  if ( mIsUdf(ang) )
124  return 0;
125 
126  ang -= setup_.angle0_;
127  const float usrang = Angle::convert(setup_.angletype_,ang,Angle::UsrDeg);
128  const float fsect = size() * (usrang / 360);
129  int sect = mNINT32(fsect);
130  if ( sect >= size() ) sect = 0;
131  return sect;
132 }
133 
134 
135 inline int DirectionalData::part( int isect, float pos ) const
136 {
137  const int nrparts = nrParts( isect );
138  const float fpart = nrparts * pos / setup_.usrposrg_.width();
139  int prt = (int)fpart;
140  if ( prt<0 ) prt = 0;
141  if ( prt>=nrparts ) prt = nrparts-1;
142  return prt;
143 }
144 
145 
146 inline DirectionalData::DirectionalData( int nrsect, int nrparts )
147 {
148  init( nrsect, nrparts );
149 }
150 
151 
152 inline void DirectionalData::init( int nrsect, int nrparts )
153 {
154  erase();
155 
156  for ( int isect=0; isect<nrsect; isect++ )
157  {
158  SectorData* sd = new SectorData;
159  *this += sd;
160  for ( int ipart=0; ipart<nrparts; ipart++ )
161  *sd += SectorPartData( 0, (ipart + .5f) / nrparts, 0 );
162  }
163 }
164 
165 } // namespace Stats
166 
167 #endif
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:287
Definition: angles.h:27
A circle of data.
Definition: statdirdata.h:55
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:53
float val_
actual angle or a value of interest
Definition: statdirdata.h:36
bool init()
virtual void erase()
Definition: manobjectset.h:37
Setup setup_
Definition: statdirdata.h:91
Interval< float > usrposrg_
Definition: statdirdata.h:67
int count_
nr data pts contributing (for confidence)
Definition: statdirdata.h:37
Angle::Type angletype_
Definition: statdirdata.h:69
bool isEmpty() const
Definition: odset.h:45
size_type size() const
Definition: objectset.h:50
#define mNINT32(x)
Definition: commondefs.h:45
Set of (small) copyable elements.
Definition: commontypes.h:30
T width(bool allowrev=true) const
Definition: ranges.h:451
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:272
float angle0_
Definition: statdirdata.h:68
Part of a data sector.
Definition: statdirdata.h:26
Definition: statdirdata.h:59
Definition: angles.h:24
Type
Definition: angles.h:27
void getFullCircle(Type typ, T &t)
Definition: angles.h:34
T convert(Type inptyp, T val, Type outtyp)
Definition: angles.h:76
TypeSet< SectorPartData > SectorData
Definition: statdirdata.h:42
Setup()
Definition: statdirdata.h:62
Statistics.
Definition: array2dinterpol.h:28
void init(int nrsectors, int nrparts)
Definition: statdirdata.h:152
int nrParts(int isect) const
Definition: statdirdata.h:82
DirectionalData(int nrsectors=0, int nrparts=0)
Definition: statdirdata.h:146
float pos_
0=center 1=on circle = maximum value
Definition: statdirdata.h:35
#define mClass(module)
Definition: commondefs.h:164
SectorPartData(float v=0, float p=0.5, int cnt=0)
Definition: statdirdata.h:30
int sector(float ang) const
Definition: statdirdata.h:121
ObjectSet where the objects contained are owned by this set.
Definition: manobjectset.h:23
int part(int isect, float pos) const
Definition: statdirdata.h:135
float angle(int isect, int bound=0) const
Definition: statdirdata.h:96
int nrSectors() const
Definition: statdirdata.h:80

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