OpendTect-6_4  6.4
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Pos::IdxPairValueSet Class Reference

A sorted set of IdxPairs and associated values. More...

Inheritance diagram for Pos::IdxPairValueSet:
[legend]

Classes

struct  SPos
 position in IdxPairValueSet; an iterator. More...
 

Public Types

typedef IdxPair::IdxType IdxType
 
typedef ValueIdxPair< IdxPair, float > PairVal
 
typedef IdxPairValues< IdxPair, float > DataRow
 

Public Member Functions

 IdxPairValueSet (int nr_vals, bool allow_duplicate_idxpairs)
 
 IdxPairValueSet (const IdxPairValueSet &)
 
virtual ~IdxPairValueSet ()
 
IdxPairValueSetoperator= (const IdxPairValueSet &)
 
void allowDuplicateIdxPairs (bool yn)
 
bool allowsDuplicateIdxPairs () const
 
void setEmpty ()
 
bool append (const IdxPairValueSet &)
 
void remove (const IdxPairValueSet &)
 
void copyStructureFrom (const IdxPairValueSet &)
 will also empty this set More...
 
SPos find (const IdxPair &ip) const
 
SPos findOccurrence (const IdxPair &, int occ=0) const
 
bool next (SPos &, bool skip_duplicate_idxpairs=false) const
 
bool prev (SPos &, bool skip_duplicate_idxpairs=false) const
 
bool isValid (const IdxPair &) const
 
void get (const SPos &, IdxPair &, float *v=0, int mxnrvals=-1) const
 
IdxPair getIdxPair (const SPos &) const
 
SPos getPos (od_int64 global_idx) const
 Slow. And no check on idx in range. More...
 
SPos add (const IdxPair &, const float *vs=0)
 Either pass sufficient data or pass null. More...
 
SPos add (const DataRow &)
 Wrong-sized will be handled correctly. More...
 
void set (SPos, const float *vs=0)
 
int nrVals () const
 
int nrFirst () const
 
int nrSecond (IdxType firstidx) const
 
bool isEmpty () const
 
bool includes (const IdxPair &ip) const
 
bool hasFirst (IdxType) const
 
bool hasSecond (IdxType) const
 
IdxPair firstIdxPair () const
 if empty, returns IdxPair::udf() More...
 
od_int64 totalSize () const
 
Interval< IdxTypefirstRange () const
 
Interval< IdxTypesecondRange (IdxType firsidx=-1) const
 
Interval< float > valRange (int valnr) const
 
void remove (const SPos &)
 afterwards, SPos may be invalid More...
 
void remove (const TypeSet< SPos > &)
 
void removeVal (int)
 Will remove entire 'column'. More...
 
bool insertVal (int)
 
bool setNrVals (int, bool kp_data=true)
 
int nrDuplicateIdxPairs () const
 
void sortDuplicateIdxPairs (int value_nr, bool ascending=true)
 
void removeDuplicateIdxPairs ()
 
void randomSubselect (od_int64 maxnr)
 
void extend (const IdxPairDelta &stepout, const IdxPairStep &)
 Adds only IdxPair postions not yet in set. More...
 
void removeRange (int valnr, const Interval< float > &, bool inside=true)
 
void remove (const TrcKeySampling &hrg, bool inside)
 
SPos add (const PairVal &)
 
SPos add (const IdxPair &, float)
 
SPos add (const IdxPair &, double)
 
SPos add (const IdxPair &, float, float)
 
SPos add (const IdxPair &, const TypeSet< float > &)
 
void add (const PosInfo::CubeData &)
 
void get (const SPos &, DataRow &) const
 
void get (const SPos &, PairVal &) const
 
void get (const SPos &, IdxPair &, float &) const
 
void get (const SPos &, IdxPair &, float &, float &) const
 
void get (const SPos &, IdxPair &, TypeSet< float > &, int maxnrvals=-1) const
 max == -1 => all More...
 
void set (const SPos &, float)
 
void set (const SPos &, float, float)
 
void set (const SPos &, const TypeSet< float > &)
 
void getColumn (int valnr, TypeSet< float > &, bool incudf) const
 
void fillPar (IOPar &, const char *key) const
 
void usePar (const IOPar &, const char *key)
 
bool getFrom (od_istream &, Pos::GeomID=mUdf(Pos::GeomID))
 detects/converts coords if geomid passed More...
 
bool putTo (od_ostream &) const
 
bool includes (const DataRow &) const
 
int nrPos (int lineidx) const
 nth line in the set More...
 
float * getVals (const SPos &pos)
 Direct access to value arrays. More...
 
