资源简介
该文件是读取segy格式文件的原码,采用c语言编写。
代码片段和文件信息
#include “stdafx.h“
#include “segy.h“
#include
#include
#include
#include
#include
#include
using namespace std;
void * SEGY_realloc (void* ptr size_t size size_t oldsize)
{
#ifdef MS_DOS
/* fix for missing realloc in MS VC6.0 */
void *new;
if (new=(void*)malloc(size))
{
memcpy(newptroldsize);
free(ptr);
ptr=new;
}
return new;
#else
return realloc(ptrsize);
#endif
}
class ShotPoint
{
public:
int X;
int Y;
int Trace;
ShotPoint() : X(0) Y(0) Trace(0) {}
ShotPoint(int NewX int NewY int NewTrace) : X(NewX) Y(NewY) Trace(NewTrace) {}
};
bool operator==(const ShotPoint& a const ShotPoint& b)
{
return (a.X == b.X) && (a.Y == b.Y);
}
bool operator<(const ShotPoint& a const ShotPoint& b)
{
if (a.X == b.X) return (a.Y < b.Y);
return a.X < b.X;
}
static void SwapWordByteOrder (char * data_array int word_count)
{
int i j;
char tmpchar;
for (i=0; i j = (i*4);
tmpchar = data_array[j+0];
data_array[j+0] = data_array[j+3];
data_array[j+3] = tmpchar;
tmpchar = data_array[j+2];
data_array[j+2] = data_array[j+1];
data_array[j+1] = tmpchar;
}
}
static void SwapNybbleByteOrder (char * data_array int nybble_count)
{
int i j;
char tmpchar;
for (i=0; i j = (i*2);
tmpchar = data_array[j+0];
data_array[j+0] = data_array[j+1];
data_array[j+1] = tmpchar;
}
}
static int ConvertBinary (void * data int size int count)
{
if (size == sizeof (short))
SwapNybbleByteOrder ((char *) data count);
else if (size != sizeof (char))
SwapWordByteOrder ((char *) data count);
return 0;
}
float * SegyReader::getSegyDataAndChar(SegyDim3s &dimchar *filename_buf)
{
int maxvals;
// Declare a dynamically allocated vector of IDs.
vector spArray;
// Iterator is used to loop through the vector.
vector::iterator spIterator;
/***********************/
/* Function‘s Body */
/***********************/
// Use AVS/Express function to map enviroment variables
FILE *infile;
struct segy_ebcdic_hdr ebcdic_hdr;
struct segy_reel_hdr reel_hdr;
struct segy_trace_hdr trace_hdr;
float *trace_vals;
float *vals *vals1;
int trace_count = 0;
int index;
float minx miny maxx maxy;
float intervall=0.0;
minx = miny = maxx = maxy = 0.0;
if (!strlen(filename_buf)) return NULL;
if ((infile = fopen(filename_buf “rb“)) == NULL) {
fprintf(stdout“ReadSegy: Cannot open segy file - %s\n“filename_buf);
return NULL;
}
fread(&ebcdic_hdr SEGY_EBCDIC_HDR_SIZE 1 infile);
fread(&reel_hdr SEGY_REEL_HDR_SIZE 1 infile);
ConvertBinary(&reel_hdr.job_id_number sizeof(int32_T) 1);
ConvertBinary(&reel_hdr.line_number sizeof(int32_T) 1);
ConvertBinary(&reel_hdr.reel_number sizeof(int32_T) 1);
ConvertBinary(&reel_hdr.traces_per_record sizeof(int16_t) 1);
Con
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1003 2004-04-07 10:31 segy读取原码\SgyReader\ReadMe.txt
文件 8913 2004-03-09 13:39 segy读取原码\SgyReader\segy.cpp
文件 3125 2004-03-09 13:39 segy读取原码\SgyReader\segy.h
文件 2028 2004-04-12 17:20 segy读取原码\SgyReader\SgyReader.cpp
文件 3498 2004-04-12 17:13 segy读取原码\SgyReader\SgyReader.dsp
文件 541 2004-04-12 17:13 segy读取原码\SgyReader\SgyReader.dsw
文件 50176 2005-03-03 09:36 segy读取原码\SgyReader\SgyReader.ncb
文件 53760 2005-03-03 09:36 segy读取原码\SgyReader\SgyReader.opt
文件 252 2004-04-12 17:25 segy读取原码\SgyReader\SgyReader.plg
文件 3945 2004-04-07 10:51 segy读取原码\SgyReader\SgyReader.vcproj
文件 213 2004-04-07 10:31 segy读取原码\SgyReader\stdafx.cpp
文件 195 2004-04-07 10:31 segy读取原码\SgyReader\stdafx.h
..AD... 0 2005-04-18 14:07 segy读取原码\SgyReader
文件 917 2004-04-07 10:31 segy读取原码\SgyReader.sln
..A..H. 9728 2004-04-07 15:37 segy读取原码\SgyReader.suo
..AD... 0 2005-04-18 14:06 segy读取原码
----------- --------- ---------- ----- ----
138512 17
评论
共有 条评论