OpendTect-6_4  6.4
rowcol.h
Go to the documentation of this file.
1 #ifndef rowcol_h
2 #define rowcol_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: A.H. Bril
9  Date: 12-8-1997
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "basicmod.h"
16 #include "posidxpair.h"
17 class RowCol;
18 
19 
20 typedef RowCol RowColDelta;
21 
22 
25 mExpClass(Basic) RowCol : public Pos::IdxPair
26 {
27 public:
28 
29  inline RowCol() {}
30  inline RowCol(int r,int c);
31  RowCol(const Pos::IdxPair&);
32 
33  inline RowCol operator+(const RowCol&) const;
34  inline RowCol operator-(const RowCol&) const;
35  inline RowCol operator+() const;
36  inline RowCol operator-() const;
37  inline RowCol operator*(const RowCol&) const;
38  inline RowCol operator*(int) const;
39  inline RowCol operator/(const RowCol&) const;
40  inline RowCol operator/(int) const;
41  inline const RowCol& operator+=(const RowCol&);
42  inline const RowCol& operator-=(const RowCol&);
43  inline const RowCol& operator*=(const RowCol&);
44  inline const RowCol& operator*=(int);
45  inline const RowCol& operator/=(const RowCol&);
46 
47  inline const char* toString(bool onlycol=false) const;
48  inline bool fromString(const char*);
49  static inline RowCol fromInt64(od_int64);
50  inline int toInt32() const;
51  static inline RowCol fromInt32(int);
52 
53  RowCol getDirection() const;
58  float angleTo(const RowCol&) const;
62  float clockwiseAngleTo(const RowCol& rc) const;
66  float counterClockwiseAngleTo(const RowCol&) const;
72  static const TypeSet<RowCol>& clockWiseSequence();
73 
74 };
75 
76 
78  : Pos::IdxPair(i,c)
79 {
80 }
81 
82 
83 inline RowCol::RowCol( const Pos::IdxPair& p )
84  : Pos::IdxPair(p)
85 {
86 }
87 
88 
90 {
92  return RowCol( p.first, p.second );
93 }
94 
95 
96 
97 inline RowCol RowCol::operator+( const RowCol& rc ) const
98  { return RowCol( row()+rc.row(), col()+rc.col() ); }
99 inline RowCol RowCol::operator-( const RowCol& rc ) const
100  { return RowCol( row()-rc.row(), col()-rc.col() ); }
101 inline RowCol RowCol::operator+() const
102  { return RowCol( +row(), +col() ); }
103 inline RowCol RowCol::operator-() const
104  { return RowCol( -row(), -col() ); }
105 inline RowCol RowCol::operator*( const RowCol& rc ) const
106  { return RowCol( row()*rc.row(), col()*rc.col() ); }
107 inline RowCol RowCol::operator*( int factor ) const
108  { return RowCol( row()*factor, col()*factor ); }
109 inline RowCol RowCol::operator/( const RowCol& rc ) const
110  { return RowCol( row()/rc.row(), col()/rc.col() ); }
111 inline RowCol RowCol::operator/( int denominator ) const
112  { return RowCol( row()/denominator, col()/denominator ); }
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*=( const RowCol& rc )
118  { row() *= rc.row(); col() *= rc.col(); return *this; }
119 inline const RowCol& RowCol::operator*=( int factor )
120  { row() *= factor; col() *= factor; return *this; }
121 inline const RowCol& RowCol::operator/=( const RowCol& rc )
122  { row() /= rc.row(); col() /= rc.col(); return *this; }
123 inline int RowCol::toInt32() const
124  { return (((unsigned int) row())<<16)+ ((unsigned int) col() & 0xFFFF);}
125 inline RowCol RowCol::fromInt32(int ll)
126  { return RowCol ( ll>>16, ((short)(ll&0xFFFF)) ); }
127 
128 
129 
130 inline const char* RowCol::toString( bool onlycol ) const
131 {
132  return Pos::IdxPair::getUsrStr( "", "/", "", onlycol );
133 }
134 
135 
136 inline bool RowCol::fromString( const char* str )
137 {
138  return Pos::IdxPair::parseUsrStr( str, "", "/", "" );
139 }
140 
141 
142 
143 #endif
IdxType & row()
Definition: posidxpair.h:45
const RowCol & operator-=(const RowCol &)
Definition: rowcol.h:115
#define mExpClass(module)
Definition: commondefs.h:160
int operator-(const DateInfo &di1, const DateInfo &di2)
Definition: dateinfo.h:129
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:136
const RowCol & operator*=(const RowCol &)
Definition: rowcol.h:117
#define od_int64
Definition: plftypes.h:36
const RowCol & operator+=(const RowCol &)
Definition: rowcol.h:113
const char * toString(bool onlycol=false) const
Definition: rowcol.h:130
float angleTo(const RowCol &) const
IdxPair with position indices; base class for BinID et al.
Definition: posidxpair.h:29
const RowCol & operator/=(const RowCol &)
Definition: rowcol.h:121
RowCol operator/(const RowCol &) const
Definition: rowcol.h:109
RowCol operator-() const
Definition: rowcol.h:103
RowCol()
Definition: rowcol.h:29
static const TypeSet< RowCol > & clockWiseSequence()
static IdxPair fromInt64(int64_t)
Definition: posidxpair.h:95
Position.
Definition: commontypes.h:42
RowCol RowColDelta
Definition: rowcol.h:17
RowCol operator+() const
Definition: rowcol.h:101
Coord3 operator*(double f, const Coord3 &b)
Definition: coord.h:130
IdxPair used for its row() and col().
Definition: rowcol.h:25
IdxType & col()
Definition: posidxpair.h:50
int toInt32() const
Definition: rowcol.h:123
Index_Type IdxType
Definition: idxpair.h:34
static RowCol fromInt32(int)
Definition: rowcol.h:125
RowCol getDirection() const
static RowCol fromInt64(int64_t)
Definition: rowcol.h:89
Export_Basic const char * toString(ViewStyle)
A pair of numbers; base class for BinID et al.
Definition: idxpair.h:30
RowCol operator*(const RowCol &) const
Definition: rowcol.h:105
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. 2019