const float * getVals (const SPos &pos) const
 Direct access to value arrays. More...
 
float getVal (const SPos &pos, int valnr) const
 < Direct access to value arrays. More...
 
bool hasDuplicateIdxPairs () const
 
bool haveDataRow (const DataRow &) const
 
int nrInls () const
 
int nrCrls (IdxType inl) const
 
int nrRows () const
 
int nrCols (IdxType row) const
 
bool hasInl (IdxType inl) const
 
bool hasCrl (IdxType crl) const
 
bool hasRow (IdxType row) const
 
bool hasCol (IdxType col) const
 
Interval< int > inlRange () const
 
Interval< int > rowRange () const
 
Interval< int > crlRange (IdxType inl=-1) const
 
Interval< int > colRange (IdxType row=-1) const
 

Protected Member Functions

void addNew (SPos &, IdxType, const float *)
 
void sortPart (TypeSet< IdxType > &, TypeSet< float > &, int, int, int, bool)
 
void removeLine (int idx)
 
IdxType getFrst (const SPos &pos) const
 
IdxType getScnd (const SPos &pos) const
 
TypeSet< IdxType > & getScndSet (const SPos &pos)
 
const TypeSet< IdxType > & getScndSet (const SPos &pos) const
 
TypeSet< float > & getValSet (const SPos &pos)
 
const TypeSet< float > & getValSet (const SPos &pos) const
 
TypeSet< IdxType > & getScndSet (int idx)
 
const TypeSet< IdxType > & getScndSet (int idx) const
 
TypeSet< float > & getValSet (int idx)
 
const TypeSet< float > & getValSet (int idx) const
 

Protected Attributes

const int nrvals_
 
TypeSet< IdxTypefrsts_
 
ObjectSet< TypeSet< IdxType > > scndsets_
 
ObjectSet< TypeSet< float > > valsets_
 
bool allowdup_
 

Friends

class DataPointSet
 
class PosVecDataSet
 

Detailed Description

A sorted set of IdxPairs and associated values.

The set is sorted on both first and second key (inl()/row()/lineNr() and crl()/col()/traceNr()). This has a cost when creating the set, and it will be slower than a normal TypeSet for small sets. Further, the order in which you add positions will not be preserved.

Luckily there are also advantages. It is much faster for searching when the set is large. When you have a block of N rows x N columns, the search time will be O( 2 log2(N) ) instead of O( N^2 / 2 ). Thus for 1000x1000 instead of 500000 you need 20 comparisons (probably a few more but not a lot more).

The iteration through the set should be done using the SPos iterator class. All positioning is already done with SPos, but you can in theory still use

const od_int64 sz = totalSize();
for ( od_int64 idx=0; idx<sz; idx++ )
{
Pos::IdxPairValueSet::SPos pos = set.getPos( idx );
// etc.
}

but that will be very wasteful.

When you construct a IdxPairValueSet, you must provide the number of values (which can be changed later) and whether duplicate IdxPairs are allowed. In the set, new uninitialized values will be set to mUdf(float).

if you also want the values sorted (for the same IdxPair) use sortDuplicateIdxPairs().

Note: if one of the values is Z, make it the first value. Not that this is enforced by the set, but it will be assumed sooner or later.

Member Typedef Documentation

Constructor & Destructor Documentation

Pos::IdxPairValueSet::IdxPairValueSet ( int  nr_vals,
bool  allow_duplicate_idxpairs 
)
Pos::IdxPairValueSet::IdxPairValueSet ( const IdxPairValueSet )
virtual Pos::IdxPairValueSet::~IdxPairValueSet ( )
virtual

Member Function Documentation

SPos Pos::IdxPairValueSet::add ( const IdxPair ,
const float *  vs = 0 
)

Either pass sufficient data or pass null.

SPos Pos::IdxPairValueSet::add ( const DataRow )

Wrong-sized will be handled correctly.

SPos Pos::IdxPairValueSet::add ( const PairVal )
SPos Pos::IdxPairValueSet::add ( const IdxPair ,
float   
)
SPos Pos::IdxPairValueSet::add ( const IdxPair ,
double   
)
SPos Pos::IdxPairValueSet::add ( const IdxPair ,
float  ,
float   
)
SPos Pos::IdxPairValueSet::add ( const IdxPair ,
const TypeSet< float > &   
)
void Pos::IdxPairValueSet::add ( const PosInfo::CubeData )
void Pos::IdxPairValueSet::addNew ( SPos ,
IdxType  ,
const float *   
)
protected
void Pos::IdxPairValueSet::allowDuplicateIdxPairs ( bool  yn)
inline
bool Pos::IdxPairValueSet::allowsDuplicateIdxPairs ( ) const
inline
bool Pos::IdxPairValueSet::append ( const IdxPairValueSet )
Interval<int> Pos::IdxPairValueSet::colRange ( IdxType  row = -1) const
inline
void Pos::IdxPairValueSet::copyStructureFrom ( const IdxPairValueSet )

