|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
//文件: SegY文件操作类
|
|
|
//主要功能:
|
|
|
// 实现坐标与线道号之间的相互转换
|
|
|
//程序编写: 2011-4-1
|
|
|
//
|
|
|
//
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
#pragma once
|
|
|
#include "RowCol.h"
|
|
|
#include "TInterval.h"
|
|
|
|
|
|
namespace NCube
|
|
|
{
|
|
|
|
|
|
//实现坐标与线道号之间的相互转换
|
|
|
class AFX_EXT_CLASS CCoorTransform
|
|
|
{
|
|
|
public:
|
|
|
CCoorTransform(void);
|
|
|
~CCoorTransform(void);
|
|
|
|
|
|
//带有x、y的为坐标,带有m、n的为线道号
|
|
|
bool Create( double x1, double y1, double m1, double n1,
|
|
|
double ddx, double ddy, double angle );
|
|
|
//根据对应二点生成平面(二点校位)
|
|
|
bool Create(
|
|
|
double x1, double y1, double m1, double n1,
|
|
|
double x2, double y2, double m2, double n2 );
|
|
|
|
|
|
//根据对应三点生成平面(三点校位)
|
|
|
bool Create(
|
|
|
double x1, double y1, double m1, double n1,
|
|
|
double x2, double y2, double m2, double n2,
|
|
|
double x3, double y3, double m3, double n3 );
|
|
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
//三点 max inline
|
|
|
// 2---------------------------
|
|
|
// | |
|
|
|
// | | max
|
|
|
// | |crossline
|
|
|
// | |
|
|
|
// | |
|
|
|
// 1---------------------------3
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
//!< 设置变换需要的三个对应坐标点. 注意第三点线号与第一点线号相同
|
|
|
//!< c0、c1、c2为实际坐标点,对应的线道号坐标为rc0、rc1、rc2(rc0.row,col2)
|
|
|
bool set3Points(
|
|
|
const CPoint2D& c0, const CPoint2D& c1, const CPoint2D& c2,
|
|
|
const CRowCol& rc0, const CRowCol& rc1, int col2 );
|
|
|
|
|
|
//!< 线道号转换为坐标
|
|
|
void toXY(const CRowCol& rc, CPoint2D& pt);
|
|
|
void toXY(int row, int col, double&x, double& y);
|
|
|
void toXY(double row, double col, double&x, double& y);
|
|
|
CPoint2D toXY(const CRowCol& rc);
|
|
|
CPoint2D toXY(int row, int col);
|
|
|
CPoint2D toXY(double row, double col);
|
|
|
|
|
|
//!< 坐标转换为线道号
|
|
|
void toRC(const CPoint2D& pt, CRowCol& rc);
|
|
|
void toRC(double x, double y, int& row, int& col);
|
|
|
CRowCol toRC(const CPoint2D& pt);
|
|
|
CRowCol toRC(double x, double y);
|
|
|
|
|
|
//!< 将线道号转换为坐标
|
|
|
CRowCol TransformBack(const CPoint2D& coord,
|
|
|
const TIntervalStep<int>* inlrg=0,
|
|
|
const TIntervalStep<int>* crlrg=0 ) const;
|
|
|
/*!< Transforms Coord to RowCol. If the ranges are
|
|
|
given, they are only used for snapping: the actual range is not used */
|
|
|
|
|
|
CPoint2D TransformBackNoSnap(const CPoint2D& coord) const;
|
|
|
/*!< transforms back, but does not snap. The row is stored in the x-component, and the
|
|
|
col is stored in the y-component. */
|
|
|
|
|
|
//输出测网
|
|
|
void WriteLine(LPCTSTR lpszFileName, TIntervalStep<int> row, TIntervalStep<int> col);
|
|
|
|
|
|
void Write(CFile& fw);
|
|
|
int Read(CFile& fr);
|
|
|
void Serialize(CArchive& ar, const short &ver);
|
|
|
|
|
|
protected:
|
|
|
//!<Sets up the transform using three points. note that the third point is
|
|
|
//assumed to be on the same row as the first point.
|
|
|
struct RCTransform
|
|
|
{
|
|
|
RCTransform() { a = b = c = 0; }
|
|
|
|
|
|
inline double det( const RCTransform& bct ) const
|
|
|
{
|
|
|
return b * bct.c - bct.b * c;
|
|
|
}
|
|
|
inline bool valid( const RCTransform& bct ) const
|
|
|
{
|
|
|
double d = det( bct );
|
|
|
return !mIsZero(d, 1e-10);
|
|
|
}
|
|
|
|
|
|
double a, b, c;
|
|
|
};
|
|
|
|
|
|
public:
|
|
|
void setTransforms( const RCTransform& x,const RCTransform& y ) { xtr = x; ytr = y; }
|
|
|
const RCTransform& getTransform( bool x ) const { return x ? xtr : ytr; }
|
|
|
|
|
|
protected:
|
|
|
RCTransform xtr;
|
|
|
RCTransform ytr;
|
|
|
|
|
|
public:
|
|
|
//形成变换的对应三点
|
|
|
CPoint2D m_pt[3];
|
|
|
CRowCol m_rc[3];
|
|
|
};
|
|
|
|
|
|
}//namespace
|