OpendTect  6.3
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 ________________________________________________________________________
9 
10 -*/
11 
12 #include "algomod.h"
13 #include "manobjectset.h"
14 #include "angles.h"
15 #include "ranges.h"
16 
17 namespace Stats
18 {
19 
25 {
26 public:
27 
28  SectorPartData( float v=0, float p=0.5, int cnt=0 )
29  : val_(v), pos_(p), count_(cnt) {}
30  bool operator ==( const SectorPartData& spd ) const
31  { return pos_ == spd.pos_; }
32 
33  float pos_;
34  float val_;
35  int count_;
36 
37 };
38 
39 
41 
42 
53 mClass(Algo) DirectionalData : public ManagedObjectSet<SectorData>
54 {
55 public:
56 
57  mClass(Algo) Setup
58  {
59  public:
61  : usrposrg_(0,1)
62  , angle0_(0)
63  , angletype_(Angle::UsrDeg) {}
64 
66  float angle0_;
68  };
69 
70  DirectionalData(int nrsectors=0,int nrparts=0);
71 
72  SectorPartData& getPartData( int isect, int ipart )
73  { return (*((*this)[isect]))[ipart]; }
74  const SectorPartData& getPartData( int isect, int ipart ) const
75  { return (*((*this)[isect]))[ipart]; }
76  inline int nrSectors() const
77  { return size(); }
78  inline int nrParts( int isect ) const
79  { return ((*this)[isect])->size(); }
80  inline float angle(int isect,int bound=0) const;
81  inline float angle(int isect,Angle::Type,int bound=0) const;
83  int sector(float ang) const;
84  int sector(float ang,Angle::Type) const;
85 
87 
88 };
89 
90 
91 inline float DirectionalData::angle( int isect, int bound ) const
92 {
93  float fullc; Angle::getFullCircle( setup_.angletype_, fullc );
94  const float angstep = fullc / size();
95  const float centerang = setup_.angle0_ + angstep * isect;
96  return centerang + bound * angstep * .5f;
97 }
98 
99 
100 inline float DirectionalData::angle( int isect, Angle::Type t, int bound ) const
101 {
102  float ang = angle( isect, bound );
103  return Angle::convert( setup_.angletype_, ang, t );
104 }
105 
106 
107 inline int DirectionalData::sector( float ang, Angle::Type t ) const
108 {
109  return sector( Angle::convert(t,ang,setup_.angletype_) );
110 }
111 
112 
113 inline int DirectionalData::sector( float ang ) const
114 {
115  ang -= setup_.angle0_;
116  const float usrang = Angle::convert(setup_.angletype_,ang,Angle::UsrDeg);
117  const float fsect = size() * (usrang / 360);
118  int sect = mNINT32(fsect);
119  if ( sect >= size() ) sect = 0;
120  return sect;
121 }
122 
123 
124 inline DirectionalData::DirectionalData( int nrsect, int nrparts )
125 {
126  for ( int isect=0; isect<nrsect; isect++ )
127  {
128  SectorData* sd = new SectorData;
129  *this += sd;
130  for ( int ipart=0; ipart<nrparts; ipart++ )
131  *sd += SectorPartData( 0, (ipart + .5f) / nrparts, 0 );
132  }
133 }
134 
135 
136 }; // namespace Stats
Definition: angles.h:25
A circle of data.
Definition: statdirdata.h:53
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:51
float val_
actual angle or a value of interest
Definition: statdirdata.h:34
Setup setup_
Definition: statdirdata.h:86
Interval< float > usrposrg_
Definition: statdirdata.h:65
int count_
nr data pts contributing (for confidence)
Definition: statdirdata.h:35
Angle::Type angletype_
Definition: statdirdata.h:67
size_type size() const
Definition: objectset.h:48
#define mNINT32(x)
Definition: commondefs.h:48
Set of (small) copyable elements.
Definition: commontypes.h:26
const SectorPartData & getPartData(int isect, int ipart) const
Definition: statdirdata.h:74
SectorPartData & getPartData(int isect, int ipart)
Definition: statdirdata.h:72
float angle0_
Definition: statdirdata.h:66
Part of a data sector.
Definition: statdirdata.h:24
Definition: statdirdata.h:57
Definition: angles.h:22
Type
Definition: angles.h:25
void getFullCircle(Type typ, T &t)
Definition: angles.h:32
T convert(Type inptyp, T val, Type outtyp)
Definition: angles.h:74
TypeSet< SectorPartData > SectorData
Definition: statdirdata.h:40
Setup()
Definition: statdirdata.h:60
Statistics.
Definition: array2dinterpol.h:27
int nrParts(int isect) const
Definition: statdirdata.h:78
DirectionalData(int nrsectors=0, int nrparts=0)
Definition: statdirdata.h:124
float pos_
0=center 1=on circle = maximum value
Definition: statdirdata.h:33
#define mClass(module)
Definition: commondefs.h:161
SectorPartData(float v=0, float p=0.5, int cnt=0)
Definition: statdirdata.h:28
int sector(float ang) const
Definition: statdirdata.h:113
ObjectSet where the objects contained are owned by this set.
Definition: manobjectset.h:49
float angle(int isect, int bound=0) const
Definition: statdirdata.h:91
int nrSectors() const
Definition: statdirdata.h:76

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