will also empty this set

Interval<int> Pos::IdxPairValueSet::crlRange ( IdxType  inl = -1) const
inline
void Pos::IdxPairValueSet::extend ( const IdxPairDelta stepout,
const IdxPairStep  
)

Adds only IdxPair postions not yet in set.

void Pos::IdxPairValueSet::fillPar ( IOPar ,
const char *  key 
) const
SPos Pos::IdxPairValueSet::find ( const IdxPair ip) const
inline
SPos Pos::IdxPairValueSet::findOccurrence ( const IdxPair ,
int  occ = 0 
) const

not found: j < 0. still, i can be >= 0 , then the inline is present Then, next(pos) will return the first on that inl.

IdxPair Pos::IdxPairValueSet::firstIdxPair ( ) const

if empty, returns IdxPair::udf()

Interval<IdxType> Pos::IdxPairValueSet::firstRange ( ) const
void Pos::IdxPairValueSet::get ( const SPos ,
IdxPair ,
float *  v = 0,
int  mxnrvals = -1 
) const
void Pos::IdxPairValueSet::get ( const SPos ,
DataRow  
) const
void Pos::IdxPairValueSet::get ( const SPos ,
PairVal  
) const
void Pos::IdxPairValueSet::get ( const SPos ,
IdxPair ,
float &   
) const
void Pos::IdxPairValueSet::get ( const SPos ,
IdxPair ,
float &  ,
float &   
) const
void Pos::IdxPairValueSet::get ( const SPos ,
IdxPair ,
TypeSet< float > &  ,
int  maxnrvals = -1 
) const

max == -1 => all

void Pos::IdxPairValueSet::getColumn ( int  valnr,
TypeSet< float > &  ,
bool  incudf 
) const
bool Pos::IdxPairValueSet::getFrom ( od_istream ,
Pos::GeomID  = mUdf(Pos::GeomID) 
)

detects/converts coords if geomid passed

IdxType Pos::IdxPairValueSet::getFrst ( const SPos pos) const
inlineprotected
IdxPair Pos::IdxPairValueSet::getIdxPair ( const SPos ) const
SPos Pos::IdxPairValueSet::getPos ( od_int64  global_idx) const

Slow. And no check on idx in range.

IdxType Pos::IdxPairValueSet::getScnd ( const SPos pos) const
inlineprotected
TypeSet<IdxType>& Pos::IdxPairValueSet::getScndSet ( const SPos pos)
inlineprotected
const TypeSet<IdxType>& Pos::IdxPairValueSet::getScndSet ( const SPos pos) const
inlineprotected
TypeSet<IdxType>& Pos::IdxPairValueSet::getScndSet ( int  idx)
inlineprotected
const TypeSet<IdxType>& Pos::IdxPairValueSet::getScndSet ( int  idx) const
inlineprotected
float Pos::IdxPairValueSet::getVal ( const SPos pos,
int  valnr 
) const
inline

< Direct access to value arrays.

float* Pos::IdxPairValueSet::getVals ( const SPos pos)
inline

Direct access to value arrays.

const float* Pos::IdxPairValueSet::getVals ( const SPos pos) const
inline

Direct access to value arrays.

