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

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