⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xfile.h

📁 该程序是用vc开发的对动态数组进行管理的DLL
💻 H
字号:
 #ifndef  XFILE_H#define  XFILE_H#include <math.h>#include <stdio.h>#include <memory.h>#include <string.h>#include <stdlib.h>#include "cwp.h"#include "xstring.h"#define  enter ('\n')


/*


XFileSeis:
	2005.10.2:修改 D2 ,如果D2大于5,则说明D2的单位是m,所以要除以1000表示成km


*//*////////////////////////////////////////////////////////////////函数名称: 控制台输入输出类主要功能:  作    者: 徐云贵时    间: /////////////////////////////////////////////////////////////////*/class Xio{public:	//**********   standard input variable  ********************//	Xio &  operator >>( char* psz );	Xio &  operator >>( unsigned char* pusz );	Xio &  operator >>( signed char* pssz );	Xio &  operator >>( char& rch );	Xio &  operator >>( unsigned char& ruch );	Xio &  operator >>( signed char& rsch );	Xio &  operator >>( short& s );	Xio &  operator >>( unsigned short& us );	Xio &  operator >>( int& n );	Xio &  operator >>( unsigned int& un );	Xio &  operator >>( long& l );	Xio &  operator >>( unsigned long& ul );	Xio &  operator >>( float& f );	Xio &  operator >>( double& d );
	Xio &  operator >>( XString & xstr );	Xio &  operator <<( XString & xstr );	//**********   standard output variable  ********************//	Xio &  operator <<( char ch1  );	Xio &  operator <<( unsigned char uch  );	Xio &  operator <<( signed char sch  );	Xio &  operator <<( char* psz  );	Xio &  operator <<( unsigned char* pusz  );	Xio &  operator <<( signed char* pssz  );	Xio &  operator <<( short s  );	Xio &  operator <<( unsigned short us  );	Xio &  operator <<( int n  );	Xio &  operator <<( unsigned int un  );	Xio &  operator <<( long l  );	Xio &  operator <<( unsigned long ul  );	Xio &  operator <<( float f  );	Xio &  operator <<( double d  );	};extern Xio cio;/*///////////////////////////////////////////////////////////////////////////函数名称: 读写文件,可操作文本、二进制输入输出主要功能:  作    者: 徐云贵时    间: /////////////////////////////////////////////////////////////////////////////*/class XFile{protected:	FILE *fp;	FILE *FP();	char FileType[10];	char FileName[1000];
public:	XFile();	~XFile();
		//**********   Open file functions  ********************//	int		open( char *path, char * mode = "r");	int		openr(char *path);	int		openw(char *path);	int		openrb(char *path);	int		openwb(char *path);		//********* Read & Write ASCII File Function ***********//	XFile &  operator >>( char* psz );	XFile &  operator >>( unsigned char* pusz );	XFile &  operator >>( signed char* pssz );	XFile &  operator >>( char& rch );	XFile &  operator >>( unsigned char& ruch );	XFile &  operator >>( signed char& rsch );	XFile &  operator >>( short& s );	XFile &  operator >>( unsigned short& us );	XFile &  operator >>( int& n );	XFile &  operator >>( unsigned int& un );	XFile &  operator >>( long& l );	XFile &  operator >>( unsigned long& ul );	XFile &  operator >>( float& f );	XFile &  operator >>( double& d );	XFile &  operator >>( XString & xstr );	XFile &  operator <<( XString & xstr );		XFile &  operator <<( char ch1  );	XFile &  operator <<( unsigned char uch  );	XFile &  operator <<( signed char sch  );	XFile &  operator <<( char* psz  );	XFile &  operator <<( unsigned char* pusz  );	XFile &  operator <<( signed char* pssz  );	XFile &  operator <<( short s  );	XFile &  operator <<( unsigned short us  );	XFile &  operator <<( int n  );	XFile &  operator <<( unsigned int un  );	XFile &  operator <<( long l  );	XFile &  operator <<( unsigned long ul  );	XFile &  operator <<( float f  );	XFile &  operator <<( double d  );	bool     getline( char* psz ,int maxlen, char delim='\n');	
	int		 gettext(char *str);		
	//********* Read & Write bianry File Function ***********//	int		write(void *data,	int size);	int		read(void *data,	int size);	int		seek(long off,		int From);	int		toCur(long cur);	int		toEnd();	int		toBeg();	long	length();	long	tell();	int		rewind();	void	close();
};/*//////////////////////////////////////////////////////////////////////////函数名称: 读写文本文件类,有读、写方式操作主要功能:  作    者: 徐云贵时    间: ///////////////////////////////////////////////////////////////////////////*/class XFileAsc{public:	XFile xfile;	void  go(long n);
	int   openr(char *path);
	int   openw(char *path);	void  close();
	XFileAsc();	~XFileAsc();	// 打开方式	// read File into All kind of DataType	int   read( short *s ,			int len );	int   read( unsigned short *us ,int len );	int   read( int *n ,			int len );	int   read( unsigned int *un ,	int len );	int   read( long *l ,			int len );	int   read( unsigned long *ul ,	int len );	int   read( float *f ,			int len );	int   read( double *d ,			int len );	// write  All kind of DataType to File	int   write( short *s ,				int len,int nwid=10);	int   write( unsigned short *us ,	int len,int nwid=10 );	int   write( int *n ,				int len,int nwid=10);	int   write( unsigned int *un ,		int len,int nwid=10 );	int   write( long *l ,				int len,int nwid=10);	int   write( unsigned long *ul,		int len,int nwid=10 );	int   write( float *f ,				int len,int nwid=10 );	int   write( double *d ,			int len,int nwid=10 );


	XFileAsc&  operator >>( char* psz );	XFileAsc&  operator >>( unsigned char* pusz );	XFileAsc&  operator >>( signed char* pssz );	XFileAsc&  operator >>( char& rch );	XFileAsc&  operator >>( unsigned char& ruch );	XFileAsc&  operator >>( signed char& rsch );	XFileAsc&  operator >>( short& s );	XFileAsc&  operator >>( unsigned short& us );	XFileAsc&  operator >>( int& n );	XFileAsc&  operator >>( unsigned int& un );	XFileAsc&  operator >>( long& l );	XFileAsc&  operator >>( unsigned long& ul );	XFileAsc&  operator >>( float& f );	XFileAsc&  operator >>( double& d );	XFileAsc&  operator >>( XString & xstr );	XFileAsc&  operator <<( XString & xstr );		XFileAsc&  operator <<( char ch1  );	XFileAsc&  operator <<( unsigned char uch  );	XFileAsc&  operator <<( signed char sch  );	XFileAsc&  operator <<( char* psz  );	XFileAsc&  operator <<( unsigned char* pusz  );	XFileAsc&  operator <<( signed char* pssz  );	XFileAsc&  operator <<( short s  );	XFileAsc&  operator <<( unsigned short us  );	XFileAsc&  operator <<( int n  );	XFileAsc&  operator <<( unsigned int un  );	XFileAsc&  operator <<( long l  );	XFileAsc&  operator <<( unsigned long ul  );	XFileAsc&  operator <<( float f  );	XFileAsc&  operator <<( double d  );	bool     getline( char* psz ,int maxlen, char delim='\n');		int		 gettext(char *str);	
	int		toCur(long cur);	int		toEnd();	int		toBeg();	long	length();	long	tell();	int		rewind();};/*//////////////////////////////////////////////////////////////////////////函数名称: 读写二进制纯二维数据类,有读、写、覆盖三种方式操作主要功能:  作    者: 徐云贵时    间: ///////////////////////////////////////////////////////////////////////////*/class XFileBin {public:	XFileBin();	~XFileBin();	XFile xfile;				// 读写数据道,三种打开方式	int	  openr(char *path );	int	  openw(char *path );	void  close();
		int   read( char *s				,int len );	int   read( short *s			,int len );	int   read( unsigned short *us	,int len );	int   read( int *n				,int len );	int   read( unsigned int *un	,int len );	int   read( long *l				,int len );	int   read( unsigned long *ul	,int len );	int   read( float *f			,int len );	int   read( double *d			,int len );	int   write( char *s			,int len );	int   write( short *s			,int len );	int   write( unsigned short *us ,int len);	int   write( int *n				,int len );	int   write( unsigned int *un	,int len);	int   write( long *l			,int len );	int   write( unsigned long *ul	,int len );	int   write( float *f			,int len );	int   write( double *d			,int len );	
	
	int   write2(void* d			,int len);
	int   read2 (void* d			,int len);

	int	  toCur(long cur);
	void  go(long cur);
	int	  toEnd();
	int	  toBeg();
	long  length();
	long  tell();
	int	  rewind();
 };/*///////////////////////////////////////////////////////////////////////////函数名称: 读写二进制二维数据类,有segy,su,bin格式,有读、写、覆盖三种方式操作主要功能:  作    者: 徐云贵时    间:  ///////////////////////////////////////////////////////////////////////////*/class XFileSeis{public:	XFile 		xfile;		int			nFileType;	int         nConv;	char		FileName[1000];			
				// 保存文件名	char		EBC[3200];	char		ASC[3200];		XSegybhead	Bhead;	XSegyhead	Head;  	float		*Data;                       
				// 保存当前道数据	long		NT;                              
				// 文件总共道数	unsigned short	NS;                              
				// 文件采样点数	int			TimeEnd;	unsigned short	DT;                             
				// 采样采样间隔 (us)	short		BSize;                           
				// 文件卷头大小: 0:su/bin,3600:XSegy	short		HSize;                           
				// 道头大小    : 0:bin,240:su,XSegy	float		D2;                                
				// distance between trace	XSegyhead   *HEAD;				   
				// save all head 	float       **DATA;				   
				// save all data
	int         NTRead;

	float		*fTraceMax;		   
				// 每道数据的最大值
	float		fAllMax;
	float		fNormalAmp;

				XFileSeis();
				~XFileSeis();
	void		close();
	void		clear();
	
	int			openr(char* szName, char * szFileType,int conv=0, 
						unsigned short nSample=0,unsigned short inter=1000,float tD2=1.0f);
	int			openw(char* szName, char * szFileType,int conv=0,
						unsigned short nSample=0,unsigned short inter=1000,float tD2=1.0f);
	
	void		dispBhead();
	void		dispHead();	int			write(XSegybhead*);	int			write(XSegyhead*);	int			write(float*);	int			write(char*);
	void		write3600();	void		read(int index);	  	   
				// get data on trace number	void        read(int idxStart,int idxEnd);
	void		readAll();

	float       fMaxV,fMinV,fMaxV1,fMinV1;
		char *			asc();
	char *			ebc();
	XSegybhead*		bhead();
	XSegyhead*		head();
	float *			data();	
	float			d2();
	char *			filename();
	unsigned short	ns();
	unsigned short	dt();	long			nt();	
	void		NormalizeOnTrace(float Amp=1);	void		NormalizeOnAll(float Amp=1);
	void		RestoreOnTrace();		   	void		RestortOnAll();			   
}; //class XFile3D:public XFileSegy{};void			pcSegy_Bin(char *srcFile,char *desFile,unsigned short *pnum=NULL,unsigned short *inter=NULL, long *tnum=NULL,float *d2=NULL);void			wsSegy_Bin(char *srcFile,char *desFile,unsigned short *pnum=NULL,unsigned short *inter=NULL, long *tnum=NULL,float *d2=NULL);void			wsSu_Bin(char *srcFile,char *desFile,unsigned short *pnum=NULL,unsigned short *inter=NULL, long *tnum=NULL, float *d2=NULL);void			pcSu_Bin(char *srcFile,char *desFile,unsigned short *pnum=NULL,unsigned short *inter=NULL, long *tnum=NULL, float *d2=NULL);void			Bin_Bin(char *srcFile,char *desFile);	void			ASC_Bin(char *srcFile,char *desFile,long pnum=300);void			Bin_ASC(char *srcFile,char *desFile,long Enter=10);void			Bin_pcSegy(char *srcFile,char *desFile,unsigned short pnum ,unsigned short  inter=1000, float  d2=1.0f);void			Bin_wsSegy(char *srcFile,char *desFile,unsigned short pnum ,unsigned short  inter=1000, float  d2=1.0f);void			Bin_wsSu(char *srcFile,char *desFile,unsigned short  pnum ,unsigned short  inter=1000, float d2=1.0f);void			Bin_pcSu(char *srcFile,char *desFile,unsigned short  pnum ,unsigned short  inter=1000, float d2=1.0f);void			pcSegy_wsSegy(char *srcFile,char *desFile);void			wsSegy_pcSegy(char *srcFile,char *desFile);void			pcSegy_wsSu(char *srcFile,char *desFile);void			wsSu_pcSegy(char *srcFile,char *desFile);void			wsSegy_wsSu(char *srcFile,char *desFile);void			wsSu_wsSegy(char *srcFile,char *desFile);void			pcSu_wsSu(char *srcFile,char *desFile);void			wsSu_pcSu(char *srcFile,char *desFile);void			transBin(char *srcFile,char *desFile,long pnum,long tnum,int n=4);	 // n: 1 2 4 8,variable sizevoid			transAsc(char *srcFile,char *desFile,long pnum,long tnum);void			MergeBin_wsSegyShot(char *parFile);void			MergeASC_wsSegyShot(char *parFile);	/*   
	  parFile: content
	  4					  (files number)
	  AscFileName1		  (input file name)
	  AscFileName2		  (input file name)
	  AscFileName3		  (input file name)
	  AscFileName4		  (input file name)
	  SegyFileName		  (output file name)
	  pnum(np)			  (number of sample)
	  inter(dt)			  (interval of sample)
	  tnumshot(nt)		  (number of trace in every shot)
	  d2(d2)			  (distance between traces)
	  numshot			  (number of shot int every file)
	 */	//	Following is the function how to Pick information from File FullPathName.
	//	for example, a pathname is "e:\\vc\\CFileInfo.cpp"
	extern XString GetFilePath(XString strFileName);		//"e:\\vc"
	extern XString GetFileExtName(XString strFileName);	    //"cpp"
	extern XString GetFileNoExtName(XString strFileName);	//"e:\\vc\\CFileInfo"
	extern XString GetFileMainName(XString strFileName);	//"CFileInfo.cpp"
	extern XString GetFileCoreName(XString strFileName);	//"CFileInfo"
#endif //XFILE_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -