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.

95 lines
2.5 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读写类
//
//程序编写: 2008-11-09
//
//
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include "file64.h"
#if !defined(__FILE64_SEGY__)
#define __FILE64_SEGY__
//nFormatCode is
//1 = 4-byte IBM floating-point
//2 = 4-byte, two's complement integer
//3 = 2-byte, two's complement integer
//4 = 4-byte fixed-point with gain (obsolete)
//5 = 4-byte IEEE floating-point
//6 = Not currently used
//7 = Not currently used
//8 = 1-byte, two's complement integer
//CreateIoFile(...) parameter
namespace NFile64
{
#define FILE_DEFAULT 0
#define FILE_MAPPING 1
#define FILE_HTTP 2
class CFileSegy :
public CFile64
{
public:
CFileSegy(void);
virtual ~CFileSegy(void);
enum EDataType
{
typeError = 0, //错误类型
typeIbmFloat = 1, // 4-byte IBM floating-point
typeIbmLong = 2, // 4-byte, two's complement integer
typeIbmShort = 3, // 2-byte, two's complement integer
typeIbmGainLong = 4, // 4-byte fixed-point with gain (obsolete)
typeIeeFloat = 5, // IEEE floating-point
// 8-bit, integer
// 7 为了地震剖面格式中的扩展
typeChar = 8, // signed char (1 byte)
typeIbmUShort = 9, // 2-byte, two's complement integer
typeIeeShort = 10, //
typeIeeLong = 11, //
typeIeeDouble = 12, // IEEE双精度实数8字节
};
//针对地震剖面SEGY文件所做
static int SizeofDataType(EDataType dt); //获得数据类型的长度
static CString GetFormatString(EDataType code);
static EDataType GetFormatCode(CString name);
//目前仅生成CFileSegy或CFileSegyMapping对象
static CFileSegy* CreateIoFile(int nCreateMode = FILE_DEFAULT); //new一个新对象
double ReadBinary(EDataType dt, int IsPC); //读取一个数据
int ReadBinary(float * x, int num, EDataType dt, int IsSwap);
int ReadBinary(double* x, int num, EDataType dt, int IsSwap);
double GetBinary(BYTE *lpValue, EDataType dt, int IsSwap);
int GetBinary(BYTE *lpValue, EDataType dt, int IsSwap, void* toValue); //结果输出在toValue中返回0表示不成功
int WriteBinary(double v, EDataType dt, int IsSwap); //写一个数据
int WriteBinary(double *pv, int num, EDataType dt, int IsSwap);
long FloatToLong(double value);
};
};
using namespace NFile64;
//判断是否是HTTP形式的网络文件
extern bool IsURL(LPCTSTR name, DWORD *pdwServiceType=NULL);
inline long NFile64::CFileSegy::FloatToLong(double value)
{
if(value<0) return (long)(value-0.5);
return (long)(value+0.5);
}
#endif // !defined(__FILE64_SEGY__)