1182 lines
33 KiB
C++
1182 lines
33 KiB
C++
#pragma warning( push ,0)
|
||
#include <cassert>
|
||
#include <algorithm>
|
||
#include "ObjWelllogWavefile.h"
|
||
#include "ObjWell.h"
|
||
#pragma warning( pop )
|
||
|
||
BEGIN_OSGDATAMODEL_NAMESPACE;
|
||
|
||
CObjWellLogWavefile::CObjWellLogWavefile()
|
||
{
|
||
m_ArrayNum=1;
|
||
isRun=false;
|
||
// SetIconName("icon/Logs.png");
|
||
isCorrDepth=0;
|
||
isCorrA1ZM=0;
|
||
isLoad=false;
|
||
}
|
||
|
||
CObjWellLogWavefile::~CObjWellLogWavefile()
|
||
{
|
||
|
||
}
|
||
QUuid CObjWellLogWavefile::GetTypeID()const
|
||
{
|
||
return GetClassID_WellLogWavefile();
|
||
}
|
||
|
||
void CObjWellLogWavefile::SetData(int i,int j,float *buffer)
|
||
{
|
||
int pos=i*waveinfo.TimeSamples+j;
|
||
CObjWellLog::SetData(pos,buffer);
|
||
}
|
||
double CObjWellLogWavefile::GetData(int i,int j,char *buffer)
|
||
{
|
||
float yy=-9999;
|
||
if(m_vProperty.size()>i) {
|
||
int pos=(int)(i*waveinfo.TimeSamples+j);
|
||
yy=CObjWellLog::GetData(acurveinfo.RepCode,(char *)&((char *)m_vProperty.m_vProperty)[pos*acurveinfo.CodeLen],acurveinfo.CodeLen);
|
||
}
|
||
return yy;
|
||
}
|
||
void CObjWellLogWavefile::SetData(float dep,int j,float *buffer)
|
||
{
|
||
if(dep>=waveinfo.StartDepth&&dep<=waveinfo.EndDepth) {
|
||
int i=(dep-waveinfo.StartDepth)/waveinfo.DepLevel+0.5;
|
||
SetData(i,j,buffer);
|
||
}
|
||
}
|
||
double CObjWellLogWavefile::GetData(float dep,int j,char *buffer)
|
||
{
|
||
if(dep>=waveinfo.StartDepth&&dep<=waveinfo.EndDepth) {
|
||
int i=(dep-waveinfo.StartDepth)/waveinfo.DepLevel+0.5;
|
||
double yy=GetData(i,j,buffer);
|
||
return yy;
|
||
}
|
||
else {
|
||
if(waveinfo.RepCode==REPR_STRING&&buffer) buffer[0]=0;
|
||
return -9999;
|
||
}
|
||
}
|
||
QString CObjWellLogWavefile::GetDescription()
|
||
{
|
||
if(!isRun)
|
||
{
|
||
CLogIO *logio=new CLogIO();
|
||
QString slfFileName=GetSlfFileName();
|
||
if(slfFileName.isEmpty()) return "";
|
||
if(!logio->Open(slfFileName.toStdString().c_str(),CSlfIO::modeRead))
|
||
{
|
||
delete logio;
|
||
return "";
|
||
}
|
||
QString name=GetName();
|
||
int i=logio->OpenWave(name.toStdString().c_str());
|
||
if(i<0) {
|
||
delete logio;
|
||
return "";
|
||
}
|
||
logio->GetWaveInfo(i,&waveinfo);
|
||
logio->CloseWave(i);
|
||
delete logio;
|
||
}
|
||
if(waveinfo.RepCode<1) waveinfo.RepCode=1;
|
||
if(waveinfo.RepCode>12) waveinfo.RepCode=12;
|
||
QString result="";
|
||
char buf[1000];
|
||
sprintf(buf,"对象类型:波列\n\
|
||
曲线名:%s\n\
|
||
曲线别名:%s\n\
|
||
曲线单位:%s\n\
|
||
单位别名:%s\n\
|
||
数据类型:%s\n\
|
||
字节长度:%d\n\
|
||
最小值:%g\n\
|
||
最大值:%g\n\
|
||
起始深度:%g\n\
|
||
终止深度:%g\n\
|
||
采样间隔:%g\n\
|
||
深度单位:%s\n\
|
||
缺省值:%g\n\
|
||
阵列数:%d\n\
|
||
起始时间:%g\n\
|
||
时间采样间隔:%g\n\
|
||
阵列采样样本点数:%d\n\
|
||
时间单位:%s\n\
|
||
阵列名称:%s\n",
|
||
waveinfo.Name,
|
||
waveinfo.AliasName,
|
||
waveinfo.Unit,//曲线单位%s,
|
||
waveinfo.AliasUnit,//单位别名%s,
|
||
Rep_STR[waveinfo.RepCode-1],//,
|
||
waveinfo.CodeLen,//,
|
||
waveinfo.MinValue,//最小值%g,
|
||
waveinfo.MaxValue,//最大值%g,
|
||
waveinfo.StartDepth,//起始深度%g,
|
||
waveinfo.EndDepth,//终止深度%g,
|
||
waveinfo.DepLevel,////采样间隔%g,
|
||
waveinfo.DepthUnit,//深度单位%g,
|
||
waveinfo.DefVal,//缺省值%g,
|
||
waveinfo.ArrayNum,//阵列数%d,
|
||
waveinfo.StartTime,//起始时间%g,
|
||
waveinfo.TimeLevel,//时间间隔%g,
|
||
waveinfo.TimeSamples,//阵列采样样本点数%d,
|
||
waveinfo.TimeUnit,//时间单位%s,
|
||
waveinfo.TimeName);//阵列名称%s
|
||
|
||
result.append(buf);
|
||
return result;
|
||
}
|
||
bool CObjWellLogWavefile::SaveToSLF()
|
||
{
|
||
if(m_ArrayNum<2) {
|
||
// bool m=HasModified();
|
||
// if(!m) return false;
|
||
int samplenum=m_vProperty.size();
|
||
if(!m_vMD.size()) return false;
|
||
if(samplenum<=0) return false;
|
||
if(m_SlfFileName=="") return true;
|
||
CLogIO * logio=new CLogIO();
|
||
if(!logio->Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeRead))
|
||
{
|
||
delete logio;
|
||
//AppendConsole(pai::log::PAI_ERROR,"SLF文件打开失败,请检查!");
|
||
return false;
|
||
}
|
||
|
||
int curveindex=logio->OpenWave(GetName().toStdString().c_str());
|
||
if(curveindex<0)
|
||
{
|
||
delete logio;
|
||
return false;
|
||
}
|
||
if(samplenum)logio->WriteWave(curveindex,m_vMD.m_vProperty[0],samplenum,(void*)(&m_vProperty.m_vProperty[0]));
|
||
delete logio;
|
||
// //qDebug()<<QString::fromStdString(GenTimeStamp())<<"数据写完成:"+GetName();
|
||
// SetModified(false,false);
|
||
return true;
|
||
}
|
||
else return false;
|
||
}
|
||
|
||
void CObjWellLogWavefile::SetisCorrDepth(bool IsCorrDepth)
|
||
{
|
||
isCorrDepth=IsCorrDepth;
|
||
}
|
||
void CObjWellLogWavefile::SetisCorrA1ZM(bool IsCorrA1ZM)
|
||
{
|
||
isCorrA1ZM=IsCorrA1ZM;
|
||
}
|
||
QVector<QPointF> BSplineFit(QVector<QPointF> discretePoints, bool closed, double stride = 0.01)
|
||
{
|
||
QVector<QPointF> fittingPoints;
|
||
for (int i = 0; i < (closed ? discretePoints.size() : discretePoints.size() - 1); i++)
|
||
{
|
||
QPointF xy[4];
|
||
xy[0] = (discretePoints[i] + 4 * discretePoints[(i + 1) % discretePoints.size()] + discretePoints[(i + 2) % discretePoints.size()]) / 6;
|
||
xy[1] = -(discretePoints[i] - discretePoints[(i + 2) % discretePoints.size()]) / 2;
|
||
xy[2] = (discretePoints[i] - 2 * discretePoints[(i + 1) % discretePoints.size()] + discretePoints[(i + 2) % discretePoints.size()]) / 2;
|
||
xy[3] = -(discretePoints[i] - 3 * discretePoints[(i + 1) % discretePoints.size()] + 3 * discretePoints[(i + 2) % discretePoints.size()] - discretePoints[(i + 3) % discretePoints.size()]) / 6;
|
||
for (double t = 0; t <= 1; t += stride)
|
||
{
|
||
QPointF totalPoints = QPointF(0, 0);
|
||
for (int j = 0; j < 4; j++) {
|
||
totalPoints += xy[j] * pow(t, j);
|
||
}
|
||
fittingPoints.push_back(totalPoints);
|
||
}
|
||
}
|
||
return fittingPoints;
|
||
}
|
||
//从slf加载数据
|
||
bool CObjWellLogWavefile::LoadFromSLF()
|
||
{
|
||
struct IN_OUT_MESSAGE
|
||
{
|
||
int nPad;//极板数//
|
||
int nPadZ;//极板子极板数据
|
||
int nSample;//每个极板元素(电扣)个数//
|
||
int Width;
|
||
int shift0;
|
||
char Name[40][64];
|
||
char A1PZ[64];
|
||
};
|
||
|
||
struct IN_OUT_MESSAGE msa[7]={
|
||
//STAR 1
|
||
{
|
||
6,1,24,360,0,
|
||
{"C_P1BTN","C_P2BTN","C_P3BTN","C_P4BTN","C_P5BTN","C_P6BTN"},
|
||
"P1AZ_STAR"
|
||
},
|
||
//CBIL 2
|
||
{
|
||
2,1,250,360,0,
|
||
{"C_BHTA","C_BHTT"},
|
||
"P1AZ_CBIL"
|
||
},
|
||
//EMI 3
|
||
{
|
||
6,1,25,360,0,
|
||
{"C_PAD1","C_PAD2","C_PAD3","C_PAD4","C_PAD5","C_PAD6"},
|
||
"P1AZ_EMI"
|
||
},
|
||
//XRMI 4
|
||
{
|
||
6,1,25,360,0,
|
||
{"C_XPAD1","C_XPAD2","C_XPAD3","C_XPAD4","C_XPAD5","C_XPAD6"},
|
||
"P1AZ_XRMI"
|
||
},
|
||
//FMI 5
|
||
{
|
||
16,4,12,360,12,
|
||
{"C_FCA1","C_FCA2","C_FCA3","C_FCA4","C_FCB1","C_FCB2","C_FCB3","C_FCB4","C_FCC1","C_FCC2","C_FCC3","C_FCC4","C_FCD1","C_FCD2","C_FCD3","C_FCD4"},
|
||
"C_P1AZ"
|
||
},
|
||
//FMS 6
|
||
{
|
||
4,1,16,360,12,
|
||
{"C_PAD1","C_PAD2","C_PAD3","C_PAD4"},
|
||
"P1AZ_FMS"
|
||
},
|
||
//EIWD KSZ 7
|
||
{
|
||
1,1,128,360,0,
|
||
{"C_RTW"}
|
||
}
|
||
};
|
||
if(m_SlfFileName=="") {
|
||
isLoad=false;
|
||
if(!key.isEmpty()&&IsMappingMem(key.toStdString().c_str())) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
key="";
|
||
}
|
||
return true;
|
||
}
|
||
if(isLoad) return true;
|
||
|
||
char tem[100];
|
||
QString name=GetName();
|
||
|
||
strcpy(tem,name.toStdString().c_str());
|
||
int fir=-1;
|
||
struct IN_OUT_MESSAGE *pMsa=NULL;
|
||
if(m_ArrayNum>1) {
|
||
for(int i=0;i<7;i++) {
|
||
for(int j=0;j<msa[i].nPad;j++){
|
||
if(strstr(msa[i].Name[j],tem)) {
|
||
fir=i;
|
||
pMsa=new struct IN_OUT_MESSAGE;
|
||
memmove(pMsa,&msa[i],sizeof(struct IN_OUT_MESSAGE));
|
||
break;
|
||
}
|
||
}
|
||
if(fir>=0) break;
|
||
}
|
||
if(fir<0) {
|
||
QStringList msa1=GetSimilarCurves(name);
|
||
if(msa1.size()>7) {
|
||
pMsa=new struct IN_OUT_MESSAGE;
|
||
fir=msa1[0].toInt();//image type
|
||
pMsa->nPad=msa1[1].toInt();//极板数//
|
||
pMsa->nPadZ=msa1[2].toInt();//极板子极板数据
|
||
pMsa->nSample=msa1[3].toInt();//每个极板元素(电扣)个数//
|
||
pMsa->Width=msa1[4].toInt();
|
||
pMsa->shift0=msa1[5].toInt();
|
||
for(int i=0;i<pMsa->nPad;i++) {
|
||
if(msa1.size()>6+i) strcpy(pMsa->Name[i],msa1[6+i].toStdString().c_str());
|
||
}
|
||
if(msa1.size()>6+pMsa->nPad)strcpy(pMsa->A1PZ,msa1[6+pMsa->nPad].toStdString().c_str());
|
||
}
|
||
}
|
||
}
|
||
if(fir<1) m_ArrayNum=1;
|
||
name=m_SlfFileName+GetName();
|
||
if(m_ArrayNum>1) {
|
||
name+="Array";
|
||
}
|
||
if(!key.isEmpty()&&name!=key&&IsMappingMem(key.toStdString().c_str()))
|
||
{
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
key="";
|
||
}
|
||
|
||
if(IsMappingMem(name.toStdString().c_str()))
|
||
{
|
||
// GetObjectEvent().OnDeAttchData(m_SlfFileName,GetName());
|
||
}
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
|
||
name=GetName();
|
||
|
||
CLogIO * logio=new CLogIO();
|
||
if(!logio->Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeRead))
|
||
{
|
||
delete logio;
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
return false;
|
||
}
|
||
int curveindex=logio->OpenWave(name.toStdString().c_str());
|
||
if(curveindex<0)
|
||
{
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
delete logio;
|
||
return false;
|
||
}
|
||
m_ObjectType=WAVE_OBJECT;
|
||
logio->GetWaveInfo(curveindex,&waveinfo);
|
||
Slf_WAVE BWAVEINFO=waveinfo;
|
||
if(m_ArrayNum>1) {
|
||
if(waveinfo.RepCode==REPR_CHAR) waveinfo.RepCode=REPR_UCHAR;
|
||
}
|
||
acurveinfo.RepCode=waveinfo.RepCode;
|
||
acurveinfo.CodeLen=waveinfo.CodeLen;
|
||
acurveinfo.DepLevel=waveinfo.DepLevel;
|
||
acurveinfo.StartDepth=waveinfo.StartDepth;
|
||
acurveinfo.EndDepth=waveinfo.EndDepth;
|
||
isRun=true;
|
||
|
||
int samplenum=(waveinfo.EndDepth-waveinfo.StartDepth)/waveinfo.DepLevel+1.5;
|
||
name=m_SlfFileName+GetName();
|
||
if(m_ArrayNum>1) {
|
||
name+="Array";
|
||
}
|
||
key=name;
|
||
int nbpp=waveinfo.SamplePoint;
|
||
int mlen=0;
|
||
int myWidth=0;
|
||
int chlen=0;
|
||
int nPadZ=0;
|
||
int myWidth1=waveinfo.SamplePoint;
|
||
int shift0=0;
|
||
if(m_ArrayNum>1) {
|
||
shift0=pMsa->shift0;
|
||
nPadZ=pMsa->nPadZ;
|
||
myWidth=pMsa->Width;
|
||
nbpp=pMsa->nSample;
|
||
m_ArrayNum=pMsa->nPad;
|
||
mlen=myWidth-m_ArrayNum*nbpp;//总盲区宽度
|
||
mlen/=m_ArrayNum;
|
||
if(mlen%2!=0) mlen+=1;
|
||
if(nPadZ<4) chlen=mlen/8;
|
||
else chlen=mlen/4;
|
||
if(chlen%2!=0) chlen+=1;
|
||
if(chlen==0) chlen=2;
|
||
// mlen=mlen-chlen;
|
||
mlen=m_ArrayNum*chlen/nPadZ;
|
||
if(mlen%2!=0) mlen++;
|
||
if(mlen>20) mlen=20;
|
||
if(chlen<4) chlen=4;
|
||
// chlen=(myWidth-(mlen*m_ArrayNum+nbpp*m_ArrayNum))/nPadZ;
|
||
int klen=pMsa->nPadZ*waveinfo.SamplePoint+mlen+pMsa->nPadZ*chlen;
|
||
myWidth1=klen*pMsa->nPad/pMsa->nPadZ;
|
||
}
|
||
else myWidth=waveinfo.SamplePoint;
|
||
int nlen=waveinfo.CodeLen*waveinfo.SamplePoint;
|
||
int reclen=waveinfo.CodeLen*myWidth*waveinfo.ArrayNum;
|
||
MappingMem(&m_Handle,(LPSTR*)&m_SharedMemory,3*sizeof(float)+sizeof(int)+reclen*(samplenum+1),key.toStdString().c_str());
|
||
if(!m_Handle||!m_SharedMemory) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
return false;
|
||
}
|
||
float *buffer=(float*)m_SharedMemory;
|
||
buffer[0]=waveinfo.StartDepth;
|
||
buffer[1]=waveinfo.EndDepth;
|
||
buffer[2]=waveinfo.DepLevel;
|
||
((int *)buffer)[3]=samplenum;
|
||
char *pchar=(char *)&buffer[4];
|
||
double laa=(double)reclen*(double)samplenum/waveinfo.CodeLen;
|
||
int num=reclen*samplenum/waveinfo.CodeLen;
|
||
float defval=-9999;
|
||
if(waveinfo.RepCode==REPR_CHAR||waveinfo.RepCode==REPR_UCHAR) defval=0;
|
||
else if(waveinfo.RepCode==REPR_SHORT||waveinfo.RepCode==REPR_USHORT) defval=0xffff;
|
||
|
||
for(int i=0;i<num;i++)
|
||
{
|
||
CObjWellLog::SetData(waveinfo.RepCode,&pchar[i*waveinfo.CodeLen],defval);
|
||
}
|
||
if(m_ArrayNum>1) //多极板曲线合并为一个图像数据
|
||
{
|
||
int klen=pMsa->nPadZ*waveinfo.SamplePoint+mlen+pMsa->nPadZ*chlen;
|
||
myWidth1=klen*pMsa->nPad/pMsa->nPadZ;
|
||
int xl=0;
|
||
int xladd=0;
|
||
for(int n=0;n<m_ArrayNum;n++) {
|
||
int IP4=n/nPadZ;//nPadZ个子极板为一组
|
||
int m1=n%nPadZ;
|
||
int mm=n%2;//nPadZ;
|
||
int mmm=m1/2;
|
||
if(mm==0) xl=1;//2个子极板间绘制一个细分隔线
|
||
else xl=0;
|
||
if(m1==0) xl=0;
|
||
int curveindex=logio->OpenWave(pMsa->Name[n]);
|
||
Slf_WAVE tWaveinfo;
|
||
char *bu=NULL;
|
||
if(curveindex>-1) {
|
||
logio->GetWaveInfo(curveindex,&tWaveinfo);
|
||
bu=new char[samplenum*tWaveinfo.ArrayNum*tWaveinfo.SamplePoint*tWaveinfo.CodeLen];
|
||
logio->ReadWave(curveindex,waveinfo.StartDepth,samplenum,(void *)bu);
|
||
if(tWaveinfo.CodeLen!=waveinfo.CodeLen) {//数据类型不同,转换一致
|
||
char *bu1=new char[samplenum*nlen];
|
||
for(int i=0;i<samplenum;i++) {
|
||
CObjWellLog::SetData(waveinfo.RepCode,&bu1[i*waveinfo.CodeLen],CObjWellLog::GetData(tWaveinfo.RepCode,(char *)&bu[i*tWaveinfo.CodeLen],tWaveinfo.CodeLen));
|
||
}
|
||
delete bu;
|
||
bu=bu1;
|
||
}
|
||
}
|
||
else {
|
||
bu=new char[samplenum*nlen];
|
||
memset(bu,0,samplenum*nlen);
|
||
}
|
||
int pos=0;
|
||
int len0=0;
|
||
if(fir==4)
|
||
{
|
||
if(isCorrDepth) {
|
||
if(m1==1) memmove(bu,&bu[3*nlen],(samplenum-3)*nlen);
|
||
else if(m1==2) memmove(bu,&bu[60*nlen],(samplenum-60)*nlen);
|
||
else if(m1==3) memmove(bu,&bu[63*nlen],(samplenum-63)*nlen);
|
||
}
|
||
xladd+=xl*chlen;
|
||
if(mm==0) xladd=0;
|
||
if(nPadZ==1) {
|
||
len0=IP4*klen*waveinfo.CodeLen+xladd*waveinfo.CodeLen+mm*nlen;
|
||
}
|
||
else if(nPadZ==2) {
|
||
len0=IP4*klen*waveinfo.CodeLen+mm*chlen*waveinfo.CodeLen+mm*nlen;
|
||
}
|
||
else {
|
||
len0=IP4*klen*waveinfo.CodeLen+mmm*(nlen*2+chlen*waveinfo.CodeLen);
|
||
}
|
||
for(int j=0;j<samplenum;j++) {
|
||
pos=j*reclen+len0;
|
||
if(nPadZ==1||nPadZ==2) {
|
||
memmove(&pchar[pos],&bu[j*nlen],nlen);
|
||
}
|
||
else {
|
||
for(int m=0;m<nbpp;m++)
|
||
{
|
||
if(n%2==0)
|
||
{
|
||
memmove(&pchar[pos+waveinfo.CodeLen*(m*2+1)],&bu[j*nlen+m*waveinfo.CodeLen],waveinfo.CodeLen);
|
||
}
|
||
else
|
||
{
|
||
memmove(&pchar[pos+m*2*waveinfo.CodeLen],&bu[j*nlen+m*waveinfo.CodeLen],waveinfo.CodeLen);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else {
|
||
len0=IP4*klen*waveinfo.CodeLen+xladd*waveinfo.CodeLen+mm*nlen;
|
||
for(int j=0;j<samplenum;j++) {
|
||
pos=j*reclen+len0;
|
||
memmove(&pchar[pos],&bu[j*nlen],nlen);
|
||
}
|
||
}
|
||
if(bu)delete bu;
|
||
}
|
||
int pos=0;
|
||
if(myWidth1!=myWidth) {
|
||
char *data1=new char[reclen];
|
||
int n=0;
|
||
float k1=(float)myWidth1/(float)(myWidth-myWidth1);
|
||
int num=myWidth-myWidth1;
|
||
for(int j=0;j<samplenum;j++) {
|
||
n=0;
|
||
for(int m=num-1;m>-1;m--)
|
||
{
|
||
pos=k1*m+0.5;
|
||
memmove(data1,&pchar[j*reclen+pos*waveinfo.CodeLen],(myWidth1-pos+n)*waveinfo.CodeLen);
|
||
memmove(&pchar[j*reclen+(pos+1)*waveinfo.CodeLen],data1,(myWidth1-pos+n++)*waveinfo.CodeLen);
|
||
}
|
||
/*
|
||
QVector<QPointF> va;
|
||
for(int t=0;t<nlen/waveinfo.CodeLen;t++)
|
||
{
|
||
float vall=0;
|
||
logio->GetData(waveinfo.RepCode,&pchar[j*reclen],&vall);
|
||
va.append(QPointF(vall,t));
|
||
}
|
||
QVector<QPointF> BSplineFit();
|
||
*/
|
||
}
|
||
delete data1;
|
||
}
|
||
}
|
||
else logio->ReadWave(curveindex,waveinfo.StartDepth,samplenum,(void *)pchar);
|
||
if(isCorrA1ZM)
|
||
{
|
||
char *pP1AZ=NULL;
|
||
int iP1AZ=-1;
|
||
Slf_CURVE aziminfo;
|
||
QString P1AZ="P1AZ";
|
||
if(pMsa) {
|
||
iP1AZ=logio->FindObjectName((char *)pMsa->A1PZ);
|
||
}
|
||
if(iP1AZ<0) {
|
||
if(pMsa&&pMsa->A1PZ[0]) P1AZ=pMsa->A1PZ;
|
||
QStringList azims=GetSimilarCurves(P1AZ);
|
||
if(azims.size()<0) azims=GetSimilarCurves("P1AZ");
|
||
|
||
foreach(QString cname,azims)
|
||
{
|
||
iP1AZ=logio->FindObjectName((char *)cname.toStdString().c_str());
|
||
if(iP1AZ>-1) {
|
||
P1AZ=cname;
|
||
iP1AZ=logio->OpenCurve((char *)P1AZ.toStdString().c_str());
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
if(iP1AZ>-1) {
|
||
logio->GetCurveInfo(iP1AZ,&aziminfo);
|
||
int samplenum1=(aziminfo.EndDepth-aziminfo.StartDepth)/aziminfo.DepLevel+1.5;
|
||
pP1AZ=new char[aziminfo.CodeLen*(samplenum1+1)];
|
||
logio->ReadCurve(iP1AZ,aziminfo.StartDepth,samplenum1,(void *)pP1AZ);
|
||
logio->CloseCurve(iP1AZ);
|
||
if(aziminfo.DepLevel!=waveinfo.DepLevel||aziminfo.StartDepth!=waveinfo.StartDepth||aziminfo.EndDepth!=waveinfo.EndDepth) {
|
||
char *pP1AZ1=new char[aziminfo.CodeLen*(samplenum+1)];
|
||
double val=0;
|
||
float dep=0,dep1=0,dep2=0;
|
||
int pos=0;
|
||
double val1=-9999,val2=-9999;
|
||
for(int i=0;i<samplenum;i++) {
|
||
dep=waveinfo.StartDepth+i*waveinfo.DepLevel;
|
||
pos=(dep-aziminfo.StartDepth)/aziminfo.DepLevel+0.5;
|
||
if(pos<0||pos>=samplenum1) {
|
||
val=-9999;
|
||
CObjWellLog::SetData(aziminfo.RepCode,(char *)&pP1AZ1[i*aziminfo.CodeLen],val);
|
||
continue;
|
||
}
|
||
dep1=aziminfo.StartDepth+pos*aziminfo.DepLevel;
|
||
val1=CObjWellLog::GetData(aziminfo.RepCode,(char *)&pP1AZ[pos*aziminfo.CodeLen],aziminfo.CodeLen);
|
||
if(pos>=samplenum1-1) {
|
||
CObjWellLog::SetData(aziminfo.RepCode,(char *)&pP1AZ1[i*aziminfo.CodeLen],val1);
|
||
continue;
|
||
}
|
||
dep2=aziminfo.StartDepth+(pos+1)*aziminfo.DepLevel;
|
||
val2=CObjWellLog::GetData(aziminfo.RepCode,(char *)&pP1AZ[(pos+1)*aziminfo.CodeLen],aziminfo.CodeLen);
|
||
if(val1==-9999||val2==-9999) {
|
||
val=-9999;
|
||
}
|
||
else val=(dep-dep1)/(dep2-dep1)*(val2-val1)+val1;
|
||
CObjWellLog::SetData(aziminfo.RepCode,(char *)&pP1AZ1[i*aziminfo.CodeLen],val);
|
||
}
|
||
delete pP1AZ;
|
||
pP1AZ=pP1AZ1;
|
||
}
|
||
}
|
||
if(pP1AZ){
|
||
AzmiuthCorrect(pchar,samplenum,myWidth,pP1AZ,aziminfo,shift0);
|
||
}
|
||
if(pP1AZ)delete pP1AZ;
|
||
}
|
||
else {
|
||
if(m_ArrayNum>1) AzmiuthCorrect(pchar,samplenum,myWidth,NULL,*(Slf_CURVE *)&waveinfo,shift0);
|
||
}
|
||
m_vMD.SetSize(3);
|
||
m_vMD.m_vProperty=(float *)m_SharedMemory;
|
||
int size=((int *)m_SharedMemory)[3];
|
||
m_vProperty.SetSize(size);
|
||
m_vProperty.m_vProperty=&m_vMD.m_vProperty[4];
|
||
|
||
if(m_vMD.size()>0){
|
||
m_TopDepth=m_vMD.m_vProperty[0];
|
||
m_BottomDepth=m_vMD.m_vProperty[1];
|
||
m_Rlev=m_vMD.m_vProperty[2];
|
||
}
|
||
m_ShiftTopDepth=-9999;
|
||
m_ShiftBottomDepth=-9999;
|
||
m_DepthOffset=0;
|
||
|
||
if(m_ArrayNum>1) {
|
||
waveinfo.ArrayNum=pMsa->nPad/pMsa->nPadZ;
|
||
waveinfo.SamplePoint=myWidth/(waveinfo.ArrayNum);
|
||
waveinfo.TimeSamples=myWidth;
|
||
}
|
||
if(pMsa) {
|
||
delete pMsa;
|
||
pMsa=NULL;
|
||
}
|
||
float val=0;
|
||
valMin.clear();
|
||
valMax.clear();
|
||
valMin.resize((waveinfo.SamplePoint)*waveinfo.ArrayNum);
|
||
valMax.resize((waveinfo.SamplePoint)*waveinfo.ArrayNum);
|
||
for(int j=0;j<(waveinfo.SamplePoint)*waveinfo.ArrayNum;j++) {
|
||
valMin[j]=999999999;
|
||
valMax[j]=-99999999;
|
||
}
|
||
char buf[200];
|
||
for(int i=0;i<samplenum;i++) {
|
||
for(int j=0;j<waveinfo.SamplePoint*waveinfo.ArrayNum;j++)
|
||
{
|
||
val=GetData(i,j,buf);
|
||
if(val==0||val==-9999||val==-999.25||val==-99999||val==-32767||val==32767) continue;
|
||
if(_isnan(val)||!_finite(val)) continue;
|
||
if(valMax[j]<val)valMax[j]=val;
|
||
if(valMin[j]>val)valMin[j]=val;
|
||
}
|
||
}
|
||
if(waveinfo.MaxValue==-50||waveinfo.MinValue==50||fabs(waveinfo.MaxValue)<1e-6||waveinfo.MinValue<1e-6||waveinfo.MaxValue==-99999||waveinfo.MaxValue==-9999||waveinfo.MinValue==999999||waveinfo.MinValue==999999||waveinfo.MinValue==99999||waveinfo.MinValue==99999||waveinfo.MinValue==-9999)
|
||
{
|
||
float valmin=99999;
|
||
float valmax=-99999;
|
||
for(int j=0;j<waveinfo.SamplePoint*waveinfo.ArrayNum;j++) {
|
||
if(valmin>valMax[j]) valmin=valMax[j];
|
||
if(valmin>valMin[j]) valmin=valMin[j];
|
||
if(valmax<valMin[j]) valmin=valMin[j];
|
||
if(valmax<valMax[j]) valmax=valMax[j];
|
||
}
|
||
waveinfo.MaxValue=valmax;
|
||
waveinfo.MinValue=valmin;
|
||
BWAVEINFO.MaxValue=valmax;
|
||
BWAVEINFO.MinValue=valmin;
|
||
logio->SetWaveInfo(curveindex,&BWAVEINFO);
|
||
}
|
||
logio->Clear();
|
||
delete logio;
|
||
isLoad=true;
|
||
// SetModified(false,false);
|
||
// GetObjectEvent().OnRefreshData(GetSlfFileName(),GetName(),this);
|
||
return true;
|
||
}
|
||
void CObjWellLogWavefile::DepthAlign(char *mr,int num,int pad,int ToolType)
|
||
{
|
||
// Star:2、4、6极板深度上移0.088392米
|
||
// EMI:2、4、6极板深度上移0.062米
|
||
// FMI:2、4、6、8极板深度上移0.14478米
|
||
//// need change
|
||
int BtnPerPad=24;
|
||
float vv;
|
||
switch(ToolType)
|
||
{
|
||
case 0: // Star-II deltaZ=0.3" deltaH=3.41"
|
||
BtnPerPad=24;
|
||
//电扣Z方向:BUTZ =/ 0, -.3, 0, -.3, 0, -.3, 0, -.3, 0, -.3, 0, -.3, 0, -.3, 0, -.3, 0,-.3, 0, -.3, 0, -.3, 0, -.3 /
|
||
//if(pad%2==0)//电扣深度对齐,第偶数个电扣需上提0.3",即0.00762m,相当于3倍的采样间隔(3*0.00254)
|
||
{
|
||
for(int btn=0; btn<BtnPerPad;btn+=1)
|
||
{
|
||
if(btn%2==0)
|
||
{
|
||
for(int lop=0;lop<3;lop++)
|
||
{
|
||
for(int y=0;y<num+3; y++)
|
||
{
|
||
memmove(&mr[(y*BtnPerPad+btn)*waveinfo.CodeLen],&mr[((y+1)*BtnPerPad+btn)*waveinfo.CodeLen],waveinfo.CodeLen);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
//极板Z方向:PADZ = / 0, -3.48, 0, -3.48, 0, -3.48 /
|
||
// 1 3 5 pad ;
|
||
if(pad%2==1)//极板深度对齐,2、4、6(第1、3、5)号极板深度需要上提3.48",即0.088392m,相当于34.8倍的采样间隔(34.8*0.00254),此处用34不太合适
|
||
{
|
||
for(int btn=0;btn<BtnPerPad;btn++)
|
||
{
|
||
for(int lop=0;lop<34;lop++)
|
||
{
|
||
for(int y=0;y<num+34;y++) memmove(&mr[(y*BtnPerPad+btn)*waveinfo.CodeLen],&mr[((y+1)*BtnPerPad+btn)*waveinfo.CodeLen],waveinfo.CodeLen);
|
||
}
|
||
}
|
||
}
|
||
// 0 2 4 pad ;电扣顺序倒置 放到图像生成时处理,为了保证和logview输出的预处理结果一致、对比
|
||
/*if(pad%2==0)
|
||
{
|
||
for(int btn=0;btn<BtnPerPad/2;btn++)
|
||
{
|
||
MyDepthProgress.SetDepth(btn,1);
|
||
for(int y=0;y<num;y++)
|
||
{
|
||
vv=mr[y*BtnPerPad+btn];
|
||
mr[y*BtnPerPad+btn]=mr[y*BtnPerPad+BtnPerPad-btn-1];
|
||
mr[y*BtnPerPad+BtnPerPad-btn-1]=vv;
|
||
}
|
||
}
|
||
}*/
|
||
break;
|
||
case 4://1: // FMI deltaZ=0.3" deltaH=5.7"
|
||
BtnPerPad=12;
|
||
//上排钮扣电极:0、2、4、6、。。。11
|
||
//下排钮扣电极:1,3,5,7.。。23
|
||
//下排钮扣电极需上提0.3''
|
||
if(pad%2==1)//电扣Z方向:BUTZ =/ 0, -.3, 0, -.3, 0, -.3, 0, -.3, 0, -.3, 0, -.3, 0, -.3, 0, -.3, 0,-.3, 0, -.3, 0, -.3, 0, -.3 /
|
||
{
|
||
for(int btn=0; btn<BtnPerPad;btn++)
|
||
{
|
||
for(int lop=0;lop<3;lop++)
|
||
{
|
||
for(int y=0;y<num-lop-1; y++)
|
||
{
|
||
memmove(&mr[(y*BtnPerPad+btn)*waveinfo.CodeLen],&mr[((y+1)*BtnPerPad+btn)*waveinfo.CodeLen],waveinfo.CodeLen);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
//极板Z方向:PADZ = / 0, -5.7, 0, -5.7, 0, -5.7, 0, -5.7 / 副极板需上提5.7
|
||
if((pad/2)%2==1)
|
||
{
|
||
for(int btn=0; btn<BtnPerPad;btn++)
|
||
{
|
||
for(int lop=0;lop<57;lop++)
|
||
{
|
||
for(int y=0;y<num+57; y++)
|
||
{
|
||
memmove(&mr[(y*BtnPerPad+btn)*waveinfo.CodeLen],&mr[((y+1)*BtnPerPad+btn)*waveinfo.CodeLen],waveinfo.CodeLen);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
case 2: // EMI deltaZ=0.3" deltaH=2.7"
|
||
case 3://XRMI
|
||
BtnPerPad=25;
|
||
//1\3\5奇数号极板电扣Z方向: BUTZ =/ -.3, 0, -.3, 0, -.3, 0, -.3, 0, -.3, 0, -.3, 0, -.3, 0, -.3, 0,-.3, 0, -.3, 0, -.3, 0, -.3,0, -.3 /
|
||
if(pad%2==0)
|
||
{
|
||
for(int btn=0; btn<BtnPerPad;btn+=1)
|
||
{
|
||
if(btn%2==0)
|
||
{
|
||
for(int lop=0;lop<3;lop++)
|
||
{
|
||
for(int y=0;y<num+3; y++)
|
||
{
|
||
memmove(&mr[(y*BtnPerPad+btn)*waveinfo.CodeLen],&mr[((y+1)*BtnPerPad+btn)*waveinfo.CodeLen],waveinfo.CodeLen);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
//2\4\6偶数号极板电扣Z方向:BUTZ =/ 0, -.3, 0, -.3, 0, -.3, 0, -.3, 0, -.3, 0, -.3, 0, -.3, 0, -.3, 0,-.3, 0, -.3, 0, -.3, 0, -.3,0 /
|
||
if(pad%2==1)
|
||
{
|
||
for(int btn=0; btn<BtnPerPad; btn+=1)
|
||
{
|
||
if(btn%2==0)
|
||
{
|
||
for(int lop=0;lop<3;lop++)
|
||
{
|
||
for(int y=0;y<num+3;y++) memmove(&mr[(y*BtnPerPad+btn)*waveinfo.CodeLen],&mr[((y+1)*BtnPerPad+btn)*waveinfo.CodeLen],waveinfo.CodeLen);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
// 1 3 5 pad ;
|
||
if(pad%2==1)
|
||
{
|
||
for(int btn=0;btn<BtnPerPad;btn++)
|
||
{
|
||
for(int lop=0;lop<27;lop++)
|
||
{
|
||
for(int y=0;y<num+27;y++) memmove(&mr[(y*BtnPerPad+btn)*waveinfo.CodeLen],&mr[((y+1)*BtnPerPad+btn)*waveinfo.CodeLen],waveinfo.CodeLen);
|
||
}
|
||
}
|
||
}
|
||
// 0 2 4 pad ;电扣顺序倒置 放到图像生成时处理
|
||
/* if(pad%2==0)
|
||
{
|
||
for(int btn=0;btn<BtnPerPad/2;btn++)
|
||
{
|
||
for(int y=0;y<num;y++)
|
||
{
|
||
vv=mr[y*BtnPerPad+btn];
|
||
mr[y*BtnPerPad+btn]=mr[y*BtnPerPad+BtnPerPad-btn-1];
|
||
mr[y*BtnPerPad+BtnPerPad-btn-1]=vv;
|
||
}
|
||
}
|
||
}
|
||
*/
|
||
break;
|
||
case 5://3: // FMS4 deltaZ=0.4" , 2 rows in earch pad
|
||
BtnPerPad=16;
|
||
for(int btn=0;btn<BtnPerPad;btn++)
|
||
{
|
||
if(btn%2==0)
|
||
{
|
||
for(int lop=0;lop<4;lop++)
|
||
{
|
||
for(int y=0;y<num-1;y++) memmove(&mr[(y*BtnPerPad+btn)*waveinfo.CodeLen],&mr[((y+1)*BtnPerPad+btn)*waveinfo.CodeLen],waveinfo.CodeLen);
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
void CObjWellLogWavefile::HorizMirror(float *mr,int Row,int Col)
|
||
{
|
||
int mcol;
|
||
float tmp;
|
||
if(Col%2==0){
|
||
mcol=Col/2;
|
||
}
|
||
else
|
||
{
|
||
mcol=(Col-1)/2;
|
||
}
|
||
for(int i=0; i<Row; i++)
|
||
{
|
||
for(int j=0; j<mcol; j++) {
|
||
tmp=mr[i*Col+j];
|
||
mr[i*Col+j]=mr[i*Col+Col-j-1];
|
||
mr[i*Col+Col-j-1]=tmp;
|
||
}
|
||
}
|
||
}
|
||
|
||
//----------------------------------------------------------------------------
|
||
void CObjWellLogWavefile::AzmiuthCorrect(char *mr,int Row,int Col,char *p1az,Slf_CURVE &curveinfo,int shift0)
|
||
{
|
||
float detaz=Col/360.0;
|
||
char *vbuf=new char[512*curveinfo.CodeLen];
|
||
float p1az0=0.0;
|
||
int ashift;
|
||
double val;
|
||
int cordlen=waveinfo.CodeLen;
|
||
if(!p1az) {
|
||
for(int i=0; i<Row; i++)
|
||
{
|
||
ashift=shift0;
|
||
if(ashift<=1 || ashift>=Col-1) continue;
|
||
memmove(vbuf,&mr[i*Col*cordlen+Col*cordlen-ashift*cordlen],cordlen*ashift);
|
||
memmove(&mr[(i*Col+ashift)*cordlen],&mr[i*Col*cordlen],cordlen*(Col-ashift));
|
||
memmove(&mr[i*Col*cordlen],vbuf,cordlen*ashift);
|
||
}
|
||
}
|
||
else {
|
||
for(int i=0; i<Row; i++)
|
||
{
|
||
val=CObjWellLog::GetData((int)curveinfo.RepCode,&p1az[i*curveinfo.CodeLen],(int)curveinfo.CodeLen);
|
||
if(val<0) ashift=val+360.0;
|
||
else ashift=val;
|
||
ashift=ashift%360;
|
||
ashift=detaz*ashift;
|
||
if(isCorrA1ZM) ashift+=shift0;
|
||
else ashift=shift0;
|
||
if(ashift<=1 || ashift>=Col-1) continue;
|
||
memmove(vbuf,&mr[i*Col*cordlen+Col*cordlen-ashift*cordlen],cordlen*ashift);
|
||
memmove(&mr[(i*Col+ashift)*cordlen],&mr[i*Col*cordlen],cordlen*(Col-ashift));
|
||
memmove(&mr[i*Col*cordlen],vbuf,cordlen*ashift);
|
||
}
|
||
}
|
||
delete vbuf;
|
||
}
|
||
|
||
void CObjWellLogWavefile::SetArrayNum(int ArrayNum)
|
||
{
|
||
if(ArrayNum!=m_ArrayNum)
|
||
{
|
||
isLoad=false;
|
||
m_ArrayNum=ArrayNum;
|
||
LoadFromSLF();
|
||
}
|
||
}
|
||
void CObjWellLogWavefile::GetValidMDProperty( PFLOATPROPERTY &vMD,PFLOATPROPERTY &vProperty,float sdep,float edep)
|
||
{
|
||
bool ret=0;
|
||
if(key.isEmpty()) ret=0;
|
||
else if(!IsMappingMem(key.toStdString().c_str()))ret=LoadFromSLF();
|
||
else
|
||
{
|
||
if(m_SharedMemory){
|
||
ret=true;
|
||
vMD.m_vProperty=(float *)m_SharedMemory;
|
||
if(!GetName().isEmpty()&&!m_SlfFileName.isEmpty()&&vMD.m_vProperty)
|
||
{
|
||
CLogIO * logio=new CLogIO();
|
||
if(logio->Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeRead))
|
||
{
|
||
int curveindex=logio->OpenWave(GetName().toStdString().c_str());
|
||
if(curveindex>-1)
|
||
{
|
||
// logio->GetWaveInfo(curveindex,&waveinfo);
|
||
}
|
||
}
|
||
delete logio;
|
||
int samplenum=(waveinfo.EndDepth-waveinfo.StartDepth)/waveinfo.DepLevel+1.5;
|
||
int samplenum1=(m_vMD.m_vProperty[1]-m_vMD.m_vProperty[0])/m_vMD.m_vProperty[2]+1.5;
|
||
if(samplenum1==samplenum){
|
||
m_vMD.m_vProperty[0]=waveinfo.StartDepth;
|
||
m_vMD.m_vProperty[1]=waveinfo.EndDepth;
|
||
m_vMD.m_vProperty[2]=waveinfo.DepLevel;
|
||
}
|
||
else {
|
||
isLoad=false;
|
||
LoadFromSLF();
|
||
vMD.m_vProperty=(float *)m_SharedMemory;
|
||
m_vProperty.m_vProperty=&m_vMD.m_vProperty[4];
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
struct IN_OUT_MESSAGE
|
||
{
|
||
int nPad;//极板数//
|
||
int nPadZ;//极板子极板数据
|
||
int nSample;//每个极板元素(电扣)个数//
|
||
int Width;
|
||
int shift0;
|
||
char Name[40][64];
|
||
char A1PZ[64];
|
||
};
|
||
|
||
struct IN_OUT_MESSAGE msa[7]={
|
||
//STAR 1
|
||
{
|
||
6,1,24,360,0,
|
||
{"C_P1BTN","C_P2BTN","C_P3BTN","C_P4BTN","C_P5BTN","C_P6BTN"},
|
||
"P1AZ_STAR"
|
||
},
|
||
//CBIL 2
|
||
{
|
||
2,1,250,360,0,
|
||
{"C_BHTA","C_BHTT"},
|
||
"P1AZ_CBIL"
|
||
},
|
||
//EMI 3
|
||
{
|
||
6,1,25,360,0,
|
||
{"C_PAD1","C_PAD2","C_PAD3","C_PAD4","C_PAD5","C_PAD6"},
|
||
"P1AZ_EMI"
|
||
},
|
||
//XRMI 4
|
||
{
|
||
6,1,25,360,0,
|
||
{"C_XPAD1","C_XPAD2","C_XPAD3","C_XPAD4","C_XPAD5","C_XPAD6"},
|
||
"P1AZ_XRMI"
|
||
},
|
||
//FMI 5
|
||
{
|
||
16,4,12,360,12,
|
||
{"C_FCA1","C_FCA2","C_FCA3","C_FCA4","C_FCB1","C_FCB2","C_FCB3","C_FCB4","C_FCC1","C_FCC2","C_FCC3","C_FCC4","C_FCD1","C_FCD2","C_FCD3","C_FCD4"},
|
||
"C_P1AZ"
|
||
},
|
||
//FMS 6
|
||
{
|
||
4,1,16,360,12,
|
||
{"C_PAD1","C_PAD2","C_PAD3","C_PAD4"},
|
||
"P1AZ_FMS"
|
||
},
|
||
//EIWD KSZ 7
|
||
{
|
||
1,1,128,360,0,
|
||
{"C_RTW"}
|
||
}
|
||
};
|
||
if(!m_SlfFileName.isEmpty())
|
||
{
|
||
char tem[100];
|
||
QString name=GetName();
|
||
|
||
strcpy(tem,name.toStdString().c_str());
|
||
int fir=-1;
|
||
struct IN_OUT_MESSAGE *pMsa=NULL;
|
||
if(m_ArrayNum>1) {
|
||
for(int i=0;i<7;i++) {
|
||
for(int j=0;j<msa[i].nPad;j++){
|
||
if(strstr(msa[i].Name[j],tem)) {
|
||
fir=i;
|
||
pMsa=new struct IN_OUT_MESSAGE;
|
||
memmove(pMsa,&msa[i],sizeof(struct IN_OUT_MESSAGE));
|
||
break;
|
||
}
|
||
}
|
||
if(fir>=0) break;
|
||
}
|
||
if(fir<0) {
|
||
QStringList msa1=GetSimilarCurves(name);
|
||
if(msa1.size()>7) {
|
||
pMsa=new struct IN_OUT_MESSAGE;
|
||
fir=msa1[0].toInt();//image type
|
||
pMsa->nPad=msa1[1].toInt();//极板数//
|
||
pMsa->nPadZ=msa1[2].toInt();//极板子极板数据
|
||
pMsa->nSample=msa1[3].toInt();//每个极板元素(电扣)个数//
|
||
pMsa->Width=msa1[4].toInt();
|
||
pMsa->shift0=msa1[5].toInt();
|
||
for(int i=0;i<pMsa->nPad;i++) {
|
||
if(msa1.size()>6+i) strcpy(pMsa->Name[i],msa1[6+i].toStdString().c_str());
|
||
}
|
||
if(msa1.size()>6+pMsa->nPad)strcpy(pMsa->A1PZ,msa1[6+pMsa->nPad].toStdString().c_str());
|
||
}
|
||
}
|
||
}
|
||
if(fir<1) m_ArrayNum=1;
|
||
name=m_SlfFileName+GetName();
|
||
if(m_ArrayNum>1) {
|
||
name+="Array";
|
||
}
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
|
||
name=GetName();
|
||
|
||
CLogIO * logio=new CLogIO();
|
||
if(logio->Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeRead))
|
||
{
|
||
int curveindex=logio->OpenWave(name.toStdString().c_str());
|
||
if(curveindex>-1)
|
||
{
|
||
m_ObjectType=WAVE_OBJECT;
|
||
logio->GetWaveInfo(curveindex,&waveinfo);
|
||
if(m_ArrayNum>1) {
|
||
if(waveinfo.RepCode==REPR_CHAR) waveinfo.RepCode=REPR_UCHAR;
|
||
}
|
||
acurveinfo.RepCode=waveinfo.RepCode;
|
||
acurveinfo.CodeLen=waveinfo.CodeLen;
|
||
acurveinfo.DepLevel=waveinfo.DepLevel;
|
||
acurveinfo.StartDepth=waveinfo.StartDepth;
|
||
acurveinfo.EndDepth=waveinfo.EndDepth;
|
||
isRun=true;
|
||
|
||
int samplenum=(waveinfo.EndDepth-waveinfo.StartDepth)/waveinfo.DepLevel+1.5;
|
||
name=m_SlfFileName+GetName();
|
||
if(m_ArrayNum>1) {
|
||
name+="Array";
|
||
}
|
||
key=name;
|
||
int nbpp=waveinfo.SamplePoint;
|
||
int mlen=0;
|
||
int myWidth=0;
|
||
int chlen=0;
|
||
int nPadZ=0;
|
||
int myWidth1=waveinfo.SamplePoint;
|
||
int shift0=0;
|
||
if(m_ArrayNum>1) {
|
||
shift0=pMsa->shift0;
|
||
nPadZ=pMsa->nPadZ;
|
||
myWidth=pMsa->Width;
|
||
nbpp=pMsa->nSample;
|
||
m_ArrayNum=pMsa->nPad;
|
||
mlen=myWidth-m_ArrayNum*nbpp;//总盲区宽度
|
||
mlen/=m_ArrayNum;
|
||
if(mlen%2!=0) mlen+=1;
|
||
if(nPadZ<4) chlen=mlen/8;
|
||
else chlen=mlen/4;
|
||
if(chlen%2!=0) chlen+=1;
|
||
if(chlen==0) chlen=2;
|
||
mlen=m_ArrayNum*chlen/nPadZ;
|
||
if(mlen%2!=0) mlen++;
|
||
if(mlen>20) mlen=20;
|
||
if(chlen<4) chlen=4;
|
||
int klen=pMsa->nPadZ*waveinfo.SamplePoint+mlen+pMsa->nPadZ*chlen;
|
||
myWidth1=klen*pMsa->nPad/pMsa->nPadZ;
|
||
}
|
||
else myWidth=waveinfo.SamplePoint;
|
||
int nlen=waveinfo.CodeLen*waveinfo.SamplePoint;
|
||
int reclen=waveinfo.CodeLen*myWidth*waveinfo.ArrayNum;
|
||
MappingMem(&m_Handle,(LPSTR*)&m_SharedMemory,3*sizeof(float)+sizeof(int)+reclen*(samplenum+1),key.toStdString().c_str());
|
||
if(m_Handle&&m_SharedMemory) {
|
||
m_vMD.SetSize(3);
|
||
m_vMD.m_vProperty=(float *)m_SharedMemory;
|
||
int size=((int *)m_SharedMemory)[3];
|
||
m_vProperty.SetSize(size);
|
||
m_vProperty.m_vProperty=&m_vMD.m_vProperty[4];
|
||
}
|
||
if(m_vMD.size()>0){
|
||
m_TopDepth=m_vMD.m_vProperty[0];
|
||
m_BottomDepth=m_vMD.m_vProperty[1];
|
||
m_Rlev=m_vMD.m_vProperty[2];
|
||
}
|
||
m_ShiftTopDepth=-9999;
|
||
m_ShiftBottomDepth=-9999;
|
||
m_DepthOffset=0;
|
||
|
||
if(m_ArrayNum>1) {
|
||
waveinfo.ArrayNum=pMsa->nPad/pMsa->nPadZ;
|
||
waveinfo.SamplePoint=myWidth/(waveinfo.ArrayNum);
|
||
waveinfo.TimeSamples=myWidth;
|
||
}
|
||
if(pMsa) {
|
||
delete pMsa;
|
||
pMsa=NULL;
|
||
}
|
||
float val=0;
|
||
valMin.clear();
|
||
valMax.clear();
|
||
valMin.resize((waveinfo.SamplePoint)*waveinfo.ArrayNum);
|
||
valMax.resize((waveinfo.SamplePoint)*waveinfo.ArrayNum);
|
||
for(int j=0;j<(waveinfo.SamplePoint)*waveinfo.ArrayNum;j++) {
|
||
valMin[j]=999999999;
|
||
valMax[j]=-99999999;
|
||
}
|
||
char buf[200];
|
||
for(int i=0;i<samplenum;i++) {
|
||
for(int j=0;j<waveinfo.SamplePoint*waveinfo.ArrayNum;j++)
|
||
{
|
||
val=GetData(i,j,buf);
|
||
if(val==0||val==-9999||val==-999.25||val==-99999||val==-32767||val==32767) continue;
|
||
if(_isnan(val)||!_finite(val)) continue;
|
||
if(valMax[j]<val)valMax[j]=val;
|
||
if(valMin[j]>val)valMin[j]=val;
|
||
}
|
||
}
|
||
if(waveinfo.MaxValue==-50||waveinfo.MinValue==50||fabs(waveinfo.MaxValue)<1e-6||waveinfo.MinValue<1e-6||waveinfo.MaxValue==-99999||waveinfo.MaxValue==-9999||waveinfo.MinValue==999999||waveinfo.MinValue==999999||waveinfo.MinValue==99999||waveinfo.MinValue==99999||waveinfo.MinValue==-9999)
|
||
{
|
||
float valmin=99999;
|
||
float valmax=-99999;
|
||
for(int j=0;j<waveinfo.SamplePoint*waveinfo.ArrayNum;j++) {
|
||
if(valmin>valMax[j]) valmin=valMax[j];
|
||
if(valmin>valMin[j]) valmin=valMin[j];
|
||
if(valmax<valMin[j]) valmin=valMin[j];
|
||
if(valmax<valMax[j]) valmax=valMax[j];
|
||
}
|
||
waveinfo.MaxValue=valmax;
|
||
waveinfo.MinValue=valmin;
|
||
}
|
||
isLoad=true;
|
||
// SetModified(false,false);
|
||
ret=true;
|
||
}
|
||
delete logio;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if(!ret) {
|
||
vMD.SetSize(0);
|
||
vMD.m_vProperty=0;
|
||
vProperty.SetSize(0);
|
||
vProperty.m_vProperty=NULL;
|
||
return;
|
||
}
|
||
else {
|
||
vMD.clear();
|
||
vProperty.clear();
|
||
vMD.SetSize(3);
|
||
vMD.m_vProperty=(float *)m_SharedMemory;
|
||
int size=((int *)m_SharedMemory)[3];
|
||
|
||
vProperty.SetSize(size);
|
||
vProperty.m_vProperty=&vMD.m_vProperty[4];
|
||
}
|
||
}
|
||
// BEGIN_REGISTER_OBJECT(CObjWellLogWavefile)
|
||
// QUuid(GetClassID_WellLogWavefile())
|
||
// END_REGISTER_OBJECT( CObjWellLogWavefile );
|
||
|
||
END_OSGDATAMODEL_NAMESPACE
|