OpendTect  6.6
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 IdxPairValues< IdxPair, float > DataRow
 
typedef IdxPair::IdxType IdxType
 
typedef ValueIdxPair< IdxPair, float > PairVal
 

Public Member Functions

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

Protected Member Functions

void addNew (SPos &, IdxType, const float *)
 
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< IdxType > & getScndSet (int idx)
 
const TypeSet< IdxType > & getScndSet (int idx) const
 
TypeSet< float > & getValSet (const SPos &pos)
 
const TypeSet< float > & getValSet (const SPos &pos) const
 
TypeSet< float > & getValSet (int idx)
 
const TypeSet< float > & getValSet (int idx) const
 
void removeLine (int idx)
 
void sortPart (TypeSet< IdxType > &, TypeSet< float > &, int, int, int, bool)
 
void updNearest (const IdxPair &, const SPos &, od_int64 &, SPos &) const
 

Protected Attributes

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

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.
}
void set(SPos, const float *vs=0)
od_int64 totalSize() const
position in IdxPairValueSet; an iterator.
Definition: posidxpairvalset.h:96

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

◆ DataRow

◆ IdxType

◆ PairVal

Constructor & Destructor Documentation

◆ IdxPairValueSet() [1/2]

Pos::IdxPairValueSet::IdxPairValueSet ( int  nr_vals,
bool  allow_duplicate_idxpairs 
)

◆ IdxPairValueSet() [2/2]

Pos::IdxPairValueSet::IdxPairValueSet ( const IdxPairValueSet )

◆ ~IdxPairValueSet()

virtual Pos::IdxPairValueSet::~IdxPairValueSet ( )
virtual

Member Function Documentation

◆ add() [1/8]

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

Wrong-sized will be handled correctly.

◆ add() [2/8]

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

Either pass sufficient data or pass null.

◆ add() [3/8]

SPos Pos::IdxPairValueSet::add ( const IdxPair ,
const TypeSet< float > &   
)

◆ add() [4/8]

SPos Pos::IdxPairValueSet::add ( const IdxPair ,
double   
)

◆ add() [5/8]

SPos Pos::IdxPairValueSet::add ( const IdxPair ,
float   
)

◆ add() [6/8]

SPos Pos::IdxPairValueSet::add ( const IdxPair ,
float  ,
float   
)

◆ add() [7/8]

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

◆ add() [8/8]

void Pos::IdxPairValueSet::add ( const PosInfo::CubeData )

◆ addNew()

void Pos::IdxPairValueSet::addNew ( SPos ,
IdxType  ,
const float *   
)
protected

◆ allowDuplicateIdxPairs()

void Pos::IdxPairValueSet::allowDuplicateIdxPairs ( bool  yn)
inline

◆ allowsDuplicateIdxPairs()

bool Pos::IdxPairValueSet::allowsDuplicateIdxPairs ( ) const
inline

◆ append()

bool Pos::IdxPairValueSet::append ( const IdxPairValueSet )

◆ colRange()

Interval<int> Pos::IdxPairValueSet::colRange ( IdxType  row = -1) const
inline

◆ copyStructureFrom()

void Pos::IdxPairValueSet::copyStructureFrom ( const IdxPairValueSet )

will also empty this set

◆ crlRange()

Interval<int> Pos::IdxPairValueSet::crlRange ( IdxType  inl = -1) const
inline

◆ extend()

void Pos::IdxPairValueSet::extend ( const IdxPairDelta stepout,
const IdxPairStep  
)

Adds only IdxPair postions not yet in set.

◆ fillPar()

void Pos::IdxPairValueSet::fillPar ( IOPar ,
const char *  key 
) const

◆ find()

SPos Pos::IdxPairValueSet::find ( const IdxPair ip) const
inline

◆ findNearest()

SPos Pos::IdxPairValueSet::findNearest ( const IdxPair ) const

◆ findNearestOnFirst()

SPos Pos::IdxPairValueSet::findNearestOnFirst ( int  frst,
int  scnd 
) const

◆ findOccurrence()

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.

◆ firstAtIdx()

int Pos::IdxPairValueSet::firstAtIdx ( int  firstidx) const

◆ firstIdx()

int Pos::IdxPairValueSet::firstIdx ( int  ) const

◆ firstIdxPair()

IdxPair Pos::IdxPairValueSet::firstIdxPair ( ) const

if empty, returns IdxPair::udf()

◆ firstRange()

Interval<IdxType> Pos::IdxPairValueSet::firstRange ( ) const

◆ get() [1/6]

void Pos::IdxPairValueSet::get ( const SPos ,
DataRow  
) const

◆ get() [2/6]

void Pos::IdxPairValueSet::get ( const SPos ,
IdxPair ,
float &   
) const

◆ get() [3/6]

