OpendTect  6.3
posidxpairvalset.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: July 2004/Oct 2013/Mar 2016
9 ________________________________________________________________________
10 
11 -*/
12 
13 #include "generalmod.h"
14 #include "posidxpairdataset.h"
15 
16 
17 namespace Pos
18 {
19 template <class IPT,class FT> class ValueIdxPair;
20 template <class IPT,class FT> class IdxPairValues;
21 
22 
36 {
37 public:
38 
45 
46  IdxPairValueSet(int nr_vals,bool allow_dupl_idxpairs);
47  virtual ~IdxPairValueSet() {}
48  IdxPairValueSet& operator =(const IdxPairValueSet&);
49 
50  inline void allowDuplicateIdxPairs( bool yn )
51  { return data_.allowDuplicateIdxPairs(yn); }
53  { return data_.allowsDuplicateIdxPairs(); }
54  void setEmpty()
55  { data_.setEmpty(); }
56  bool append( const IdxPairValueSet& oth )
57  { return data_.append( oth.data_ ); }
58  void remove( const IdxPairValueSet& oth )
59  { data_.remove( oth.data_ ); }
60  void copyStructureFrom(const IdxPairValueSet&);
62 
63  inline SPos find( const IdxPair& ip ) const
64  { return data_.find( ip ); }
65  SPos findOccurrence( const IdxPair& ip, int occ=0 ) const
66  { return data_.findOccurrence( ip, occ ); }
67  bool next( SPos& spos, bool skip_dupl_idxpairs=false ) const
68  { return data_.next( spos, skip_dupl_idxpairs ); }
69  bool prev( SPos& spos, bool skip_dupl_idxpairs=false ) const
70  { return data_.prev( spos, skip_dupl_idxpairs ); }
71  bool isValid( const IdxPair& spos ) const
72  { return data_.isValid( spos ); }
73 
74  void get(const SPos&,float* v=0,int mxnrvals=-1) const;
75  void get(const SPos&,IdxPair&,float* v=0,int mxnrv=-1) const;
76  IdxPair getIdxPair( const SPos& spos ) const
77  { return data_.getIdxPair( spos ); }
78  SPos getPos(GlobIdxType global_idx) const
79  { return data_.getPos( global_idx ); }
80  SPos add(const IdxPair&,const float* vs=0);
82  SPos add(const DataRow&);
84  void set(SPos,const float* vs=0);
85 
89  // more get, set and add: see below
90 
91  inline int nrVals() const
92  { return nrvals_; }
93  inline IdxType nrFirst() const
94  { return data_.nrFirst(); }
95  inline IdxType nrSecond( IdxType firstidx ) const
96  { return data_.nrSecond(firstidx); }
97  inline bool isEmpty() const
98  { return data_.isEmpty(); }
99  inline bool includes( const IdxPair& ip ) const
100  { return data_.includes( ip ); }
101  inline bool hasFirst( IdxType inl ) const
102  { return data_.hasFirst( inl ); }
103  inline bool hasSecond( IdxType crl ) const
104  { return data_.hasSecond( crl ); }
105  inline IdxPair firstIdxPair() const
106  { return data_.firstIdxPair(); }
107  inline GlobIdxType totalSize() const
108  { return data_.totalSize(); }
110  { return data_.firstRange(); }
111  inline Interval<IdxType> secondRange( IdxType frstidx=-1 ) const
112  { return data_.secondRange( frstidx ); }
113  Interval<float> valRange(int valnr) const;
114 
115  bool insertVal(int); //<! Will add a 'column'
116  bool setNrVals(int);
117  inline bool hasDuplicateIdxPairs() const
118  { return data_.hasDuplicateIdxPairs(); }
119  inline ArrIdxType nrDuplicateIdxPairs() const
120  { return data_.nrDuplicateIdxPairs(); }
122  { data_.removeDuplicateIdxPairs(); }
123  inline void randomSubselect( od_int64 maxsz )
124  { data_.randomSubselect( maxsz ); }
125 
126  void extend(const IdxPairDelta& stepout,const IdxPairStep&,
127  bool avoiddups=true);
128  void add(const PosInfo::CubeData&);
129  inline void remove( const SPos& spos )
130  { data_.remove( spos ); }
131  inline void remove( const TypeSet<SPos>& torem )
132  { data_.remove( torem ); }
133  void removeRange(int valnr,const Interval<float>&,
134  bool inside=true);
135  inline void remove( const TrcKeySampling& hrg, bool inside )
136  { data_.remove( hrg, inside ); }
137  void removeVal(int);
138 
139  // Convenience stuff
140  SPos add(const PairVal&);
141  SPos add(const IdxPair&,float);
142  SPos add(const IdxPair&,double);
143  SPos add(const IdxPair&,float,float);
144  SPos add(const IdxPair&,const TypeSet<float>&);
145  void get(const SPos&,DataRow&) const;
146  void get(const SPos&,PairVal&) const;
147  void get(const SPos&,IdxPair&,float&) const;
148  void get(const SPos&,IdxPair&,float&,float&) const;
149  void get(const SPos&,IdxPair&,TypeSet<float>&,
150  int mxnrvals=-1) const;
151  void get(const SPos&,TypeSet<float>&,int maxnrvals=-1) const;
152  void set(const SPos&,float);
153  void set(const SPos&,float,float);
154  void set(const SPos&,const TypeSet<float>&);
155  void getColumn(int valnr,TypeSet<float>&,bool incudf) const;
156 
157  // Slow! Can still come in handly for small sets
158  void fillPar(IOPar&,const char* key) const;
159  void usePar(const IOPar&,const char* key);
160 
161  // Fast
162  bool getFrom(od_istream&,Pos::GeomID=mUdf(Pos::GeomID));
164  bool putTo(od_ostream&) const;
165 
166  inline ArrIdxType nrPos( ArrIdxType lineidx ) const
167  { return data_.nrPos(lineidx); }
168  float* getVals(const SPos&);
170  const float* getVals(const SPos&) const;
172  float getVal(const SPos& pos,int valnr) const;
174  bool haveDataRow(const DataRow&) const;
175 
176  // aliases
177  inline ArrIdxType nrInls() const { return nrFirst(); }
178  inline ArrIdxType nrCrls( IdxType inl ) const { return nrSecond(inl); }
179  inline ArrIdxType nrRows() const { return nrFirst(); }
180  inline ArrIdxType nrCols( IdxType row ) const { return nrSecond(row); }
181  bool hasInl( IdxType inl ) const { return hasFirst(inl); }
182  bool hasCrl( IdxType crl ) const { return hasSecond(crl); }
183  inline bool hasRow( IdxType row ) const { return hasFirst(row); }
184  inline bool hasCol( IdxType col ) const { return hasSecond(col); }
185  Interval<IdxType> inlRange() const { return firstRange(); }
186  Interval<IdxType> rowRange() const { return firstRange(); }
187  Interval<IdxType> crlRange( IdxType inl=-1 ) const
188  { return secondRange(inl); }
189  Interval<IdxType> colRange( IdxType row=-1 ) const
190  { return secondRange(row); }
191 
192 protected:
193 
194  const int nrvals_;
196 
197  inline float* gtVals( const SPos& spos )
198  { return (float*)data_.getObj( spos ); }
199  inline const float* gtVals( const SPos& spos ) const
200  { return (const float*)data_.getObj( spos ); }
201 
202  friend class DataPointSet;
203  friend class PosVecDataSet;
204 
205 };
206 
207 
208 } // namespace Pos
#define mExpClass(module)
Definition: commondefs.h:157
Interval< IdxType > firstRange() const
Definition: posidxpairvalset.h:109
IdxPair firstIdxPair() const
Definition: posidxpairvalset.h:105
ArrIdxType nrInls() const
Definition: posidxpairvalset.h:177
OD class for stream write common access to the user log file, or std::cout in batch progs...
Definition: od_ostream.h:25
Interval< IdxType > secondRange(IdxType frstidx=-1) const
Definition: posidxpairvalset.h:111
bool isValid(const IdxPair &spos) const
Definition: posidxpairvalset.h:71
const float * gtVals(const SPos &spos) const
Definition: posidxpairvalset.h:199
Set of data points with group selection.
Definition: datapointset.h:47
ArrIdxType nrCols(IdxType row) const
Definition: posidxpairvalset.h:180
IdxPairDataSet data_
Definition: posidxpairvalset.h:195
IdxType nrSecond(IdxType firstidx) const
Definition: posidxpairvalset.h:95
IdxPair with a value.
Definition: posidxpairvalue.h:27
void usePar(const IOPar &iop, ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:200
bool hasCol(IdxType col) const
Definition: posidxpairvalset.h:184
#define od_int64
Definition: plftypes.h:34
IdxPair with position indices; base class for BinID et al.
Definition: posidxpair.h:27
IdxPairDataSet::SPos SPos
Definition: posidxpairvalset.h:42
bool includes(const IdxPair &ip) const
Definition: posidxpairvalset.h:99
ValueIdxPair< IdxPair, float > PairVal
Definition: posidxpairvalset.h:40
TypeSet< IdxType >::size_type ArrIdxType
Definition: posidxpairdataset.h:65
IdxPair::IdxType IdxType
Definition: posidxpairvalset.h:39
IdxType nrFirst() const
Definition: posidxpairvalset.h:93
ArrIdxType nrRows() const
Definition: posidxpairvalset.h:179
IdxPair with 0-N values.
Definition: posidxpairvalue.h:21
bool hasDuplicateIdxPairs() const
Definition: posidxpairvalset.h:117
ArrIdxType nrDuplicateIdxPairs() const
Definition: posidxpairvalset.h:119
OD class for stream read.
Definition: od_istream.h:23
const void * getObj(SPos) const
bool prev(SPos &spos, bool skip_dupl_idxpairs=false) const
Definition: posidxpairvalset.h:69
void allowDuplicateIdxPairs(bool yn)
Definition: posidxpairvalset.h:50
A sorted set of IdxPairs and associated data buffer.
Definition: posidxpairdataset.h:60
IdxPair getIdxPair(const SPos &spos) const
Definition: posidxpairvalset.h:76
IdxPairDataSet::GlobIdxType GlobIdxType
Definition: posidxpairvalset.h:44
Interval< IdxType > inlRange() const
Definition: posidxpairvalset.h:185
virtual ~IdxPairValueSet()
Definition: posidxpairvalset.h:47
uses an IdxPairDataSet to hold arrays of floats
Definition: posidxpairvalset.h:35
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:53
Horizontal sampling (inline and crossline range and steps).
Definition: trckeysampling.h:25
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:270
void setEmpty()
Definition: posidxpairvalset.h:54
Position.
Definition: commontypes.h:38
bool hasInl(IdxType inl) const
Definition: posidxpairvalset.h:181
od_int64 GlobIdxType
Definition: posidxpairdataset.h:67
void removeDuplicateIdxPairs()
Definition: posidxpairvalset.h:121
IdxPairValues< IdxPair, float > DataRow
Definition: posidxpairvalset.h:41
bool allowsDuplicateIdxPairs() const
Definition: posidxpairvalset.h:52
bool hasRow(IdxType row) const
Definition: posidxpairvalset.h:183
void removeRange(ODSET &inst, size_type start, size_type stop)
Removes a range from the set.
Definition: odset.h:55
void fillPar(IOPar &iop, const ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:187
Interval< IdxType > crlRange(IdxType inl=-1) const
Definition: posidxpairvalset.h:187
Index_Type GeomID
Definition: commontypes.h:48
bool hasCrl(IdxType crl) const
Definition: posidxpairvalset.h:182
bool isEmpty() const
Definition: posidxpairvalset.h:97
ArrIdxType nrCrls(IdxType inl) const
Definition: posidxpairvalset.h:178
Index_Type IdxType
Definition: idxpair.h:32
GlobIdxType totalSize() const
Definition: posidxpairvalset.h:107
SPos findOccurrence(const IdxPair &ip, int occ=0) const
Definition: posidxpairvalset.h:65
IdxPairDataSet::ArrIdxType ArrIdxType
Definition: posidxpairvalset.h:43
void randomSubselect(od_int64 maxsz)
Definition: posidxpairvalset.h:123
SPos find(const IdxPair &ip) const
Definition: posidxpairvalset.h:63
const int nrvals_
Definition: posidxpairvalset.h:194
float * gtVals(const SPos &spos)
Definition: posidxpairvalset.h:197
SPos getPos(GlobIdxType global_idx) const
Definition: posidxpairvalset.h:78
bool append(const IdxPairValueSet &oth)
Definition: posidxpairvalset.h:56
bool hasSecond(IdxType crl) const
Definition: posidxpairvalset.h:103
Set Position: position in IdxPairDataSet.
Definition: posidxpairdataset.h:75
bool next(SPos &spos, bool skip_dupl_idxpairs=false) const
Definition: posidxpairvalset.h:67
Position info for an entire 3D cube. The LineData&#39;s are not sorted.
Definition: posinfo.h:96
Data set consisting of data vectors.
Definition: posvecdataset.h:29
int nrVals() const
Definition: posidxpairvalset.h:91
Interval< IdxType > colRange(IdxType row=-1) const
Definition: posidxpairvalset.h:189
ArrIdxType nrPos(ArrIdxType lineidx) const
Definition: posidxpairvalset.h:166
Interval< IdxType > rowRange() const
Definition: posidxpairvalset.h:186
bool hasFirst(IdxType inl) const
Definition: posidxpairvalset.h:101

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