TypeSet<float>& Pos::IdxPairValueSet::getValSet ( const SPos pos)
inlineprotected
const TypeSet<float>& Pos::IdxPairValueSet::getValSet ( const SPos pos) const
inlineprotected
TypeSet<float>& Pos::IdxPairValueSet::getValSet ( int  idx)
inlineprotected
const TypeSet<float>& Pos::IdxPairValueSet::getValSet ( int  idx) const
inlineprotected
bool Pos::IdxPairValueSet::hasCol ( IdxType  col) const
inline
bool Pos::IdxPairValueSet::hasCrl ( IdxType  crl) const
inline
bool Pos::IdxPairValueSet::hasDuplicateIdxPairs ( ) const
bool Pos::IdxPairValueSet::hasFirst ( IdxType  ) const
bool Pos::IdxPairValueSet::hasInl ( IdxType  inl) const
inline
bool Pos::IdxPairValueSet::hasRow ( IdxType  row) const
inline
bool Pos::IdxPairValueSet::hasSecond ( IdxType  ) const
bool Pos::IdxPairValueSet::haveDataRow ( const DataRow ) const
bool Pos::IdxPairValueSet::includes ( const IdxPair ip) const
inline
bool Pos::IdxPairValueSet::includes ( const DataRow ) const
Interval<int> Pos::IdxPairValueSet::inlRange ( ) const
inline
bool Pos::IdxPairValueSet::insertVal ( int  )
bool Pos::IdxPairValueSet::isEmpty ( ) const
inline
bool Pos::IdxPairValueSet::isValid ( const IdxPair ) const
bool Pos::IdxPairValueSet::next ( SPos ,
bool  skip_duplicate_idxpairs = false 
) const
int Pos::IdxPairValueSet::nrCols ( IdxType  row) const
inline
int Pos::IdxPairValueSet::nrCrls ( IdxType  inl) const
inline
int Pos::IdxPairValueSet::nrDuplicateIdxPairs ( ) const
int Pos::IdxPairValueSet::nrFirst ( ) const
inline
int Pos::IdxPairValueSet::nrInls ( ) const
inline
int Pos::IdxPairValueSet::nrPos ( int  lineidx) const

nth line in the set

int Pos::IdxPairValueSet::nrRows ( ) const
inline
int Pos::IdxPairValueSet::nrSecond ( IdxType  firstidx) const
int Pos::IdxPairValueSet::nrVals ( ) const
inline
IdxPairValueSet& Pos::IdxPairValueSet::operator= ( const IdxPairValueSet )
bool Pos::IdxPairValueSet::prev ( SPos ,
bool  skip_duplicate_idxpairs = false 
) const
bool Pos::IdxPairValueSet::putTo ( od_ostream ) const
void Pos::IdxPairValueSet::randomSubselect ( od_int64  maxnr)
void Pos::IdxPairValueSet::remove ( const IdxPairValueSet )
void Pos::IdxPairValueSet::remove ( const SPos )

afterwards, SPos may be invalid

void Pos::IdxPairValueSet::remove ( const TypeSet< SPos > &  )

You cannot remove while iterating Collect the to-be-removed and use this instead

void Pos::IdxPairValueSet::remove ( const TrcKeySampling hrg,
bool  inside 
)
void Pos::IdxPairValueSet::removeDuplicateIdxPairs ( )
void Pos::IdxPairValueSet::removeLine ( int  idx)
protected
void Pos::IdxPairValueSet::removeRange ( int  valnr,
const Interval< float > &  ,
bool  inside = true 
)

Removes vectors with value for column valnr in- or outside interval

void Pos::IdxPairValueSet::removeVal ( int  )

Will remove entire 'column'.

Interval<int> Pos::IdxPairValueSet::rowRange ( ) const
inline
Interval<IdxType> Pos::IdxPairValueSet::secondRange ( IdxType  firsidx = -1) const
void Pos::IdxPairValueSet::set ( SPos  ,
const float *  vs = 0 
)

null = set to undef no checks on data size (how could there be?) and also not whether SPos is actually in set! in doubt, use isValid(SPos) .

void Pos::IdxPairValueSet::set ( const SPos ,
float   
)
void Pos::IdxPairValueSet::set ( const SPos ,
float  ,
float   
)
void Pos::IdxPairValueSet::set ( const SPos ,
const TypeSet< float > &   
)
void Pos::IdxPairValueSet::setEmpty ( )
bool Pos::IdxPairValueSet::setNrVals ( int  ,
bool  kp_data = true 
)
void Pos::IdxPairValueSet::sortDuplicateIdxPairs ( int  value_nr,
bool  ascending = true 
)
void Pos::IdxPairValueSet::sortPart ( TypeSet< IdxType > &  ,
TypeSet< float > &  ,
int  ,
int  ,
int  ,
bool   
)
protected
od_int64 Pos::IdxPairValueSet::totalSize ( ) const
void Pos::IdxPairValueSet::usePar ( const IOPar ,
const char *  key 
)
Interval<float> Pos::IdxPairValueSet::valRange ( int  valnr) const

Friends And Related Function Documentation

friend class DataPointSet
friend
friend class PosVecDataSet
friend

Member Data Documentation

bool Pos::IdxPairValueSet::allowdup_
protected
TypeSet<IdxType> Pos::IdxPairValueSet::frsts_
protected
const int Pos::IdxPairValueSet::nrvals_
protected
ObjectSet< TypeSet<IdxType> > Pos::IdxPairValueSet::scndsets_
protected
ObjectSet< TypeSet<float> > Pos::IdxPairValueSet::valsets_
protected

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