void Pos::IdxPairValueSet::get ( const SPos ,
IdxPair ,
float &  ,
float &   
) const

◆ get() [4/6]

void Pos::IdxPairValueSet::get ( const SPos ,
IdxPair ,
float *  v = 0,
int  mxnrvals = -1 
) const

◆ get() [5/6]

void Pos::IdxPairValueSet::get ( const SPos ,
IdxPair ,
TypeSet< float > &  ,
int  maxnrvals = -1 
) const

max == -1 => all

◆ get() [6/6]

void Pos::IdxPairValueSet::get ( const SPos ,
PairVal  
) const

◆ getColumn()

void Pos::IdxPairValueSet::getColumn ( int  valnr,
TypeSet< float > &  ,
bool  incudf 
) const

◆ getFrom()

bool Pos::IdxPairValueSet::getFrom ( od_istream ,
Pos::GeomID  = mUdf(Pos::GeomID) 
)

detects/converts coords if geomid passed

◆ getFrst()

IdxType Pos::IdxPairValueSet::getFrst ( const SPos pos) const
inlineprotected

◆ getIdxPair()

IdxPair Pos::IdxPairValueSet::getIdxPair ( const SPos ) const

◆ getPos()

SPos Pos::IdxPairValueSet::getPos ( od_int64  global_idx) const

Slow. And no check on idx in range.

◆ getScnd()

IdxType Pos::IdxPairValueSet::getScnd ( const SPos pos) const
inlineprotected

◆ getScndSet() [1/4]

TypeSet<IdxType>& Pos::IdxPairValueSet::getScndSet ( const SPos pos)
inlineprotected

◆ getScndSet() [2/4]

const TypeSet<IdxType>& Pos::IdxPairValueSet::getScndSet ( const SPos pos) const
inlineprotected

◆ getScndSet() [3/4]

TypeSet<IdxType>& Pos::IdxPairValueSet::getScndSet ( int  idx)
inlineprotected

◆ getScndSet() [4/4]

const TypeSet<IdxType>& Pos::IdxPairValueSet::getScndSet ( int  idx) const
inlineprotected

◆ getSecondsAtIdx()

void Pos::IdxPairValueSet::getSecondsAtIdx ( int  firstidx,
TypeSet< int > &   
) const

◆ getVal()

float Pos::IdxPairValueSet::getVal ( const SPos pos,
int  valnr 
) const
inline

< Direct access to value arrays.

◆ getVals() [1/2]

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

Direct access to value arrays.

◆ getVals() [2/2]

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

Direct access to value arrays.

◆ getValSet() [1/4]

TypeSet<float>& Pos::IdxPairValueSet::getValSet ( const SPos pos)
inlineprotected

◆ getValSet() [2/4]

const TypeSet<float>& Pos::IdxPairValueSet::getValSet ( const SPos pos) const
inlineprotected

◆ getValSet() [3/4]

TypeSet<float>& Pos::IdxPairValueSet::getValSet ( int  idx)
inlineprotected

◆ getValSet() [4/4]

const TypeSet<float>& Pos::IdxPairValueSet::getValSet ( int  idx) const
inlineprotected

◆ hasCol()

bool Pos::IdxPairValueSet::hasCol ( IdxType  col) const
inline

◆ hasCrl()

bool Pos::IdxPairValueSet::hasCrl ( IdxType  crl) const
inline

◆ hasDuplicateIdxPairs()

bool Pos::IdxPairValueSet::hasDuplicateIdxPairs ( ) const

◆ hasFirst()

bool Pos::IdxPairValueSet::hasFirst ( IdxType  ) const

◆ hasInl()

bool Pos::IdxPairValueSet::hasInl ( IdxType  inl) const
inline

◆ hasRow()

bool Pos::IdxPairValueSet::hasRow ( IdxType  row) const
inline

◆ hasSecond()

bool Pos::IdxPairValueSet::hasSecond ( IdxType  ) const

◆ haveDataRow()

bool Pos::IdxPairValueSet::haveDataRow ( const DataRow ) const

◆ includes() [1/2]

bool Pos::IdxPairValueSet::includes ( const DataRow ) const

◆ includes() [2/2]

bool Pos::IdxPairValueSet::includes ( const IdxPair ip) const
inline

◆ inlRange()

Interval<int> Pos::IdxPairValueSet::inlRange ( ) const
inline

◆ insertVal()

bool Pos::IdxPairValueSet::insertVal ( int  )

◆ isEmpty()

bool Pos::IdxPairValueSet::isEmpty ( ) const
inline

◆ isValid()

bool Pos::IdxPairValueSet::isValid ( const IdxPair ) const

◆ next()

bool Pos::IdxPairValueSet::next ( SPos ,
bool  skip_duplicate_idxpairs = false 
) const

◆ nrCols()

