|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
//<2F>ļ<EFBFBD>: SegY<67>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
//<2F><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>:
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD><DFA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߺ<EFBFBD>Ϊ<EFBFBD>кţ<D0BA><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߺ<EFBFBD>Ϊ<EFBFBD>к<EFBFBD>
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д: 2011-4-1
|
|
|
|
|
|
//
|
|
|
|
|
|
//
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef rowcol_h
|
|
|
|
|
|
#define rowcol_h
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace NCube
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
class AFX_EXT_CLASS CRowCol
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
inline CRowCol(int r,int c);
|
|
|
|
|
|
inline CRowCol(const CRowCol&);
|
|
|
|
|
|
inline CRowCol(const __int64&);
|
|
|
|
|
|
inline CRowCol();
|
|
|
|
|
|
|
|
|
|
|
|
inline bool operator==(const CRowCol&) const;
|
|
|
|
|
|
inline bool operator!=(const CRowCol&) const;
|
|
|
|
|
|
inline CRowCol operator+(const CRowCol&) const;
|
|
|
|
|
|
inline CRowCol operator-(const CRowCol&) const;
|
|
|
|
|
|
inline CRowCol operator+() const;
|
|
|
|
|
|
inline CRowCol operator-() const;
|
|
|
|
|
|
inline CRowCol operator*(const CRowCol&) const;
|
|
|
|
|
|
inline CRowCol operator*(int) const;
|
|
|
|
|
|
inline CRowCol operator/(const CRowCol&) const;
|
|
|
|
|
|
inline CRowCol operator/(int) const;
|
|
|
|
|
|
inline const CRowCol& operator+=(const CRowCol&);
|
|
|
|
|
|
inline const CRowCol& operator-=(const CRowCol&);
|
|
|
|
|
|
inline const CRowCol& operator*=(const CRowCol&);
|
|
|
|
|
|
inline const CRowCol& operator*=(int);
|
|
|
|
|
|
inline const CRowCol& operator/=(const CRowCol&);
|
|
|
|
|
|
inline int& operator[](int idx);
|
|
|
|
|
|
inline int operator[](int idx) const;
|
|
|
|
|
|
|
|
|
|
|
|
void getString(char*) const;
|
|
|
|
|
|
void setString(char*) const;
|
|
|
|
|
|
|
|
|
|
|
|
bool use(const char*);
|
|
|
|
|
|
__int64 toInt64() const;
|
|
|
|
|
|
void fromInt64(__int64);
|
|
|
|
|
|
int toInt32() const;
|
|
|
|
|
|
void fromInt32(int);
|
|
|
|
|
|
int sqDistTo(const CRowCol&) const;
|
|
|
|
|
|
bool isNeighborTo(const CRowCol&,const CRowCol&, bool eightconnectivity=true) const;
|
|
|
|
|
|
void set(int r, int c) { row = r; col = c; }
|
|
|
|
|
|
void Swap() { int sp = row; row = col; col = sp; }
|
|
|
|
|
|
|
|
|
|
|
|
int row; //inline
|
|
|
|
|
|
int col; //crossline
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
inline CRowCol::CRowCol( int r, int c ) : row(r), col(c) {}
|
|
|
|
|
|
inline CRowCol::CRowCol( const CRowCol& rc ) : row(rc.row), col(rc.col) {}
|
|
|
|
|
|
inline CRowCol::CRowCol( const __int64& ser ) { fromInt64(ser); }
|
|
|
|
|
|
inline CRowCol::CRowCol() : row( 0 ), col ( 0 ) {}
|
|
|
|
|
|
inline bool CRowCol::operator==(const CRowCol& rc ) const { return row==rc.row && col==rc.col; }
|
|
|
|
|
|
inline bool CRowCol::operator!=(const CRowCol& rc ) const { return row!=rc.row || col!=rc.col; }
|
|
|
|
|
|
inline CRowCol CRowCol::operator+( const CRowCol& rc ) const { return CRowCol( row+rc.row, col+rc.col ); }
|
|
|
|
|
|
inline CRowCol CRowCol::operator-( const CRowCol& rc ) const { return CRowCol( row-rc.row, col-rc.col ); }
|
|
|
|
|
|
inline CRowCol CRowCol::operator+() const { return CRowCol( +row, +col ); }
|
|
|
|
|
|
inline CRowCol CRowCol::operator-() const { return CRowCol( -row, -col ); }
|
|
|
|
|
|
inline CRowCol CRowCol::operator*( const CRowCol& rc ) const { return CRowCol( row*rc.row, col*rc.col ); }
|
|
|
|
|
|
inline CRowCol CRowCol::operator*( int factor ) const { return CRowCol( row*factor, col*factor ); }
|
|
|
|
|
|
inline CRowCol CRowCol::operator/( const CRowCol& rc ) const { return CRowCol( row/rc.row, col/rc.col ); }
|
|
|
|
|
|
inline CRowCol CRowCol::operator/( int denominator ) const { return CRowCol( row/denominator, col/denominator ); }
|
|
|
|
|
|
inline const CRowCol& CRowCol::operator+=( const CRowCol& rc ) { row += rc.row; col += rc.col; return *this; }
|
|
|
|
|
|
inline const CRowCol& CRowCol::operator-=( const CRowCol& rc ) { row -= rc.row; col -= rc.col; return *this; }
|
|
|
|
|
|
inline const CRowCol& CRowCol::operator*=( const CRowCol& rc ) { row *= rc.row; col *= rc.col; return *this; }
|
|
|
|
|
|
inline const CRowCol& CRowCol::operator*=( int factor ) { row *= factor; col *= factor; return *this; }
|
|
|
|
|
|
inline const CRowCol& CRowCol::operator/=( const CRowCol& rc ) { row /= rc.row; col /= rc.col; return *this; }
|
|
|
|
|
|
inline int& CRowCol::operator[](int idx) { return idx==0 ? row : col; }
|
|
|
|
|
|
inline int CRowCol::operator[](int idx) const { return idx==0 ? row : col; }
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
using namespace NCube;
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|