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.

133 lines
4.8 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文件操作类
//主要功能:
//
//程序编写: 2011-4-1
//
//
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include "DrawModel\ObjectSet.h"
#include "SeisTraceData.h"
#include "Texture.h"
#include "Mesh2D.h"
namespace NSeis
{
class CSeisLinePar
{
public:
CSeisLinePar();
enum EColorType
{
colTypeSeis252 = 1, //地震剖面颜色级别变密度颜色为252种
colTypeMesh = 2 //曲面颜色级别,为真彩色级
};
double Uniform(double a, double b)
{
//归一化振幅数据
a /= b;
a *= m_dScaleFactor; //为了设置颜色区间时方便,将其控制在(-100, 100内, 或不变
return a;
}
double m_dScaleFactor; //振幅放大因子在地震剖面中为100在MESH网格中为1
EColorType m_colorType;
EUniformType m_uniformType; //归一化类型
};
//存储一个地震剖面的振幅数据,该剖面来自于二三维数据体,与之前的CTraceData类相似
class AFX_EXT_CLASS CSeisLineData
{
public:
CSeisLineData(void);
~CSeisLineData(void);
//创建振幅保存数组为nCol道数据每道数据为nRow个采样点每个采样点字节长度根据类型获得
//内部按照列进行保存每列连续数据为nRow个
bool Create(CSize sz, CFileSegy::EDataType eDataType = CFileSegy::typeIbmFloat);
bool Create(int nRow, int nCol, CFileSegy::EDataType eDataType = CFileSegy::typeIbmFloat);
virtual void Clear();
bool CreateTexture(CTexture* pTex, CColorBase& cb, int nBPP);
bool ToMesh2D(CMesh2D& md);
bool CreateFormMesh2D(CMesh2D& md);
protected:
//返回的指针需要外部使用delete删除维数为剖面的行(x)列(y)数
unsigned char* CreateTexture(CColorBase& cb, int nBPP);
public:
int GetTotalBytes() { return m_traces[0]->GetBytesLength() * GetTraceCount(); } //获得数据的总字节数
int GetSampleCount() { return m_size.cx; } //每道数据的采样点个数
int GetTraceCount() { return m_size.cy; } //总道数
CFileSegy::EDataType GetDataType() { return m_eDataType; } //获得数据类型
EOrientation GetOrientation() { return m_eOrientation; }
void SetOrientation(EOrientation eo) { m_eOrientation = eo; }
inline CSize GetSize(void) { return m_size; }
inline void SetSize(CSize sz) { m_size = sz; } //设置行列数需要与add配合使用
inline void add( CSeisTraceData* td ) { m_traces += td; m_size.cy+=1; }
inline CSeisTraceData* operator[](int nCol) const { return m_traces[nCol]; }
inline CSeisTraceData* GetTrace(int nCol) const { return m_traces[nCol]; } //获得指定道数据指针
float GetValue(int nRow, int nCol); //获得指定行列的数据点(振幅值)
CSeisTraceDataInfo& GetTraceDataInfo(int nCol) { return m_traces[nCol]->GetDataInfo(); }
bool GetCurveCoordRC(CCurve& cv, bool bIsMaxRange); //获得所定义曲线的空间坐标
bool GetTraceCoordRC(int nTraceIndex, dfPoint& pt, bool bIsMaxRange); //获得指定道的坐标
bool GetCurveCoordXY(CCurve& cv, bool bIsMaxRange); //获得所定义曲线的空间坐标
bool GetTraceCoordXY(int nTraceIndex, dfPoint& pt, bool bIsMaxRange); //获得指定道的坐标
double GetMaxValue(int nCol) { return GetTraceDataInfo(nCol).m_dMaxValue;} //获得最大值, 0<=nRow<m_size.cx
void SetMaxValue(int nCol, double val) { GetTraceDataInfo(nCol).m_dMaxValue = val; }
double GetMinValue(int nCol) { return GetTraceDataInfo(nCol).m_dMinValue;} //获得最小值
void SetMinValue(int nCol, double val) { GetTraceDataInfo(nCol).m_dMinValue = val; }
double GetRMS(int nCol) { return GetTraceDataInfo(nCol).m_dRms; } //获得均方根值
void SetRMS(int nCol, double val) { GetTraceDataInfo(nCol).m_dRms = val; }
//根据道数据计算最大值、最小值、均方根值
void RestatDataInfo();
void EnableLock(bool bEnable) { m_bLock = bEnable; }
bool IsLock() { return m_bLock; }
void operator = (CSeisLineData& sd);
void Reversal(void); //反转道数据
//设置剖面显示的开始结束时间值
void SetTimeRange(TInterval<float>& range) { m_zRange = range; }
TInterval<float>& GetTimeRange() { return m_zRange; }
CCubeRange GetCubeRange(); //获得该剖面所涉及的最大最小线道号范围
void Serialize(CArchive& ar, const short &ver);
bool WriteMesh(LPCTSTR lpszFileName);
bool WriteTraceDataInfo(LPCTSTR lpszFileName); //写道统计信息
bool WriteSegy(LPCTSTR lpszFileName, unsigned short sample_interval = 1000);
void WriteSegyTrace(CFileSegy& fw, int nTraceIndex, unsigned short sample_interval, char* pTraceHeader=NULL);
void SetLinePar(CSeisLinePar& par) { m_sectionPar = par; }
CSeisLinePar& GetLinePar() { return m_sectionPar; }
protected:
NSet::TObjectSet<CSeisTraceData> m_traces; //道数据
CSize m_size; //行列数行cx每道数据采样点个数列cy总共多少道数据
bool m_bLock; //该剖面是否锁定,锁定后该剖面仅能显示、不能编辑
CFileSegy::EDataType m_eDataType; //数据类型
EOrientation m_eOrientation; //剖面类型,是主测线剖面、联络测线剖面,还是自定义线剖面
TInterval<float> m_zRange; //Z轴的开始、结束时间
CSeisLinePar m_sectionPar;
};
}//namespace