|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
//文件: SegY文件操作类
|
|
|
//主要功能:
|
|
|
//
|
|
|
//程序编写: 2011-4-1
|
|
|
//
|
|
|
//
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
namespace NCube
|
|
|
{
|
|
|
|
|
|
/*!\brief Raw binary data access. */
|
|
|
class AFX_EXT_CLASS CDataBuffer
|
|
|
{
|
|
|
public:
|
|
|
CDataBuffer(void);
|
|
|
~CDataBuffer(void);
|
|
|
|
|
|
inline bool IsEmpty() const;
|
|
|
inline int GetCount() const { return m_nSampleNum; }
|
|
|
inline int GetBytesPerSample() { return m_nSampleBytes; }
|
|
|
inline int GetBytesLength() { return m_nSampleNum * m_nSampleBytes; }
|
|
|
|
|
|
inline BYTE* GetData() { return m_pData; }
|
|
|
inline short* GetDataShort() { return (short*)GetData(); }
|
|
|
inline long * GetDataLong() { return (long*)GetData(); }
|
|
|
inline float* GetDataFloat() { return (float*)GetData(); }
|
|
|
inline char * GetDataChar() { return (char*)GetData(); }
|
|
|
inline double* GetDataDouble() { return (double*)GetData(); }
|
|
|
|
|
|
inline BYTE* GetData(int nIndex) {return m_pData + (nIndex*m_nSampleBytes);}//返回第nIndex个数据索引指针 0<nIndex<m_nSampleNum
|
|
|
|
|
|
CDataBuffer& operator=(CDataBuffer& dbf);
|
|
|
|
|
|
//绑定数据,并不自动释放已申请空间,将直接替换m_pData, 需要提前释放时可外部调用Clear
|
|
|
void Attach(BYTE* pData, int nSampleNum, int nSampleBytes);
|
|
|
BYTE* Detach(void); //返回数据指针,将内部置空
|
|
|
|
|
|
virtual void Create(int num, int samBytes);
|
|
|
virtual void Clear(void);
|
|
|
void Resize(int num, int samBytes, bool copydata=true);
|
|
|
void Zero(void); //设置数据为0
|
|
|
|
|
|
protected:
|
|
|
int m_nSampleBytes; //每个采样点的字节长度
|
|
|
int m_nSampleNum; //采样点个数
|
|
|
BYTE* m_pData; //数据存放指针
|
|
|
};
|
|
|
|
|
|
}
|
|
|
using namespace NCube; |