////////////////////////////////////////////////////////////////////////////// //文件: SegY文件操作类 //主要功能: // 定义主测线与联络测线,主测线号为行号,联络测线号为列号 //程序编写: 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