You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

231 lines
6.7 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

//////////////////////////////////////////////////////////////////////////////
//文件: SegY文件操作类
//主要功能:
//
//程序编写: 2005-12-07
//
//
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include ".\DrawExchange.h"
#include "Offset.h"
extern "C"
{
AFX_EXT_API double WINAPI DrawExchangeToDepth(double &x,double &y);
AFX_EXT_API double WINAPI DrawExchangeToTime(double &x, double &y);//输入的x为CDP号y为深度值返回时y为时间
AFX_EXT_API CDrawExchange2D* WINAPI GetDrawExchange(void);
AFX_EXT_API COffset ** WINAPI GetPPOffsetX();
AFX_EXT_API void * WINAPI SectionToFXY(CSectionBase &sec);
AFX_EXT_API void WINAPI SetServerHost(CString strServerHost);
};
class AFX_EXT_CLASS CTraceData
{
public:
CTraceData();
~CTraceData(void);
float GetValue(long i, long j); //i为道索引号,j为采样点索引号
void SetValue(long i, long j, float v);
float GetMaxValue(long i);
float GetMinValue(long i);
float GetRMS(long i);
float* GetTrace(long i);
void Reversal(void);
void CopyData(CTraceData& td);
void GetMinMax(void);
void GetOneMinMaxRMS(long i);
int Create(long nx, long ny);
void Clear(void);
float* m_pMaxValue; //每道数据的最大最小值
float* m_pMinValue;
float* m_pTraceRMS; //每道数据的均方根值
float* m_pData; //道数据
long numx; //道数
long numy; //采样点数
BYTE* m_pRead; //标识单道数据是否已经读取
BOOL m_bReadedAll; //是否已经读取了全部数据
BOOL IsReaded(long i);
void EnableReaded(long i, BOOL bReaded);
void EnableReaded(BOOL bEnable);
void operator=(CTraceData& td);
};
class AFX_EXT_CLASS CSectionBase :
public CVector
{
public:
CSectionBase(void);
virtual ~CSectionBase(void);
virtual void Serialize(CArchive& ar, const short& ver);
void Serialize_Old(CArchive& ar, const short& ver);
virtual int Read(CFile& fr, const short& ver);
int ReadOld(CFile& fr, const short& ver);
virtual void Write(CFile& fw, const short& ver);
int ReadOther(CFile& fr, const short& ver);
void WriteOther(CFile& fw, const short& ver);
void CreateOther(void); //必须在初始化参数n与dt之后
virtual int Create(int numx);
virtual void Clear(void);
virtual int GetRange(double& min, double& max);
virtual void operator=(CSectionBase& sb);
//IndexOffset为每道的索引号保存在道头中的位置,为了保存出的SEGY建立索引用
int WriteSegy(CString outSegy,int IndexOffset); //将当前剖面写为一个SEGY文件
int WriteSegy(CString outSegy); //将当前剖面数据写到一个SEGY文件中
int WriteHead(CFile64& fw,int nHead=3600); //写SEGY文件头
//写为深度域剖面,ppthCurve为一条时深曲线,将其不为空时根据这条曲线调用ToDepthWidthCurve将剖面转换为深度域剖面
int WriteSegyDepth(CString outSegy, int IndexOffset, CCurve* ppthCurve=NULL);
int WriteSegy(LPCTSTR lpszFileName, CTraceData& td, double dy);
int WriteMesh(LPCTSTR lpszFileName, CTraceData& td, double dy);
int CreateDimension2D(CDimension2D& dim, CTraceData& td, double dy);
//对SEGY文件进行操作,打开的文件是m_input
int Open(void);
void Close(void);
virtual void ClearTraceData(void);//清除已读取的地震道数据
protected:
virtual void InitSection(); //在显示剖面之前,进行初始化操作
virtual void SectionMath(CVector& vt); //对读取的地震道进行处理
CVector v[2];
CVector vt;
CCurve *pCurve;
//读取SEGY文件指针
CFileSegy *m_pfr;
CVector vh[2];
public:
CImage *ToImage(int sel);
CImage *ToImage(void *pColor);
int GetRange(double& min, double& max,int m_first,int m_end,int step);//step=10;first=2
int GetMN(double l0,double &m,double &n);
CVector* GetOneA(int i);
CCurve* GetCurrentTraceCurve(void);
void SortTrace(void); //当CDP号大小顺序进行排序,小的再前大的在后
virtual void Reversal(void);
//获得振幅值
BOOL GetPointSwing(int i, double &t0); //获得某一T0处的振幅值
BOOL GetRangeSwing(int i, double bt0, double et0, double& swing, int idea); //获得某一范围的振幅值
double X0(void);
double Y0(void);
double X1(void);
double Y1(void);
double DY(void);
double Y0H(void);
double Y1H(void);
double DYH(void);
void SetTimePoint(double dStartTime, double dEndTime);
int StartPoint,EndPoint;//开始(结束)时间/深度(0=<point<=n)
//对于彩色显示剖面进行深度转换时
double delth; //采样间隔
long numh; //采样点个数
CString name;
__int64 *offset;
double *DrawExchangeM;
double *DrawExchangeN;
double x0;
double y0;
int n; // 采样点个数
//int DataType; // 数据类型
int m_nFormatCode; // SEGY中振幅数据的格式代码(1=IBM float,5=IEEE float),详请见dfSegyAnalyzer3D.exe中文件头分析
int IsPC;
double dt; //采样间隔
DWORD m_nFlags; //为了扩展用
CFileSegy::EDataType GetFormatCode(void);
CFileSegy* GetIoFile(void);
//为了使显示更快,保存每道的数据
CTraceData m_traceData; //地震剖面数据,时间值
//仅显示深度域剖面或速度剖面时使用
CTraceData m_traceVel; //速度值, 范围与时间数据相同
CTraceData m_traceDepth; //地震剖面数据,深度值,由 [速度*时间] 得到后,根据SetCustomDepth设置的采样间隔及采样点个数插值得到
//为了拉平层
CTraceData m_traceDragFlat; //拉平地震剖面
int m_bDrawVelocitySection; //画速度剖面
void SetCustomDepth(double interval, long numh);
void ToVelocity(double x0, CVector& v);
BOOL IsDrawDepth(void);
BOOL IsDragFlat(void);
virtual int ReadTraceOne(int index, BOOL bMustRead=FALSE);
void ReadTraceData(void);
int TimeToDepthOne(int nIndex, BOOL bMustTo=FALSE);
void TimeToDepth(void);
void ToDragFlat(void); //拉平所有道
int ToDragFlatOne(int nIndex, BOOL bMustToDragFlat=FALSE); //拉平指定道
//old, 速度较慢,在CSectionDraw中使用
virtual int ReadTrace(int index, CVector& vecter); //读取一道的数据,读取一道的采样个数由vecter.num确定(0<index<num)
int ToDepth(int nIndex,CVector &v);
int MustToDepth(int nIndex,CVector &v);
int ToDepth(int nIndex,CVector &v,CVector &vh);
int ToDepthWithCurve(int nIndex,CVector &v,CCurve& curve);//根据一条时深曲线将剖面转换为深度
void ToDragFlat(int nIndex);
CScreenXY m_exchange;
CVector ViewC;
CString m_viewc;
CString m_input,m_xf,m_yf;
int ReadViewC();
double amin;
double amax;
CRect8 GetRect(int bIsColor);
int GetIsochronousSwing(double t0, double* data);//获得最近采样点的等时振幅
//curve为平面坐标曲线,要根据此曲线从pDimDT中插值DT对SEGY进行校正
//pDimDT中为校正量
//该函数仅对CSectionBase中指定的道进行校正 并不写SEGY文件头
//将校正后的数据写到fw中去
//pDimDT为二维曲面,当pDimDT为NULL时按deltValue校正
int CalibrateSegy(CFileSegy& fw, CCurve& curve, CDimension3D* pDimDT, double deltValue);
//读取并校正指定道,调用之前必须将指针定位到该道,pOneTrace中保存校正后的道数据
void CalibrateOneTrace(char* pOneTrace, double dt);
int ReadCoordinate(int posx, int posy);
};
inline CFileSegy* CSectionBase::GetIoFile(void)
{
return m_pfr;
}
inline CFileSegy::EDataType CSectionBase::GetFormatCode(void)
{
return (CFileSegy::EDataType)m_nFormatCode;
}
inline CCurve* CSectionBase::GetCurrentTraceCurve(void)
{
return pCurve;
}