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

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