OpendTect  6.3
rowcol.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: A.H. Bril
8  Date: 12-8-1997
9 ________________________________________________________________________
10 
11 -*/
12 
13 #include "basicmod.h"
14 #include "posidxpair.h"
15 class RowCol;
16 
17 
18 typedef RowCol RowColDelta;
19 
20 
23 mExpClass(Basic) RowCol : public Pos::IdxPair
24 {
25 public:
26 
27  inline RowCol() {}
28  inline RowCol(int r,int c);
29  RowCol(const Pos::IdxPair&);
30 
31  inline RowCol operator+(const RowCol&) const;
32  inline RowCol operator-(const RowCol&) const;
33  inline RowCol operator+() const;
34  inline RowCol operator-() const;
35  inline RowCol operator*(const RowCol&) const;
36  inline RowCol operator*(int) const;
37  inline RowCol operator/(const RowCol&) const;
38  inline RowCol operator/(int) const;
39  inline const RowCol& operator+=(const RowCol&);
40  inline const RowCol& operator-=(const RowCol&);
41  inline const RowCol& operator*=(const RowCol&);
42  inline const RowCol& operator*=(int);
43  inline const RowCol& operator/=(const RowCol&);
44 
45  inline const char* toString(bool onlycol=false) const;
46  inline bool fromString(const char*);
47  static inline RowCol fromInt64(od_int64);
48  inline int toInt32() const;
49  static inline RowCol fromInt32(int);
50 
51  RowCol getDirection() const;
56  float angleTo(const RowCol&) const;
60  float clockwiseAngleTo(const RowCol& rc) const;
64  float counterClockwiseAngleTo(const RowCol&) const;
70  static const TypeSet<RowCol>& clockWiseSequence();
71 
72 };
73 
74 
76  : Pos::IdxPair(i,c)
77 {
78 }
79 
80 
81 inline RowCol::RowCol( const Pos::IdxPair& p )
82  : Pos::IdxPair(p)
83 {
84 }
85 
86 
88 {
90  return RowCol( p.first, p.second );
91 }
92 
93 
94 
95 inline RowCol RowCol::operator+( const RowCol& rc ) const
96  { return RowCol( row()+rc.row(), col()+rc.col() ); }
97 inline RowCol RowCol::operator-( const RowCol& rc ) const
98  { return RowCol( row()-rc.row(), col()-rc.col() ); }
99 inline RowCol RowCol::operator+() const
100  { return RowCol( +row(), +col() ); }
101 inline RowCol RowCol::operator-() const
102  { return RowCol( -row(), -col() ); }
103 inline RowCol RowCol::operator*( const RowCol& rc ) const
104  { return RowCol( row()*rc.row(), col()*rc.col() ); }
105 inline RowCol RowCol::operator*( int factor ) const
106  { return RowCol( row()*factor, col()*factor ); }
107 inline RowCol RowCol::operator/( const RowCol& rc ) const
108  { return RowCol( row()/rc.row(), col()/rc.col() ); }
109 inline RowCol RowCol::operator/( int denominator ) const
110  { return RowCol( row()/denominator, col()/denominator ); }
111 inline const RowCol& RowCol::operator+=( const RowCol& rc )
112  { row() += rc.row(); col() += rc.col(); return *this; }
113 inline const RowCol& RowCol::operator-=( const RowCol& rc )
114  { row() -= rc.row(); col() -= rc.col(); return *this; }
115 inline const RowCol& RowCol::operator*=( const RowCol& rc )
116  { row() *= rc.row(); col() *= rc.col(); return *this; }
117 inline const RowCol& RowCol::operator*=( int factor )
118  { row() *= factor; col() *= factor; return *this; }
119 inline const RowCol& RowCol::operator/=( const RowCol& rc )
120  { row() /= rc.row(); col() /= rc.col(); return *this; }
121 inline int RowCol::toInt32() const
122  { return (((unsigned int) row())<<16)+ ((unsigned int) col() & 0xFFFF);}
123 inline RowCol RowCol::fromInt32(int ll)
124  { return RowCol ( ll>>16, ((short)(ll&0xFFFF)) ); }
125 
126 
127 
128 inline const char* RowCol::toString( bool onlycol ) const
129 {
130  return Pos::IdxPair::getUsrStr( "", "/", "", onlycol );
131 }
132 
133 
134 inline bool RowCol::fromString( const char* str )
135 {
136  return Pos::IdxPair::parseUsrStr( str, "", "/", "" );
137 }
IdxType & row()
Definition: posidxpair.h:43
const RowCol & operator-=(const RowCol &)
Definition: rowcol.h:113
#define mExpClass(module)
Definition: commondefs.h:157
int operator-(const DateInfo &di1, const DateInfo &di2)
Definition: dateinfo.h:127
const char * getUsrStr(const char *prefx, const char *sep, const char *postfx, bool only2nd) const
float counterClockwiseAngleTo(const RowCol &) const
bool fromString(const char *)
Definition: rowcol.h:134
const RowCol & operator*=(const RowCol &)
Definition: rowcol.h:115
#define od_int64
Definition: plftypes.h:34
const RowCol & operator+=(const RowCol &)
Definition: rowcol.h:111
const char * toString(bool onlycol=false) const
Definition: rowcol.h:128
float angleTo(const RowCol &) const
IdxPair with position indices; base class for BinID et al.
Definition: posidxpair.h:27
const RowCol & operator/=(const RowCol &)
Definition: rowcol.h:119
RowCol operator/(const RowCol &) const
Definition: rowcol.h:107
RowCol operator-() const
Definition: rowcol.h:101
RowCol()
Definition: rowcol.h:27
static const TypeSet< RowCol > & clockWiseSequence()
static IdxPair fromInt64(int64_t)
Definition: posidxpair.h:93
Position.
Definition: commontypes.h:38
RowCol RowColDelta
Definition: rowcol.h:15
BufferString toString(const DBKey &ky)
Definition: dbkey.h:115
RowCol operator+() const
Definition: rowcol.h:99
IdxPair used for its row() and col().
Definition: rowcol.h:23
IdxType & col()
Definition: posidxpair.h:48
int toInt32() const
Definition: rowcol.h:121
Index_Type IdxType
Definition: idxpair.h:32
static RowCol fromInt32(int)
Definition: rowcol.h:123
RowCol getDirection() const
Point2D< T > operator*(int f, const Point2D< T > &b)
Definition: geometry.h:86
static RowCol fromInt64(int64_t)
Definition: rowcol.h:87
A pair of numbers; base class for BinID et al.
Definition: idxpair.h:28
RowCol operator*(const RowCol &) const
Definition: rowcol.h:103
bool parseUsrStr(const char *str, const char *prefx, const char *sep, const char *postfx)
float clockwiseAngleTo(const RowCol &rc) const

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