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.

112 lines
3.4 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 "TInterval.h"
#include "RowCol.h"
#include "SeisFileHeader.h"
namespace NSeis
{
//仅是为了使声明函数中的参数定义清晰,
#define OUT //标识其为输出参数
#define IN //标识其为输入参数
// 地震剖面元素ID号定义为了与其它图形元素不冲突设定其从200开始
enum ESeisID
{
idIndex2D = 200 , //2D地震剖面索引
idIndex3D //3D地震剖面索引
};
class AFX_EXT_CLASS CSeisIndexPoint
{
public:
CSeisIndexPoint(){posFile=-1;}
CPoint2D coor; //线道号对应的坐标
CRowCol rowcol; //线道号
__int64 posFile; //文件位置
bool operator == (CSeisIndexPoint& sp) const;
};
class AFX_EXT_CLASS CSeisSampleInfo
{
public:
CSeisSampleInfo();
//使用参数CSeisFileHeader对象初始化采样信息
void Initialize(CSeisFileHeader& fh);
/** @brief 获得总采样点个数 */
unsigned short GetTotalSampleNumber() { return sample_num; }
/** @brief 获得格式代码 */
CFileSegy::EDataType& GetFormatCode() { return dataType; }
/** @brief 获得采样间隔 */
float GetSampleInterval() { return sample_interval * 0.001f; }
/** @brief 获得一个采样点的字节长度 */
int GetOneSampleBytes() { return CFileSegy::SizeofDataType(dataType); }
/** @brief 获得一道数据的字节长度 */
int GetTotalSampleBytes() { return GetOneSampleBytes()*GetTotalSampleNumber(); }
void Write(CFile& fw, const short& ver);
int Read(CFile& fr, const short& ver);
void Serialize(CArchive& ar, const short &ver);
/////////////////////////////////////////////////////////////////////////////////////
//时间范围设置,缺省为全部
void InitRange();
float GetStartTime() { return m_dataRange.start * GetSampleInterval(); }
float GetStopTime() { return m_dataRange.stop * GetSampleInterval(); }
TInterval<int>& GetTimeRange() { return m_dataRange; }
TInterval<float> GetTimeRangeF();
//设置开始结束时间,这样读取时仅读取指定范围内的采样点,内部将转换为采样点
//在设置CSeisIndexLine2D索引后
void SetTimeRange(TInterval<float>& range); //参数为时间值,内部将转换为采样点索引号
void SetTimeRange(TInterval<int>& range); //参数为采样点索引号
void SetTimeRange(int start, int stop); //参数为采样点索引号
void SetTimeRange(float start, float stop); //参数为时间值
//是否是使用整道数据, 根据m_dataRange参数判断
bool IsFullyTraceData();
//获得显示样点数
unsigned short GetCustomSampleNumber() { return m_dataRange.width()+1; }
/** @brief 获得一道显示数据的字节长度 */
int GetCustomSampleBytes() { return GetOneSampleBytes()*GetCustomSampleNumber(); }
//剖面显示的开始结束时间,在使用时将根据采样点间隔转换为整采样点索引值,
//如果全部为0或小于0的数时剖面将按照全部显示
TInterval<int> m_dataRange; //采样点范围,>=0 <采样点总个数
////////////////////////////////////////////////////////////////////////////////////
//读写地震道数据时是否将字节顺序反转
BOOL IsSwap() { return m_bSwap; }
void EnableSwap(BOOL bEnable) { m_bSwap = bEnable; }
/////////////////////////////////////////////////////////////////////////////////////
/** @brief 采样间隔,按照微秒保存,使用时需要*0.001(转换为毫秒) */
unsigned short sample_interval;
unsigned short sample_num; //每道数据的采样点个数
CFileSegy::EDataType dataType; //道数据类型
protected:
BOOL m_bSwap; //读写SegY文件时是否反转字节
};
}//namespace
using namespace NSeis;