OpendTect-6_4  6.4
seisposkey.h
Go to the documentation of this file.
1 #ifndef seisposkey_h
2 #define seisposkey_h
3 
4 /*
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Bert
9  Date: Nov 2008
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 */
14 
15 #include "seismod.h"
16 #include "seistype.h"
17 #include "binid.h"
18 
19 
20 namespace Seis
21 {
22 
24 {
25 public:
26 
27  inline PosKey(Seis::GeomType gt=Seis::Vol);
28  inline PosKey( const BinID& bid, float offs=mUdf(float) )
29  : binid_(bid), offset_(offs) {}
30  inline PosKey( int trcnr, float offs=mUdf(float) )
31  : binid_(mUdf(int),trcnr), offset_(offs) {}
32  inline bool operator ==(const PosKey&) const;
33 
34  inline bool is2D() const { return mIsUdf(binid_.inl()); }
35  inline bool isPS() const { return !mIsUdf(offset_); }
36  inline Seis::GeomType geomType() const { return geomTypeOf(
37  is2D(),isPS()); }
38  inline bool isUndef() const { return mIsUdf(binid_.crl()); }
39  inline void setUndef() { mSetUdf(binid_.crl()); }
40 
41  inline const BinID& binID() const { return binid_; }
42  inline int trcNr() const { return binid_.crl(); }
43  inline int inLine() const { return binid_.inl(); }
44  inline int xLine() const { return binid_.crl(); }
45  inline float offset() const { return offset_; }
46  inline bool hasOffset(float) const;
47 
48  inline void setTrcNr( int trcnr ) { binid_.crl() = trcnr; }
49  inline void setBinID( const BinID& bid ) { binid_ = bid; }
50  inline void setInline( int inl ) { binid_.inl() = inl; }
51  inline void setXine( int crl ) { binid_.crl() = crl; }
52  inline void setOffset( float offs ) { offset_ = offs; }
53  inline void set( const BinID& bid, float offs )
54  { binid_ = bid; offset_ = offs; }
55  inline void set( int trcnr, float offs )
56  { binid_.inl() = mUdf(int); binid_.crl() = trcnr;
57  offset_ = offs; }
58  inline void set(int trcnr,const BinID&,float);
60 
61  inline int& trcNr() { return binid_.crl(); }
62  inline BinID& binID() { return binid_; }
63  inline float& offset() { return offset_; }
64  inline int& inLine() { return binid_.inl(); }
65  inline int& xLine() { return binid_.crl(); }
66 
67  static PosKey undef() { return PosKey( mUdf(int) ); }
68 
69 protected:
70 
71  BinID binid_;
72  float offset_;
73 
74 };
75 
76 
78  : binid_(0,0)
79  , offset_(0)
80 {
81  if ( Seis::is2D(gt) ) mSetUdf(binid_.inl());
82  if ( !Seis::isPS(gt) ) mSetUdf(offset_);
83 }
84 
85 inline bool PosKey::hasOffset( float offs ) const
86 {
87  const float diff = offs - offset_;
88  return mIsZero(diff,1e-4);
89 }
90 
91 inline void PosKey::set( int nr, const BinID& bid, float offs )
92 {
93  const Seis::GeomType gt( geomType() );
94  if ( Seis::is2D(gt) )
95  setTrcNr( nr );
96  else
97  setBinID( bid );
98  if ( Seis::isPS(gt) )
99  offset_ = offs;
100  else
101  mSetUdf(offset_);
102 
103 }
104 
105 inline bool PosKey::operator ==( const PosKey& pk ) const
106 {
107  if ( binid_ != pk.binid_ )
108  return false;
109 
110  if ( mIsUdf(pk.offset_) )
111  return mIsUdf( offset_ );
112 
113  return mIsEqual(offset_,pk.offset_,1e-4); }
114 
115 };
116 
117 
118 #endif
const BinID & binID() const
Definition: seisposkey.h:41
#define mExpClass(module)
Definition: commondefs.h:160
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:287
Summary for a Seismic object.
Definition: segydirectdef.h:23
int trcNr() const
Definition: seisposkey.h:42
float & offset()
Definition: seisposkey.h:63
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:53
#define mSetUdf(val)
Use this macro to set simple types to undefined.
Definition: undefval.h:274
#define mIsZero(x, eps)
Definition: commondefs.h:53
bool is2D(GeomType gt)
Definition: seistype.h:34
PosKey(int trcnr, float offs=mUdf(float))
Definition: seisposkey.h:30
IdxType & inl()
Definition: posidxpair.h:43
int & xLine()
Definition: seisposkey.h:65
void setXine(int crl)
Definition: seisposkey.h:51
int inLine() const
Definition: seisposkey.h:43
void setInline(int inl)
Definition: seisposkey.h:50
BinID binid_
Definition: seisposkey.h:71
Definition: seisposkey.h:23
#define mIsEqual(x, y, eps)
Definition: commondefs.h:54
GeomType
Definition: seistype.h:33
bool isPS(GeomType gt)
Definition: seistype.h:38
int & inLine()
Definition: seisposkey.h:64
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:272
bool is2D() const
Definition: seisposkey.h:34
bool operator==(const PosKey &) const
Definition: seisposkey.h:105
PosKey(Seis::GeomType gt=Seis::Vol)
Definition: seisposkey.h:77
void setOffset(float offs)
Definition: seisposkey.h:52
Seis::GeomType geomType() const
Definition: seisposkey.h:36
void setTrcNr(int trcnr)
Definition: seisposkey.h:48
float offset() const
Definition: seisposkey.h:45
Positioning in a seismic survey: inline/crossline or lineNr/trcNr.
Definition: binid.h:30
bool isUndef() const
Definition: seisposkey.h:38
BinID & binID()
Definition: seisposkey.h:62
Definition: seistype.h:33
static PosKey undef()
Definition: seisposkey.h:67
float offset_
Definition: seisposkey.h:72
GeomType geomTypeOf(const char *)
bool hasOffset(float) const
Definition: seisposkey.h:85
void set(const BinID &bid, float offs)
Definition: seisposkey.h:53
int xLine() const
Definition: seisposkey.h:44
int & trcNr()
Definition: seisposkey.h:61
void setUndef()
Definition: seisposkey.h:39
bool isPS() const
Definition: seisposkey.h:35
void setBinID(const BinID &bid)
Definition: seisposkey.h:49
PosKey(const BinID &bid, float offs=mUdf(float))
Definition: seisposkey.h:28

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