int Pos::IdxPairValueSet::nrCols ( IdxType  row) const
inline

◆ nrCrls()

int Pos::IdxPairValueSet::nrCrls ( IdxType  inl) const
inline

◆ nrDuplicateIdxPairs()

int Pos::IdxPairValueSet::nrDuplicateIdxPairs ( ) const

◆ nrFirst()

int Pos::IdxPairValueSet::nrFirst ( ) const
inline

◆ nrInls()

int Pos::IdxPairValueSet::nrInls ( ) const
inline

◆ nrPos()

int Pos::IdxPairValueSet::nrPos ( int  lineidx) const

nth line in the set

◆ nrRows()

int Pos::IdxPairValueSet::nrRows ( ) const
inline

◆ nrSecond()

int Pos::IdxPairValueSet::nrSecond ( IdxType  firstidx) const

◆ nrVals()

int Pos::IdxPairValueSet::nrVals ( ) const
inline

◆ operator=()

IdxPairValueSet& Pos::IdxPairValueSet::operator= ( const IdxPairValueSet )

◆ prev()

bool Pos::IdxPairValueSet::prev ( SPos ,
bool  skip_duplicate_idxpairs = false 
) const

◆ putTo()

bool Pos::IdxPairValueSet::putTo ( od_ostream ) const

◆ randomSubselect()

void Pos::IdxPairValueSet::randomSubselect ( od_int64  maxnr)

◆ remove() [1/4]

void Pos::IdxPairValueSet::remove ( const IdxPairValueSet )

◆ remove() [2/4]

void Pos::IdxPairValueSet::remove ( const SPos )

afterwards, SPos may be invalid

◆ remove() [3/4]

void Pos::IdxPairValueSet::remove ( const TrcKeySampling hrg,
bool  inside 
)

◆ remove() [4/4]

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

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

◆ removeDuplicateIdxPairs()

void Pos::IdxPairValueSet::removeDuplicateIdxPairs ( )

◆ removeLine()

void Pos::IdxPairValueSet::removeLine ( int  idx)
protected

◆ removeRange()

void Pos::IdxPairValueSet::removeRange ( int  valnr,
const Interval< float > &  ,
bool  inside = true 
)

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

◆ removeVal()

void Pos::IdxPairValueSet::removeVal ( int  )

Will remove entire 'column'.

◆ rowRange()

Interval<int> Pos::IdxPairValueSet::rowRange ( ) const
inline

◆ secondIdx()

int Pos::IdxPairValueSet::secondIdx ( int  firstidx,
int   
) const

◆ secondRange()

Interval<IdxType> Pos::IdxPairValueSet::secondRange ( IdxType  firsidx = -1) const

◆ set() [1/4]

void Pos::IdxPairValueSet::set ( const SPos ,
const TypeSet< float > &   
)

◆ set() [2/4]

void Pos::IdxPairValueSet::set ( const SPos ,
float   
)

◆ set() [3/4]

void Pos::IdxPairValueSet::set ( const SPos ,
float  ,
float   
)

◆ set() [4/4]

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) .

◆ setEmpty()

void Pos::IdxPairValueSet::setEmpty ( )

◆ setNrVals()

bool Pos::IdxPairValueSet::setNrVals ( int  ,
bool  kp_data = true 
)

◆ sortDuplicateIdxPairs()

void Pos::IdxPairValueSet::sortDuplicateIdxPairs ( int  value_nr,
bool  ascending = true 
)

◆ sortPart()

void Pos::IdxPairValueSet::sortPart ( TypeSet< IdxType > &  ,
TypeSet< float > &  ,
int  ,
int  ,
int  ,
bool   
)
protected

◆ totalSize()

od_int64 Pos::IdxPairValueSet::totalSize ( ) const

◆ updNearest()

void Pos::IdxPairValueSet::updNearest ( const IdxPair ,
const SPos ,
od_int64 &  ,
SPos  
) const
protected

◆ usePar()

void Pos::IdxPairValueSet::usePar ( const IOPar ,
const char *  key 
)

◆ valRange()

Interval<float> Pos::IdxPairValueSet::valRange ( int  valnr) const

Friends And Related Function Documentation

◆ DataPointSet

friend class DataPointSet
friend

◆ PosVecDataSet

friend class PosVecDataSet
friend

Member Data Documentation

◆ allowdup_

bool Pos::IdxPairValueSet::allowdup_
protected

◆ frsts_

TypeSet<IdxType> Pos::IdxPairValueSet::frsts_
protected

◆ nrvals_

const int Pos::IdxPairValueSet::nrvals_
protected

◆ scndsets_

ObjectSet< TypeSet<IdxType> > Pos::IdxPairValueSet::scndsets_
protected

◆ valsets_

ObjectSet< TypeSet<float> > Pos::IdxPairValueSet::valsets_
protected

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