OpendTect  6.3
seisposkey.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: Bert
8  Date: Nov 2008
9 ________________________________________________________________________
10 
11 */
12 
13 #include "seiscommon.h"
14 #include "binid.h"
15 
16 
17 namespace Seis
18 {
19 
21 {
22 public:
23 
24  inline PosKey(Seis::GeomType gt=Seis::Vol);
25  inline PosKey( const BinID& bid, float offs=mUdf(float) )
26  : binid_(bid), offset_(offs) {}
27  inline PosKey( int trcnr, float offs=mUdf(float) )
28  : binid_(mUdf(int),trcnr), offset_(offs) {}
29  inline bool operator ==(const PosKey&) const;
30  inline bool operator !=( const PosKey& oth ) const
31  { return !(*this == oth); }
32 
33  inline bool is2D() const { return mIsUdf(binid_.inl()); }
34  inline bool isPS() const { return !mIsUdf(offset_); }
35  inline Seis::GeomType geomType() const { return geomTypeOf(
36  is2D(),isPS()); }
37  inline bool isUndef() const { return mIsUdf(binid_.crl()); }
38  inline void setUndef() { mSetUdf(binid_.crl()); }
39 
40  inline const BinID& binID() const { return binid_; }
41  inline int trcNr() const { return binid_.crl(); }
42  inline int inLine() const { return binid_.inl(); }
43  inline int xLine() const { return binid_.crl(); }
44  inline float offset() const { return offset_; }
45  inline bool hasOffset(float) const;
46 
47  inline void setTrcNr( int trcnr ) { binid_.crl() = trcnr; }
48  inline void setBinID( const BinID& bid ) { binid_ = bid; }
49  inline void setInline( int inl ) { binid_.inl() = inl; }
50  inline void setXine( int crl ) { binid_.crl() = crl; }
51  inline void setOffset( float offs ) { offset_ = offs; }
52  inline void set( const BinID& bid, float offs )
53  { binid_ = bid; offset_ = offs; }
54  inline void set( int trcnr, float offs )
55  { binid_.inl() = mUdf(int); binid_.crl() = trcnr;
56  offset_ = offs; }
57  inline void set(int trcnr,const BinID&,float);
59 
60  inline int& trcNr() { return binid_.crl(); }
61  inline BinID& binID() { return binid_; }
62  inline float& offset() { return offset_; }
63  inline int& inLine() { return binid_.inl(); }
64  inline int& xLine() { return binid_.crl(); }
65 
66  static PosKey undef() { return PosKey( mUdf(int) ); }
67 
68 protected:
69 
70  BinID binid_;
71  float offset_;
72 
73 };
74 
75 
77  : binid_(0,0)
78  , offset_(0)
79 {
80  if ( Seis::is2D(gt) ) mSetUdf(binid_.inl());
81  if ( !Seis::isPS(gt) ) mSetUdf(offset_);
82 }
83 
84 inline bool PosKey::hasOffset( float offs ) const
85 {
86  if ( mIsUdf(offs) )
87  return mIsUdf(offset_);
88  return equalOffset( offs, offset_ );
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& oth ) const
106 {
107  if ( binid_ != oth.binid_ )
108  return false;
109 
110  if ( mIsUdf(oth.offset_) )
111  return mIsUdf( offset_ );
112 
113  return mIsEqual(offset_,oth.offset_,1e-4);
114 }
115 
116 
117 } // namespace Seis
const BinID & binID() const
Definition: seisposkey.h:40
#define mExpClass(module)
Definition: commondefs.h:157
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:285
Seismics.
Definition: segydirectdef.h:20
int trcNr() const
Definition: seisposkey.h:41
float & offset()
Definition: seisposkey.h:62
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:51
#define mSetUdf(val)
Use this macro to set simple types to undefined.
Definition: undefval.h:272
bool is2D(GeomType gt)
Definition: seistype.h:32
PosKey(int trcnr, float offs=mUdf(float))
Definition: seisposkey.h:27
IdxType & inl()
Definition: posidxpair.h:41
int & xLine()
Definition: seisposkey.h:64
void setXine(int crl)
Definition: seisposkey.h:50
int inLine() const
Definition: seisposkey.h:42
void setInline(int inl)
Definition: seisposkey.h:49
BinID binid_
Definition: seisposkey.h:70
Definition: seisposkey.h:20
#define mIsEqual(x, y, eps)
Definition: commondefs.h:56
GeomType
Definition: seistype.h:31
bool isPS(GeomType gt)
Definition: seistype.h:36
int & inLine()
Definition: seisposkey.h:63
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:270
bool is2D() const
Definition: seisposkey.h:33
bool operator==(const PosKey &) const
Definition: seisposkey.h:105
PosKey(Seis::GeomType gt=Seis::Vol)
Definition: seisposkey.h:76
bool operator!=(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:60
void setOffset(float offs)
Definition: seisposkey.h:51
Seis::GeomType geomType() const
Definition: seisposkey.h:35
void setTrcNr(int trcnr)
Definition: seisposkey.h:47
float offset() const
Definition: seisposkey.h:44
Positioning in a seismic survey: inline/crossline or lineNr/trcNr.
Definition: binid.h:28
bool isUndef() const
Definition: seisposkey.h:37
BinID & binID()
Definition: seisposkey.h:61
Definition: seistype.h:31
static PosKey undef()
Definition: seisposkey.h:66
float offset_
Definition: seisposkey.h:71
GeomType geomTypeOf(const char *)
bool hasOffset(float) const
Definition: seisposkey.h:84
void set(const BinID &bid, float offs)
Definition: seisposkey.h:52
int xLine() const
Definition: seisposkey.h:43
int & trcNr()
Definition: seisposkey.h:60
void setUndef()
Definition: seisposkey.h:38
bool equalOffset(float offs1, float offs2)
Undef not supported.
Definition: seiscommon.h:26
bool isPS() const
Definition: seisposkey.h:34
void setBinID(const BinID &bid)
Definition: seisposkey.h:48
PosKey(const BinID &bid, float offs=mUdf(float))
Definition: seisposkey.h:25

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