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.
kev/Drawer/SSBase/MxnFormat/SeisFileHeader.h

122 lines
4.2 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文件操作类
//主要功能:
// 操纵SegY文件的文件头及道头信息以获得相应参数信息
//程序编写: 2011-4-1
//
//
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include "rowcol.h"
#include "binaryposition.h"
namespace NSeis
{
//SegY格式结构/////////////////////////////////////////////////////////////////////
//
// | 文件头 | 第一道 | 第二道 | 第n道 |最后一道 |
// --------------------------------------------------------------------
// | 3200+400 | 240 | | 240 | | | 240 | |
// | 字节 | 字节 | 道数据 | 字节 | 道数据 | ....... | 字节 | 道数据 |
// | 文件头 | 道头 | | 道头 | | | 道头 | |
// --------------------------------------------------------------------
//
///////////////////////////////////////////////////////////////////////////////////
//SegY格式文件头,总共3600个字节有用的仅是后400个字节
//#define SGY_FILE_HEADER_LEN 3600
//#define SGY_TRACE_HEADER_LEN 240
class AFX_EXT_CLASS CSeisFileHeader
{
public:
CSeisFileHeader(void);
~CSeisFileHeader(void);
int ReadHeader(CFileSegy& fr);
void Initialize(void); //初始化下面定义的参数,必须在读取头数据以后
int line_num; /* (04-07)line number (only one line per reel) */
unsigned short sample_interval; /* (16-17)sample interval in micro secs for this reel */
unsigned short sample_num; /* (20-21)number of samples per trace for this reel */
short format_code; /* (24-25)data sample format code:
1 = floating point (4 bytes)
2 = fixed point (4 bytes)
3 = fixed point (2 bytes)
4 = fixed point w/gain code (4 bytes)
+ SEG-Y rev 1:
5 = IEEE float (4 bytes)
8 = signed char (1 byte)*/
short system_coor; /* (54-55)measurement system code: 1 = meters 2 = feet */
inline BYTE* GetBytes(int offset, int len){ return m_byHeader + offset; }
inline BYTE* GetHeader() { return m_byHeader; };
int GetFormatLength(); //获得一个采样点的字节长度必须在format_code初始化之后
void operator=(CSeisFileHeader& dbf);
protected:
BYTE m_byHeader[400];
};
class AFX_EXT_CLASS CSeisTraceInfo
{
public:
CSeisTraceInfo(void);
bool isUsable; //该道数据是否正确,(28-29)仅为1时才正确
unsigned short sample_interval; /* (116-117)sample interval in micro secs for this reel */
unsigned short sample_num; /* (114-115)number of samples per trace for this reel */
double m_dCoorScale; //(70-71)短整型,坐标缩放因子
bool m_bUseCoorScale; //是否使用坐标缩放因子进行坐标计算
short system_coor; //坐标单位: 1 = meters 2 = feet从文件头中获得需要外部指定
//当为feet时将自动转换为meters
CRowCol m_rowcol; //线号与道号inline=row, crossline=col
CPoint2D m_coor; //坐标,最终以米为单位保存,其它单位时在内部进行转换
};
//SegY格式的道头占有240个字节
class AFX_EXT_CLASS CSeisTraceHeader
{
public:
CSeisTraceHeader(void);
~CSeisTraceHeader(void);
int ReadHeader(CFileSegy& fr);
void Initialize(void); //初始化下面定义的参数,必须在读取头数据以后
CSeisTraceInfo& GetTraceInfo() { return traceInfo; }
int GetSampleNumber() { return traceInfo.sample_num; }
double GetSampleInterval() { return traceInfo.sample_interval; }
double GetScale(CBinaryPosition& bp);
BYTE* GetBytes(CBinaryPosition& bp);
inline BYTE* GetBytes(int offset, int len) { return m_byHeader + offset; }
inline BYTE* GetHeader() { return m_byHeader; };
void operator=(CSeisTraceHeader& dbf);
int Read(CFile& fr, const short& ver);
void Write(CFile& fw, const short& ver);
void Serialize(CArchive& ar, const short &ver);
void ClonePositon(CSeisTraceHeader& sth); //复制以下位置参数
//位置定义
CBinaryPosition m_bpx; //坐标位置X定义
CBinaryPosition m_bpy; //坐标位置Y定义
CBinaryPosition m_bpz; //坐标位置Z定义高程信息一般为无效只有用户设定后才能使用
CBinaryPosition m_bpRow; //线号位置定义
CBinaryPosition m_bpCol; //道号位置定义
CBinaryPosition m_bpScale; //缩放因子定义
protected:
BYTE m_byHeader[240];
CSeisTraceInfo traceInfo; //读取道头得到的信息
};
}
using namespace NSeis;