OpendTect-6_4  6.4
trckeysampling.h
Go to the documentation of this file.
1 #ifndef trckeysampling_h
2 #define trckeysampling_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Bert
9  Date: Feb 2008
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "basicmod.h"
16 #include "binid.h"
17 #include "ranges.h"
18 #include "typeset.h"
19 #include "trckey.h"
20 
22 
28 {
29 public:
30 
31  TrcKeySampling();
32  TrcKeySampling(const TrcKeySampling&);
33  TrcKeySampling(Pos::GeomID);
34 
35  bool is2D() const { return TrcKey::is2D(survid_); }
36  Pos::GeomID getGeomID() const;
37 
38  TrcKeySampling& set(const Interval<int>& linerg,
39  const Interval<int>& trcnrrg);
41  void get(Interval<int>& linerg,Interval<int>& trcnrrg) const;
43  TrcKeySampling getLineChunk(int totalchunks,int chunknr) const;
45 
46  StepInterval<int> lineRange() const;
47  StepInterval<int> trcRange() const;
48  float lineDistance() const;
51  float trcDistance() const;
54  void setLineRange(const Interval<int>&);
55  void setTrcRange(const Interval<int>&);
56 
57  bool includes(const TrcKeySampling&,
58  bool ignoresteps=false) const;
59  bool includes(const TrcKey&) const;
60  bool includes(const TrcKey&,bool ignoresteps) const;
61  bool lineOK(Pos::LineID) const;
62  bool trcOK(Pos::TraceID) const;
63 
64  bool lineOK(Pos::LineID,bool ignoresteps) const;
65  bool trcOK(Pos::TraceID,bool ignoresteps) const;
66 
67  void include(const TrcKey&);
68  void includeLine(Pos::LineID);
69  void includeTrc(Pos::TraceID);
70  void include(const TrcKeySampling&, bool ignoresteps=false );
71  bool isDefined() const;
72  void limitTo(const TrcKeySampling&,bool ignoresteps=false);
73  void limitToWithUdf(const TrcKeySampling&);
76  void expand(int nrlines,int nrtrcs);
77 
78  int lineIdx(Pos::LineID) const;
79  int trcIdx(Pos::TraceID) const;
80  inline Pos::LineID lineID(int) const;
81  inline Pos::TraceID traceID(int) const;
82 
83  od_int64 globalIdx(const TrcKey&) const;
84  od_int64 globalIdx(const BinID&) const;
85  BinID atIndex(int i0,int i1) const;
86  BinID atIndex(od_int64 globalidx) const;
87  TrcKey trcKeyAt(int i0,int i1) const;
88  TrcKey trcKeyAt(od_int64 globalidx) const;
89  TrcKey toTrcKey(const Coord&,float* distance=0) const;
90  Coord toCoord(const BinID&) const;
91  TrcKey center() const;
92  int nrLines() const;
93  int nrTrcs() const;
94  od_int64 totalNr() const;
95  bool isEmpty() const;
96  void neighbors(od_int64 globalidx,TypeSet<od_int64>&) const;
97  void neighbors(const TrcKey&,TypeSet<TrcKey>&) const;
98 
99  void init(bool settoSI=true);
101  bool init(Pos::GeomID);
102 
103  void set2DDef();
105  void normalise();
107  void getRandomSet(int nr,TypeSet<TrcKey>&) const;
108 
109  bool getInterSection(const TrcKeySampling&,
110  TrcKeySampling&) const;
112 
113  BinID getNearest(const BinID&) const;
114  TrcKey getNearest(const TrcKey&) const;
117  void snapToSurvey();
121  bool operator==(const TrcKeySampling&) const;
122  bool operator!=(const TrcKeySampling&) const;
123  TrcKeySampling& operator=(const TrcKeySampling&);
124 
125  bool usePar(const IOPar&);
126  void fillPar(IOPar&) const;
127  static void removeInfo(IOPar&);
128  void toString(BufferString&) const;
129 
134 
135  //Legacy. Will be removed
136  TrcKeySampling(bool settoSI);
137  StepInterval<int> inlRange() const { return lineRange(); }
138  StepInterval<int> crlRange() const { return trcRange(); }
139  void setInlRange(const Interval<int>& rg) {setLineRange(rg);}
140  void setCrlRange(const Interval<int>& rg) {setTrcRange(rg);}
141 
142  int nrInl() const { return nrLines(); }
143  int nrCrl() const { return nrTrcs(); }
144 
145  int inlIdx( Pos::LineID lid ) const {return lineIdx(lid);}
146  int crlIdx( Pos::TraceID tid ) const { return trcIdx(tid); }
147  inline void include( const BinID& bid )
148  { includeLine(bid.inl()); includeTrc(bid.crl()); }
149  void includeInl( int inl ) { includeLine(inl); }
150  void includeCrl( int crl ) { includeTrc(crl); }
151  inline bool includes( const BinID& bid ) const
152  { return lineOK(bid.inl()) && trcOK(bid.crl()); }
153  inline bool inlOK( int inl ) const { return lineOK(inl); }
154  inline bool crlOK( int crl ) const { return trcOK(crl); }
155 
156  inline bool includes(const BinID& bid, bool ignoresteps) const
157  { return lineOK(bid.inl(), ignoresteps ) &&
158  trcOK(bid.crl(), ignoresteps ); }
159 
163 
164  void shrinkTo(const TrcKeySampling& innertks);
165  void growTo(const TrcKeySampling& outertks);
166 private:
167  bool doLimitTo(StepInterval<int>&, const StepInterval<int>&,
168  const bool ignoresteps,
169  const bool nostephandling);
170 };
171 
172 
174 {
175 public:
176 
177  void isOK() const;
178  void add(Pos::GeomID);
179  bool isPresent(Pos::GeomID);
180 };
181 
182 
183 
184 
190 {
191 public:
192  TrcKeySamplingIterator() : tks_( true ) { reset(); }
194  { setSampling( hs ); }
195 
196  void setSampling(const TrcKeySampling&);
197 
198  void reset();
199  void setNextPos(const TrcKey& trk) { curpos_ = tks_.globalIdx(trk); }
200  bool next(TrcKey&) const;
201  bool next(BinID&) const;
202 
203  od_int64 curIdx() const { return curpos_; }
204  TrcKey curTrcKey() const { return tks_.atIndex( curIdx() );}
205 
206 protected:
207 
211 };
212 
213 
214 
215 
218 
219 
220 inline int TrcKeySampling::lineIdx( Pos::LineID line ) const
221 {
222  return step_.lineNr()
223  ? (line-start_.lineNr()) / step_.lineNr()
224  : (line==start_.lineNr() ? 0 : -1);
225 }
226 
227 
228 inline int TrcKeySampling::trcIdx( Pos::TraceID trcid ) const
229 {
230  return step_.trcNr()
231  ? (trcid-start_.trcNr()) / step_.trcNr()
232  : (trcid==start_.trcNr() ? 0 : -1);
233 }
234 
235 
236 inline Pos::LineID TrcKeySampling::lineID( int lidx ) const
237 {
238  return start_.lineNr() + step_.lineNr() * lidx;
239 }
240 
241 
242 inline Pos::TraceID TrcKeySampling::traceID( int tidx ) const
243 {
244  return start_.trcNr() + step_.trcNr() * tidx;
245 }
246 
247 
248 #endif
#define mExpClass(module)
Definition: commondefs.h:160
Index_Type LineID
Definition: commontypes.h:50
int64_t totalnr_
Definition: trckeysampling.h:209
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:53
TrcKeySampling HorSampling
Definition: trckeysampling.h:216
bool includes(const BinID &bid) const
Definition: trckeysampling.h:151
void setCrlRange(const Interval< int > &rg)
Definition: trckeysampling.h:140
Pos::LineID lineID(int) const
Definition: trckeysampling.h:236
Index_Type TraceID
Definition: commontypes.h:51
int inlIdx(Pos::LineID lid) const
Definition: trckeysampling.h:145
void setNextPos(const TrcKey &trk)
Definition: trckeysampling.h:199
bool crlOK(int crl) const
Definition: trckeysampling.h:154
void usePar(const IOPar &iop, ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:188
#define od_int64
Definition: plftypes.h:36
TrcKeySamplingIterator HorSamplingIterator
Definition: trckeysampling.h:217
Pos::SurvID survid_
Definition: trckeysampling.h:130
bool init()
IdxType & inl()
Definition: posidxpair.h:43
bool inlOK(int inl) const
Definition: trckeysampling.h:153
int64_t curIdx() const
Definition: trckeysampling.h:203
int nrInl() const
Definition: trckeysampling.h:142
TypeSet< TrcKey > TrcKeyPath
Definition: trckeysampling.h:21
Finds next BinID in TrcKeySampling; initializes to first position.
Definition: trckeysampling.h:189
BinID & step
Definition: trckeysampling.h:162
Pos::TraceID traceID(int) const
Definition: trckeysampling.h:242
A cartesian coordinate in 2D space.
Definition: coord.h:25
IdxType & trcNr()
Definition: posidxpair.h:49
void includeCrl(int crl)
Definition: trckeysampling.h:150
int lineIdx(Pos::LineID) const
Definition: trckeysampling.h:220
BinID step_
Definition: trckeysampling.h:133
Threads::Atomic< int64_t > curpos_
Definition: trckeysampling.h:210
BinID & stop
Definition: trckeysampling.h:161
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
Index_Type SurvID
Definition: commontypes.h:49
Horizontal sampling (inline and crossline range and steps).
Definition: trckeysampling.h:27
int trcIdx(Pos::TraceID) const
Definition: trckeysampling.h:228
int crlIdx(Pos::TraceID tid) const
Definition: trckeysampling.h:146
bool operator!=(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:62
void fillPar(IOPar &iop, const ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:175
void include(const BinID &bid)
Definition: trckeysampling.h:147
StepInterval< int > crlRange() const
Definition: trckeysampling.h:138
Index_Type GeomID
Definition: commontypes.h:52
IdxType & crl()
Definition: posidxpair.h:48
BinID & start
Definition: trckeysampling.h:160
#define mDeprecated
Definition: plfdefs.h:233
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
IdxType & lineNr()
Definition: posidxpair.h:44
BinID stop_
Definition: trckeysampling.h:132
Positioning in a seismic survey: inline/crossline or lineNr/trcNr.
Definition: binid.h:30
bool includes(const BinID &bid, bool ignoresteps) const
Definition: trckeysampling.h:156
TrcKeySamplingIterator()
Definition: trckeysampling.h:192
TrcKeySamplingIterator(const TrcKeySampling &hs)
Definition: trckeysampling.h:193
Definition: atomic.h:33
bool is2D() const
Definition: trckey.h:44
Represents a unique trace position in one of the surveys that OpendTect is managing.
Definition: trckey.h:28
bool is2D() const
Definition: trckeysampling.h:35
int nrCrl() const
Definition: trckeysampling.h:143
void includeInl(int inl)
Definition: trckeysampling.h:149
bool isEmpty(const NLAModel *mdl)
TrcKeySampling tks_
Definition: trckeysampling.h:208
StepInterval< int > inlRange() const
Definition: trckeysampling.h:137
TrcKey curTrcKey() const
Definition: trckeysampling.h:204
Export_Basic const char * toString(ViewStyle)
Definition: trckeysampling.h:173
void setInlRange(const Interval< int > &rg)
Definition: trckeysampling.h:139
BinID start_
Definition: trckeysampling.h:131

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