#pragma once #include "WisTableTran.h" //#include "MemRdWt.h" #include "DepthProgress.h" #include #include "MyXtfLib.h" #include "MyLisLib.h" #include "MyLpsLib.h" #include "translf2data.h" #include extern short ReverseShort(short num); extern long ReverseLong(long num); extern int ReverseInt(int num); extern float ReverseFloat(float num); extern double ReverseDouble(double num); #define GJTUTOUFILENAME "gjtutou.inp" #define GJVDLBITNAME "gj_vdl.bit" #define TUTOUBITNAMELIST "bz_map.bit,bz_cli_map.bit,cli_map.bit,jx_map.bit,protn_list.bit,protn_map.bit,vbz_map.bit,vcli_map.bit,vprotn_map.bit,vprotn_list.bit,vzpi_map.bit,zpi_map.bit,cra_list.bit,cra_map.bit,vcra_list.bit,vcra_map.bit,porp_list.bit,porp_map.bit,vporp_map.bit,vporp_list.bit,vbz_cli_map.bit" #define TUTOUFILENAME "tutou.inp" #define G1FILENAME "g1.crd" #define G2FILENAME "g2.crd" short ReverseShort(short num) { short Result; BYTE* temp; temp=(BYTE*)# QByteArray tempArray; tempArray.append(*(temp+1)); tempArray.append(*(temp)); short* tempNum=(short*)(tempArray.data()); Result=*tempNum; return Result; }; long ReverseLong(long num) { long Result; BYTE* temp; temp=(BYTE*)# QByteArray tempArray; tempArray.append(*(temp+3)); tempArray.append(*(temp+2)); tempArray.append(*(temp+1)); tempArray.append(*(temp)); long* tempNum=(long*)(tempArray.data()); Result=*tempNum; return Result; }; int ReverseInt(int num) { int Result; BYTE* temp; temp=(BYTE*)# QByteArray tempArray; tempArray.append(*(temp+3)); tempArray.append(*(temp+2)); tempArray.append(*(temp+1)); tempArray.append(*(temp)); int* tempNum=(int*)(tempArray.data()); Result=*tempNum; return Result; }; float ReverseFloat(float num) { float Result; BYTE* temp; temp=(BYTE*)# QByteArray tempArray; tempArray.append(*(temp+3)); tempArray.append(*(temp+2)); tempArray.append(*(temp+1)); tempArray.append(*(temp)); float* tempNum=(float*)(tempArray.data()); Result=*tempNum; return Result; }; double ReverseDouble(double num) { double Result; BYTE* temp; temp=(BYTE*)# QByteArray tempArray; tempArray.append(*(temp+7)); tempArray.append(*(temp+6)); tempArray.append(*(temp+5)); tempArray.append(*(temp+4)); tempArray.append(*(temp+3)); tempArray.append(*(temp+2)); tempArray.append(*(temp+1)); tempArray.append(*(temp)); double* tempNum=(double*)(tempArray.data()); Result=*tempNum; return Result; } //func 输出文件名小写 QString LowerFileName(QString wellname){ int index = wellname.lastIndexOf('/'); QString temp = wellname.mid(index); temp = temp.toLower(); wellname.replace(index, wellname.size() - index, temp); return wellname; } int ifexIntRange(float v) { if(v >= 214748) return 0; else if(v >= 21474) return 4; else if(v >= 2147) return 5; else return 6; } //20201218 GZL add /* func: 重采样 attr: fBuffer重采前数据,深度范围符合用户所需 rlevNew新的间隔 rlevOld旧的间隔 pointOld重采前的数据点数 sdepth用户所需的起始深度 realsdep 实际数据的起始深度 result 存储输出 point2 result最大元素量 ndim 波数 ifFloat */ #define DIGIT6 1000000 #define DIGIT5 100000 #define DIGIT4 10000 #define DIGIT 1 template void reRlev(T* fBuffer, float rlevNew, float rlevOld, int pointOld, float sdepth, float realsdep, float* result, int point2, int ndim, bool ifFloat) { float curDepth = sdepth/*float( int(sdepth * DIGIT) ) / DIGIT*/;//从采样首深 int curIndex = 0; float tempX = realsdep/*float( int(realsdep * DIGIT) ) / DIGIT*/; //前脚 int indexX = 0; float tempY; //后脚 int indexY; float realE = sdepth + rlevOld * pointOld; //终止深度 float x, valueX; //用来进行线性计算的参数(差) //float rlevOldDIGIT = float(int(rlevOld * DIGIT)) / DIGIT; float rlevOldDIGIT = rlevOld; bool ifBreak = false; while(1){ #pragma region 缩放while if(tempX <= curDepth) { x = curDepth - tempX; #pragma region 计算后脚深度 indexY = indexX + 1; tempY = realsdep + indexY * rlevOld; #pragma endregion if(tempY >= curDepth){ // 计算curDepth的曲线值 for(int i = 0; i < ndim; i++){ if(indexY >= pointOld){ //已超最深边界 ifBreak = true; if(tempX == curDepth) { result[curIndex * ndim + i] = fBuffer[indexX * ndim + i]; } for(int cu = curIndex + 1 ; cu < point2; cu++) { if(ifFloat) result[cu * ndim + i] = -9999; else result[cu * ndim + i] = 0; } } else{ valueX = fBuffer[indexY * ndim + i] - fBuffer[indexX * ndim + i]; result[curIndex * ndim + i] = valueX * x / rlevOldDIGIT + fBuffer[indexX * ndim + i]; } } curIndex ++; if(curIndex >= point2 || ifBreak){ break; } } else{ #pragma region 后脚向前迈一步 indexX = indexY; tempX = tempY; continue; #pragma endregion } } else{ if(indexX == 0){ //cur在最浅边界之上 for(int i = 0; i < ndim; i++){ //valueX = fBuffer[indexY * ndim + i] - fBuffer[indexX * ndim + i]; if(ifFloat) result[curIndex * ndim + i] = -9999; else result[curIndex * ndim + i] = 0; } curIndex ++; if(curIndex >= point2){ break; } //curDepth = float( int(sdepth * DIGIT) + curIndex * int(rlevNew * DIGIT) ) / DIGIT; curDepth = sdepth + curIndex * rlevNew; continue; } else{ #pragma region 往回迈一步 indexY = indexX; tempY = tempX; indexX = indexY - 1; tempX = sdepth + indexX * rlevOld; continue; #pragma endregion } } #pragma region 向前迈一步 indexX = indexY; tempX = tempY; indexY = indexX + 1; #pragma endregion //“用户”向前迈一步 //curDepth = float( int(sdepth * DIGIT) + curIndex * int(rlevNew * DIGIT) ) / DIGIT; curDepth = sdepth + curIndex * rlevNew; //超出实际深度范围,结束 //if(curDepth >= realE) // break; #pragma endregion } } bool isTrueNum(QString text) { QByteArray ba = text.toLatin1(); const char* s = ba.data(); while(*s && ((*s >= '0' && *s <= '9') || *s == '.' || *s == '-' || *s == 'e')) s++; if(*s) return false; else return true; } void LPSResult_SP(CMemRdWt *mrw, int index, LAYER_DATA tempRes, QMap zoneOrder, FILE *fp) { int no = 0, tempZone = -9999, d_index = 0; float tempSd, tempEd, d_mid[5] = {0}; QString resultList; //int i_temp = mrw->GetTableRecordCount(index); for(int i_row = 0; i_row < mrw->GetTableRecordCount(index); i_row++) { mrw->ReadTable(index, i_row + 1, (void*)&tempRes); if(tempRes.MDepth1 == 0) //result为单值,可转化 { if(tempRes.Result == zoneOrder.value("一类层").toInt()) tempRes.Result = 11; else if(tempRes.Result == zoneOrder.value("二类层").toInt()) tempRes.Result = 22; else if(tempRes.Result == zoneOrder.value("三类层").toInt()) tempRes.Result = 33; else if(tempRes.Result == zoneOrder.value("差油层").toInt()) tempRes.Result = 66; else if(tempRes.Result == zoneOrder.value("未进硼层").toInt()) tempRes.Result = 77; else if(tempRes.Result == zoneOrder.value("差油层").toInt()) tempRes.Result = 88; else if(tempRes.Result == zoneOrder.value("差气层").toInt()) tempRes.Result = 99; else if(tempRes.Result == zoneOrder.value("强水淹层").toInt()) tempRes.Result = 5; else if(tempRes.Result == zoneOrder.value("中水淹层").toInt()) tempRes.Result = 5; else if(tempRes.Result == zoneOrder.value("弱水淹层").toInt()) tempRes.Result = 5; else if(tempRes.Result == zoneOrder.value("特强水淹层").toInt()) tempRes.Result = 5; else if(tempRes.Result == zoneOrder.value("较强水淹层").toInt()) tempRes.Result = 5; else if(tempRes.Result == zoneOrder.value("含水油层").toInt()) tempRes.Result = 1; else if(tempRes.Result == zoneOrder.value("含气油层").toInt()) tempRes.Result = 1; else if(tempRes.Result == zoneOrder.value("偏干油层").toInt()) tempRes.Result = 1; else if(tempRes.Result == zoneOrder.value("含煤层气层").toInt()) tempRes.Result = 6; else if(tempRes.Result == zoneOrder.value("一类裂缝层").toInt()) tempRes.Result = 11; else if(tempRes.Result == zoneOrder.value("二类裂缝层").toInt()) tempRes.Result = 22; else if(tempRes.Result == zoneOrder.value("三类裂缝层").toInt()) tempRes.Result = 33; else if(tempRes.Result == zoneOrder.value("一类页岩油层").toInt()) tempRes.Result = 11; else if(tempRes.Result == zoneOrder.value("二类页岩油层").toInt()) tempRes.Result = 22; else if(tempRes.Result == zoneOrder.value("三类页岩油层").toInt()) tempRes.Result = 33; else if(tempRes.Result == zoneOrder.value("含气油水同层").toInt()) tempRes.Result = 2; } if(i_row == 0) { if(atoi(tempRes.Zone) > 1) no = -atoi(tempRes.Zone); else no = tempRes.Order; } else no = tempRes.Order; int zoneNum = QString(tempRes.Zone).toInt(); if(tempZone != -9999) { if(zoneNum != tempZone) //断层,直接输出temp { if(resultList == "55" || resultList == "555" || resultList == "5555" || resultList == "55555") { resultList = "5"; fprintf(fp, "%3d%7d%9.3f%9.3f%8.2f%8.2f%8.2f%8.2f%8.2f\n", tempZone,resultList.toInt(),tempSd,tempEd,0,0,0,0,0); } else fprintf(fp, "%3d%7d%9.3f%9.3f%8.2f%8.2f%8.2f%8.2f%8.2f\n", tempZone,resultList.toInt(),tempSd,tempEd,d_mid[0],d_mid[1],d_mid[2],d_mid[3],d_mid[4]); tempZone = -9999; resultList.clear(); d_mid[0] = 0;d_mid[1] = 0;d_mid[2] = 0;d_mid[3] = 0;d_mid[4] = 0; d_index = 0; } else //继续更新temp(合并水淹层) { if(tempRes.StartDepth == tempEd) //连接 下层 { if(i_row == mrw->GetTableRecordCount(index) - 1)//最后一个 { d_mid[d_index++] = tempEd; tempEd = tempRes.EndDepth; resultList += QString::number(tempRes.Result); if(resultList == "55" || resultList == "555" || resultList == "5555" || resultList == "55555") fprintf(fp, "%3d%7d%9.3f%9.3f%8.2f%8.2f%8.2f%8.2f%8.2f\n", tempZone,5,tempSd,tempEd,0,0,0,0,0); else fprintf(fp, "%3d%7d%9.3f%9.3f%8.2f%8.2f%8.2f%8.2f%8.2f\n", tempZone,resultList.toInt(),tempSd,tempEd,d_mid[0],d_mid[1],d_mid[2],d_mid[3],d_mid[4]); } d_mid[d_index++] = tempEd; tempEd = tempRes.EndDepth; resultList += QString::number(tempRes.Result); continue; } else //断层,直接输出temp { if(resultList == "55" || resultList == "555" || resultList == "5555" || resultList == "55555") { resultList = "5"; fprintf(fp, "%3d%7d%9.3f%9.3f%8.2f%8.2f%8.2f%8.2f%8.2f\n", tempZone,resultList.toInt(),tempSd,tempEd,0,0,0,0,0); } else fprintf(fp, "%3d%7d%9.3f%9.3f%8.2f%8.2f%8.2f%8.2f%8.2f\n", tempZone,resultList.toInt(),tempSd,tempEd,d_mid[0],d_mid[1],d_mid[2],d_mid[3],d_mid[4]); tempZone = -9999; resultList.clear(); d_mid[0] = 0;d_mid[1] = 0;d_mid[2] = 0;d_mid[3] = 0;d_mid[4] = 0; d_index = 0; } } } if(tempZone == -9999 && i_row != (mrw->GetTableRecordCount(index) - 1) && (tempRes.MDepth1 == 0)) //可合并状 { tempSd = tempRes.StartDepth; tempEd = tempRes.EndDepth; tempZone = zoneNum; resultList += QString::number(tempRes.Result); continue; } fprintf(fp, "%3d%7d%9.3f%9.3f%8.2f%8.2f%8.2f%8.2f%8.2f\n", zoneNum/*tempRes.Order*/, tempRes.Result, tempRes.StartDepth, tempRes.EndDepth, tempRes.MDepth1, tempRes.MDepth2, tempRes.MDepth3, tempRes.MDepth4, tempRes.MDepth5 ); } } void LPSResult_NOR(CMemRdWt *mrw, int index, FILE *fp, QStringList del_col,bool Zero) { char* buf = new char[mrw->GetTableRecordLength(index)]; //mrw->GetTableFieldInfo(index, iiii); int col_num = mrw->GetTableFieldCount(index); int row_num = mrw->GetTableRecordCount(index); Slf_TABLE_FIELD *Table_Field = new Slf_TABLE_FIELD[col_num + 1]; mrw->GetTableFieldInfo(index, Table_Field); for(int i_row = 0; i_row < row_num; i_row++) { mrw->ReadTable(index, i_row + 1, buf); int curLen = 0; QStringList allRow; for(int j = 0; j < col_num; j++) { char strKey[100]; GetData(Table_Field[j].RepCode, &buf[curLen], strKey); curLen += Table_Field[j].Length; if(Zero&& ( Table_Field[j].RepCode==6&&isdigit(strKey[0])&&atof(strKey)==0 //||Table_Field[j].RepCode==1&&atof(strKey)==0 ) ) strcpy(strKey,""); allRow.append(QString(strKey)); } bool firstCol = true; for(int i_allRow = 0; i_allRow < allRow.size(); i_allRow++) { if(del_col.contains(QString::number(i_allRow))) continue; if(!firstCol) fprintf(fp, " "); firstCol = false; if(allRow[i_allRow] == "" && i_allRow == 1) { fprintf(fp, " "); } else if(isTrueNum(allRow[i_allRow])&&allRow[i_allRow] != "") { float tempT = float(int(allRow[i_allRow].toFloat() * 10000)) / 10000; if(tempT < 0.0001) tempT = 0; if(i_allRow == 1) fprintf(fp, "%9d", int(tempT)); else if(i_allRow == 3) { tempT += 0.01; fprintf(fp, "%6.1f", tempT); } else fprintf(fp, "%6.3f", tempT); } else fprintf(fp, "%s", allRow[i_allRow].toStdString().c_str()); } fprintf(fp, "\n"); } delete []buf; delete []Table_Field; } /* func: 计算数据存放位置信息 attr: xtf_lib RepCodeLen 曲线类型字节长度 curve_num 曲线数 TimeSample */ #define MAXBLOCK_BTLEN 4096 int writeSEPos(MyXtfLib &xtf_lib, int RepCodeLen, int curve_num, int TimeSample) { int length = xtf_lib.CurveSampleNum[curve_num] * RepCodeLen * TimeSample; int num = length / MAXBLOCK_BTLEN; if (length % MAXBLOCK_BTLEN > 0) num++; //剩余块 xtf_lib.CurveStartPos[curve_num] = xtf_lib.BlockNum + 1; //计算的文件块开始位置 xtf_lib.CurveEndPos[curve_num] = xtf_lib.BlockNum + 1 + num; //计算的文件块结束位置 xtf_lib.BlockNum += (num + 1); return length; } /* func 重采样深度信息操作 attr xtf_lib pInfo 原始深度信息 Outsdep, Outedep, Outrlev 新深度信息 curve_num */ template void reRlevDepthLevel(MyXtfLib &xtf_lib, F pInfo, float Outsdep, float Outedep, float Outrlev, int curve_num){ xtf_lib.CurveStartDepth[curve_num] = Outsdep; xtf_lib.CurveEndDepth[curve_num] = Outedep; xtf_lib.CurveDepthLevel[curve_num]= Outrlev/*pInfo.DepLevel*/; /* if(pInfo.StartDepth > Outsdep) xtf_lib.CurveStartDepth[curve_num] = pInfo.StartDepth; else xtf_lib.CurveStartDepth[curve_num] = Outsdep; if(pInfo.EndDepth < Outedep) xtf_lib.CurveEndDepth[curve_num] = pInfo.EndDepth; else xtf_lib.CurveEndDepth[curve_num] = Outedep; xtf_lib.CurveDepthLevel[curve_num]= Outrlev; */ } float GetDepScale(CMemRdWt *mrw,bool IsFeet)//判断深度单位 { int h=0; int ObjectCount = mrw->GetObjectCount(); float DepScale=1; for(int i=0;iGetObjectStatus(i)==OBJECT_DISCARD||mrw->GetObjectStatus(i)==OBJECT_DELETE)continue; char Name[200]; mrw->GetObjectName(i,Name); if(strstr(Name,"%")==NULL) { int index=mrw->FindObjectIndex(Name); if(index<0)continue; int Type=mrw->GetObjectType(index); if(Type==CURVE_OBJECT||Type==WAVE_OBJECT) { Slf_CHANNEL pInfo; index=mrw->OpenChannel(Name); mrw->GetChannelInfo(index,&pInfo); if((pInfo.DimInfo[0].Unit[0]=='f')||(pInfo.DimInfo[0].Unit[0]=='F')) {//英制 if(!IsFeet)DepScale=0.3048;//ft->m } else if(IsFeet)DepScale=3.28;//m->ft break;//读一条曲线即可,认为一个slf文件的深度单位是一致的 } } } return DepScale; } void TranToLps(CMemRdWt *mrw,QString Outfile,float Outsdep,float Outedep,float Outrlev,int NumObject,OUTOBJECTINF *OutInf,bool IsFeet,bool Zero) { //Outfile = Outfile.toUpper(); float temps,tempe,tempr; temps = Outsdep;tempe = Outedep;tempr = Outrlev; int outputG1_ind = -1; int outputG2_ind = -1; QFileInfo rFileInfo(Outfile); QString WellName = rFileInfo.completeBaseName(); QString PathName=rFileInfo.absolutePath()+"\/"; if(rFileInfo.exists() && rFileInfo.isFile() && rFileInfo.suffix() =="WLD") { if(QMessageBox::information(NULL,"提示","当前LPS文件"+Outfile+"已存在,是否覆盖?",QMessageBox::Yes|QMessageBox::No)!=QMessageBox::Yes)return; QString szBaseName = rFileInfo.baseName(); QDir rDir = rFileInfo.absoluteDir(); auto rList = rDir.entryInfoList(); for(int nIndex = 0; nIndex < rList.size(); ++nIndex) { if(rList[nIndex].baseName() == szBaseName) { rDir.remove(rList[nIndex].fileName()); } } } float DepScale = GetDepScale(mrw, IsFeet); int Ind[1024]; FILE *fp; //产生描述信息文件:wld MyLpsLib lps_lib; lps_lib.PathName = PathName; lps_lib.WellName = WellName; mrw->GetFileMessage(lps_lib.FILE_MESSAGE); /* int indexSTable = mrw->OpenTable("井基本信息"); if(indexSTable>-1) { int h=mrw->ReadTable(indexSTable,1,&lps_lib.WellStaticInfo); mrw->CloseTable(indexSTable); } int indexDTable = mrw->OpenTable("测井信息"); if(indexDTable>-1) { mrw->ReadTable(indexDTable, 1, &lps_lib.WellDynamicInfo); mrw->CloseTable(indexDTable); } */ if(!lps_lib.WriteWLD()) { return; } char Name[64]; int num=mrw->GetObjectCount(); lps_lib.num1d=0,lps_lib.num2d=0; lps_lib.ResultId=-1,lps_lib.CoreId=-1; vector CurveNo, WaveNo; int resultIndex = -1; int vresultIndex = -1; QMap outTableMap; for(int i = 0; i < NumObject; i++) { Ind[i] = mrw->FindSlfObjectIndex(OutInf[i].Name, 0); if(Ind[i]<0)continue; int type=mrw->GetObjectType(Ind[i]); if(type == CURVE_OBJECT ) //常规曲线 { CurveNo.push_back(i); lps_lib.num1d++; } else if(type == WAVE_OBJECT)//阵列曲线 { WaveNo.push_back(i); lps_lib.num2d++; } else if(type==CARD_OBJECT)//参数流 { #pragma region 参数流 int inpIndex = mrw->OpenStream(OutInf[i].Name); if(inpIndex < 0) {} else{ int lenInp = mrw->GetStreamLength(inpIndex); char *InpBuffer = new char[lenInp + 1]; DWORD bb=0; mrw->ReadStream(inpIndex, lenInp, &bb, InpBuffer); mrw->CloseStream(inpIndex); InpBuffer[lenInp] = 0; string inpfilename = OutInf[i].Name; transform(inpfilename.begin(), inpfilename.end(), inpfilename.begin(), ::tolower); inpfilename.copy(OutInf[i].Name, inpfilename.length()); QString inpName = QString(QLatin1String(OutInf[i].Name)); if(inpName.indexOf(".inp") < 0) inpName = ".inp"; QString cs = PathName + WellName.toLower() + '_' + inpName/*OutInf[i].Name*/; if((fp = fopen(cs.toStdString().c_str(), "w+b")) == NULL){} else{ QString str=InpBuffer; str.toLower(); while(str.indexOf("\r\n")>=0) { str=str.replace("\r\n","\n"); } fprintf(fp, str.toStdString().c_str()); mrw->CloseStream(inpIndex); fclose(fp); } } #pragma endregion } else if(type==0||type>=6) { outTableMap.insert(OutInf[i].Name, 1); //输出table列表 if(strncmp(OutInf[i].Name, "RESULT",strlen("RESULT"))==0 || strncmp(OutInf[i].Name, "VRESULT",strlen("VRESULT"))==0) lps_lib.ResultId=i; if(QString(OutInf[i].Name) == "RESULT") resultIndex = i; if(QString(OutInf[i].Name) == "VRESULT") vresultIndex = i; if(strcmp(OutInf[i].Name,"SWALL_CORE")==0) lps_lib.CoreId=i; if(strncmp(OutInf[i].Name, "GUJING1_RESULT", strlen("GUJING1_RESULT")) == 0) outputG1_ind = i; if(strncmp(OutInf[i].Name, "GUJING2_RESULT", strlen("GUJING2_RESULT")) == 0) outputG2_ind = i; } } if(lps_lib.num1d)lps_lib.c1d = new CurveIndex1d[lps_lib.num1d+1]; if(lps_lib.num2d)lps_lib.c2d = new CurveIndex2d[lps_lib.num2d+1]; QString configfile=GetConfPath()+"output_nameMap\\SL输出批量改名.ini"; QStringList lines; QFile file( configfile ); if ( file.open( QIODevice::ReadOnly ) ) { QTextStream stream( &file ); QString line; while ( !stream.atEnd() ) { line = stream.readLine(); // 不包括“\n”的一行文本 lines += line; } file.close(); } lines.removeAll(""); QMap zoneOrder; for(int i=0;i1) zoneOrder.insert(ss[0],ss[1]); } if(lps_lib.num1d) { #pragma region 一维曲线数据文件 WldFileHead d1d; strcpy(d1d.flag,D1D_FILE_FLAG); d1d.length=sizeof(WldFileHead); lps_lib.OpenDataFile(".d1d"); lps_lib.WriteDataFile((char *)&d1d,32); DWORD pos=32; for(int i = 0; i < lps_lib.num1d; i++) { memset(&lps_lib.c1d[i],0,sizeof(CurveIndex1d)); int id=CurveNo[i]; int index=mrw->OpenCurve(OutInf[id].Name); Slf_CURVE pInfo; mrw->GetCurveInfo(index,&pInfo); //20201228 GZL add if(temps == -9999.0) Outsdep = pInfo.StartDepth; if(tempe == -9999.0) Outedep = pInfo.EndDepth; if(tempr == -9999.0) Outrlev = pInfo.DepLevel; strncpy(lps_lib.c1d[i].name,OutInf[id].OutName,8);// 曲线名称 if(!zoneOrder[OutInf[id].OutName].isEmpty()) { strncpy(lps_lib.c1d[i].name,zoneOrder[OutInf[id].OutName].toStdString().c_str(),8);// 曲线名称 } lps_lib.c1d[i].name[7]=0; // 曲线别名 if(OutInf[id].AliasName[0]==0) strcpy(lps_lib.c1d[i].alias,lps_lib.c1d[i].name); else strncpy(lps_lib.c1d[i].alias,OutInf[id].AliasName,8); lps_lib.c1d[i].alias[7]=0; for(int j=0;j<16;j++)lps_lib.c1d[i].flag[j]=0x0; // 曲线附加标志 lps_lib.c1d[i].sdepth = Outsdep; /*if(pInfo.StartDepth > Outsdep) lps_lib.c1d[i].sdepth = pInfo.StartDepth; // 曲线的起始深度 else lps_lib.c1d[i].sdepth = Outsdep;*/ lps_lib.c1d[i].edepth = Outedep; /*if(pInfo.EndDepth < Outedep) lps_lib.c1d[i].edepth = pInfo.EndDepth; // 曲线的结束深度 else lps_lib.c1d[i].edepth = Outedep;*/ //20201218 GZL change lps_lib.c1d[i].dstep = Outrlev/*pInfo.DepLevel*/; // 曲线采样的深度间距 if(IsFeet) { strcpy(lps_lib.c1d[i].dunit, "feet"); // 深度值量纲 } else if(OutInf[id].Unit[0]) { strcpy(lps_lib.c1d[i].dunit,pInfo.DepthUnit); } else if(pInfo.DepthUnit[0]) strcpy(lps_lib.c1d[i].dunit,pInfo.DepthUnit); if(OutInf[id].Unit[0]==0) strcpy(OutInf[id].Unit,pInfo.Unit); if(OutInf[id].Unit[0]) strncpy(lps_lib.c1d[i].vunit,OutInf[id].Unit,8); // 曲线值量纲 lps_lib.c1d[i].vunit[7]=0; if(pInfo.RepCode!=REPR_FLOAT) { strcpy(lps_lib.c1d[i].data_type,"float"); } else strcpy(lps_lib.c1d[i].data_type,lps_lib.GetDataType(pInfo.RepCode)); // 曲线值存储类型 lps_lib.c1d[i].address = pos; int point = (pInfo.EndDepth/*lps_lib.c1d[i].edepth*/ - pInfo.StartDepth/*lps_lib.c1d[i].sdepth*/) / pInfo.DepLevel + 1.5; //实际数据所需点数 //20201218 GZL add int point2 = (lps_lib.c1d[i].edepth - lps_lib.c1d[i].sdepth) / Outrlev + 1.5; //重采样后数据点数 pos += point2 * sizeof(float); char *pBuffer = new char[point * pInfo.CodeLen + 10]; //实际数据存储 //20201219 GZL change mrw->ReadCurve(index, pInfo.StartDepth/*lps_lib.c1d[i].sdepth*/, point, (void *)&pBuffer[0]); //20201218 GZL add //float *fBuffer = new float[point + 2]; //mrw->ReadCurve(index, lps_lib.c1d[i].sdepth, point, &fBuffer[0]); //delete fBuffer; if(pInfo.RepCode != REPR_FLOAT) { char *pBuffer1=new char[point * sizeof(float)+10]; float *pFloa = (float *)pBuffer1; float yy = -9999.0; for (int i = 0; i < point; i++) { pFloa[i] = mrw->GetData(pInfo.RepCode, &pBuffer[i*pInfo.CodeLen], &yy); } delete[] pBuffer; pBuffer = pBuffer1; } #pragma region 20201218 GZL add 重采样 //准备 float *fBuffer; fBuffer = (float *)pBuffer; float *rfBuffer = new float[point2]; if(Outrlev != pInfo.DepLevel || pInfo.StartDepth != lps_lib.c1d[i].sdepth || pInfo.EndDepth != lps_lib.c1d[i].edepth){ reRlev(fBuffer, Outrlev, pInfo.DepLevel, point, lps_lib.c1d[i].sdepth, pInfo.StartDepth, rfBuffer, point2, 1, true); } char *rcBuffer /*= new char[point2 * pInfo.CodeLen + 10]*/; rcBuffer = (char *)rfBuffer; #pragma endregion if(Outrlev != pInfo.DepLevel || pInfo.StartDepth != lps_lib.c1d[i].sdepth || pInfo.EndDepth != lps_lib.c1d[i].edepth){ lps_lib.TurnData(REPR_FLOAT, point2, rcBuffer); lps_lib.WriteDataFile(rcBuffer, point2 * sizeof(float)); } else{ lps_lib.TurnData(REPR_FLOAT, point, pBuffer); lps_lib.WriteDataFile(pBuffer, point * sizeof(float)); } delete []pBuffer; delete []rcBuffer; //delete rfBuffer; lps_lib.c1d[i].sdepth *= DepScale; lps_lib.c1d[i].edepth *= DepScale; lps_lib.c1d[i].dstep *= DepScale; } d1d.length=ReverseInt(pos); lps_lib.Rewind(); lps_lib.WriteDataFile((char *)&d1d, 32); lps_lib.CloseDataFile(); if(!lps_lib.WriteI1D()) return;//一维曲线索引文件 #pragma endregion } if(lps_lib.num2d) { #pragma region 二维曲线数据文件 WldFileHead d2d; strcpy(d2d.flag,D2D_FILE_FLAG); d2d.length=ReverseInt(sizeof(WldFileHead)); lps_lib.OpenDataFile(".d2d"); lps_lib.WriteDataFile((char *)&d2d,32); DWORD pos=32; for(int i=0;iOpenWave(OutInf[id].Name); Slf_WAVE pInfo; mrw->GetWaveInfo(index,&pInfo); //20201228 GZL add if(temps == -9999.0) Outsdep = pInfo.StartDepth; if(tempe == -9999.0) Outedep = pInfo.EndDepth; if(tempr == -9999.0) Outrlev = pInfo.DepLevel; strncpy(lps_lib.c2d[i].name,OutInf[id].OutName,8);// 曲线名称 lps_lib.c2d[i].name[7]=0; if(OutInf[id].AliasName[0]==0) strcpy(lps_lib.c2d[i].alias,lps_lib.c2d[i].name); else strncpy(lps_lib.c2d[i].alias,OutInf[id].AliasName,8); // 曲线别名 lps_lib.c2d[i].alias[7]=0; for(int j=0;j<16;j++)lps_lib.c2d[i].flag[j]=0x0; // 曲线附加标志 lps_lib.c2d[i].sdepth = Outsdep; lps_lib.c2d[i].edepth = Outedep; /*if(pInfo.StartDepth>Outsdep) lps_lib.c2d[i].sdepth = pInfo.StartDepth; // 曲线的起始深度 else lps_lib.c2d[i].sdepth = Outsdep; if(pInfo.EndDepthReadWave(index, pInfo.StartDepth/*lps_lib.c2d[i].sdepth*/, point, (void *)&pBuffer[0]); if(pInfo.RepCode != REPR_FLOAT) { char *pBuffer1=new char[point * sizeof(float)*pInfo.TimeSamples+10]; float *pFloa=(float *)pBuffer1; float yy=-9999.0; for (int i=0;iGetData(pInfo.RepCode,&pBuffer[(i*pInfo.TimeSamples+j) * pInfo.CodeLen],&yy); } } delete[] pBuffer; pBuffer=pBuffer1; } #pragma region 20201218 GZL add 重采样 //准备 float *fBuffer; fBuffer = (float *)pBuffer; float *rfBuffer = new float[point2 * pInfo.TimeSamples]; if(Outrlev != pInfo.DepLevel || pInfo.StartDepth != lps_lib.c2d[i].sdepth || pInfo.EndDepth != lps_lib.c2d[i].edepth){ reRlev(fBuffer, Outrlev, pInfo.DepLevel, point, Outsdep, pInfo.StartDepth, rfBuffer, point2, pInfo.TimeSamples, true); } char *rcBuffer/* = new char[point2 * pInfo.TimeSamples * pInfo.CodeLen + 10]*/; rcBuffer = (char *)rfBuffer; #pragma endregion if(Outrlev != pInfo.DepLevel || pInfo.StartDepth != lps_lib.c2d[i].sdepth || pInfo.EndDepth != lps_lib.c2d[i].edepth){ //传重采样数据 lps_lib.TurnData(REPR_FLOAT, point2 * pInfo.TimeSamples, rcBuffer); lps_lib.WriteDataFile(rcBuffer, point2 * sizeof(float) * pInfo.TimeSamples); } else{ lps_lib.TurnData(REPR_FLOAT, point * pInfo.TimeSamples, pBuffer); lps_lib.WriteDataFile(pBuffer, point * sizeof(float) * pInfo.TimeSamples); } delete []pBuffer; delete []rcBuffer; lps_lib.c2d[i].sdepth *= DepScale; lps_lib.c2d[i].edepth *= DepScale; lps_lib.c2d[i].dstep *= DepScale; } d2d.length=ReverseInt(pos); lps_lib.Rewind(); lps_lib.WriteDataFile((char *)&d2d,32); lps_lib.CloseDataFile(); if(!lps_lib.WriteI2D()) return;//一维曲线索引文件 #pragma endregion } CurveNo.clear(),WaveNo.clear(); #pragma region 输出结论 if(lps_lib.ResultId >= 0) { QMap zoneOrder = GetZoneOrder();//初始化ZoneOrder 层序号根据层位名来,配置文件在conf\\RESULT.txt int count = mrw->GetObjectCount(); for(int i = 0; i < count; i++) { if(mrw->GetObjectStatus(i) != OBJECT_NORMAL) continue; short att,subatt; short curvetype=mrw->GetObjectType(i); mrw->GetObjectAttribute(i,&att,&subatt); if(curvetype > CARD_OBJECT || curvetype == 0) { #pragma region result中文映射 QMap resultColName_map; resultColName_map.insert("NO","序号"); resultColName_map.insert("ZONE","层号"); resultColName_map.insert("GEOZN","层位"); resultColName_map.insert("THICK","有效厚度"); resultColName_map.insert("RSULT","结论"); resultColName_map.insert("GR","自然伽玛"); resultColName_map.insert("SP","自然电位"); resultColName_map.insert("RT","深探测电阻率"); resultColName_map.insert("RXO","冲洗带电阻率"); resultColName_map.insert("AC","声波时差"); resultColName_map.insert("DEN","补偿密度"); resultColName_map.insert("CNL","补偿中子"); resultColName_map.insert("R4","浅探测电阻率"); resultColName_map.insert("RN","微电位"); resultColName_map.insert("RL","微梯度"); resultColName_map.insert("POR","孔隙度"); resultColName_map.insert("PORF","侵入带含水孔隙体积"); resultColName_map.insert("PORX","冲洗带残余烃体积"); resultColName_map.insert("PORH","冲洗带残余烃重量");resultColName_map.insert("PORW","含水孔隙体积"); resultColName_map.insert("PORT","总孔隙度"); resultColName_map.insert("PORN","中子孔隙度"); resultColName_map.insert("SH","泥质含量"); resultColName_map.insert("PERM","渗透率"); resultColName_map.insert("PERO","油有效渗透率"); resultColName_map.insert("PERW","水有效渗透率"); resultColName_map.insert("SW","含水饱和度"); resultColName_map.insert("SWI","束缚水饱和度"); resultColName_map.insert("FW","产水率"); resultColName_map.insert("OIL","油层"); resultColName_map.insert("POOROIL","差油层"); resultColName_map.insert("OILWATER","油水同层"); resultColName_map.insert("WATEROIL","含油水层"); resultColName_map.insert("GAS","气层"); resultColName_map.insert("POORGAS","差气层"); resultColName_map.insert("GASWATER","气水同层"); resultColName_map.insert("WATERGAS","含气水层"); resultColName_map.insert("CORE","取心描述"); resultColName_map.insert("VGR","自然伽玛"); resultColName_map.insert("VSP","自然电位"); resultColName_map.insert("VRT","深探测电阻率"); resultColName_map.insert("VRXO","冲洗带电阻率"); resultColName_map.insert("VAC","声波时差"); resultColName_map.insert("VDEN","补偿密度"); resultColName_map.insert("VCNL","补偿中子"); resultColName_map.insert("VR4","浅探测电阻率"); resultColName_map.insert("VRN","微电位"); resultColName_map.insert("VRL","微梯度"); resultColName_map.insert("VPOR","孔隙度"); resultColName_map.insert("VPOR2","次生孔隙度"); resultColName_map.insert("VPORA","声波孔隙度"); resultColName_map.insert("VPORD","密度孔隙度"); resultColName_map.insert("VPORF","侵入带含水孔隙体积"); resultColName_map.insert("VPORX","冲洗带残余烃体积"); resultColName_map.insert("VPORH","冲洗带残余烃重量"); resultColName_map.insert("VPORW","含水孔隙体积"); resultColName_map.insert("VPORT","总孔隙度"); resultColName_map.insert("VPORN","中子孔隙度"); resultColName_map.insert("VSH","泥质含量"); resultColName_map.insert("VPERM","渗透率"); resultColName_map.insert("VPERO","油有效渗透率"); resultColName_map.insert("VPERW","水有效渗透率"); resultColName_map.insert("VSW","含水饱和度"); resultColName_map.insert("VSWI","束缚水饱和度"); resultColName_map.insert("VFW","产水率"); resultColName_map.insert("VDGA","视颗粒密度"); resultColName_map.insert("DGA","视颗粒密度"); resultColName_map.insert("SH","泥质含量"); resultColName_map.insert("SAND","沙岩含量"); resultColName_map.insert("LIME","灰岩含量"); resultColName_map.insert("DOLM","白云岩含量"); resultColName_map.insert("OTHR","石膏含量"); resultColName_map.insert("ANDE","安山岩含量"); resultColName_map.insert("BASD","侵入岩含量"); resultColName_map.insert("DIAB","辉长岩含量"); resultColName_map.insert("CONG","角砾岩含量"); resultColName_map.insert("TUFF","凝灰岩含量"); resultColName_map.insert("GRAV","砾岩含量"); resultColName_map.insert("BASA","玄武岩含量"); resultColName_map.insert("ANHY","中砾岩含量"); resultColName_map.insert("SALT","岩盐含量"); resultColName_map.insert("COAL","煤层"); resultColName_map.insert("VSAND","沙岩含量"); resultColName_map.insert("VLIME","灰岩含量"); resultColName_map.insert("VDOLM","白云岩含量"); resultColName_map.insert("VOTHR","石膏含量"); resultColName_map.insert("VANDE","安山岩含量"); resultColName_map.insert("VBASD","侵入岩含量"); resultColName_map.insert("VDIAB","辉长岩含量"); resultColName_map.insert("VCONG","角砾岩含量"); resultColName_map.insert("VTUFF","凝灰岩含量"); resultColName_map.insert("VGRAV","砾岩含量"); resultColName_map.insert("VBASA","玄武岩含量"); resultColName_map.insert("VANHY","中砾岩含量"); resultColName_map.insert("VSALT","岩盐含量"); resultColName_map.insert("VCOAL","煤层"); resultColName_map.insert("VSWIR","束缚水饱和度"); #pragma endregion result中文映射 char name[64]; mrw->GetObjectName(i, name); if(strncmp(name, "RESULT", strlen("RESULT")) != 0 && strncmp(name, "VRESULT", strlen("VRESULT")) != 0) continue; if(outTableMap[name] <= 0) continue; if(mrw->OpenTable(name) < 0) continue; QString cs = PathName + WellName.toLower(); if(strchr(name, '_')) cs += strchr(name, '_'); if(strncmp(name, "VRESULT", strlen("VRESULT")) == 0) cs += "_tvd"; if(QString(name) == "RESULT" || QString(name) == "VRESULT") cs+=".ird"; else cs+=".txt"; if((fp=fopen(cs.toStdString().c_str(),"w+t")) == NULL) return; LAYER_DATA tempRes; int index = mrw->OpenTable(name); if(QString(name) == "RESULT") { #pragma region RESULT head if(QString(OutInf[resultIndex].OutName) == "RESULT_CRA") { fprintf(fp,"CRA\n"); fprintf(fp,"PERM SW POR POR2 DGA SH SAND LIME DOLM GRAV \n"); } else if(QString(OutInf[resultIndex].OutName) == "RESULT_PORP") { fprintf(fp,"PORP\n"); fprintf(fp,"PERM SW PORT PORF PORW PORX PORH SH \n"); } else if(QString(OutInf[resultIndex].OutName) =="RESULT_PORTN") { fprintf(fp,"PROT\n"); fprintf(fp,"PERM PERO PERW PORT SW SWIR SH FW \n"); } else { fprintf(fp,"CRA\n"); fprintf(fp,"PERM SW POR POR2 DGA SH SAND LIME DOLM GRAV \n"); } #pragma endregion RESULT head LPSResult_SP(mrw, index, tempRes, zoneOrder, fp); } else if(QString(name) == "VRESULT") { #pragma region VRESULT head if(QString(OutInf[vresultIndex].OutName) =="VRESULT") { fprintf(fp,"VCRA\n"); fprintf(fp,"VPEM VSW VPOT VPO2 VDGA VSH VSAN VLIM VDOL VGRA \n"); } else if(QString(OutInf[vresultIndex].OutName) =="VRESULT_CRA") { fprintf(fp,"VCRA\n"); fprintf(fp,"VPEM VSW VPOT VPO2 VDGA VSH VSAN VLIM VDOL VGRA \n"); } else if(QString(OutInf[vresultIndex].OutName) == "VRESULT_PORP") { fprintf(fp,"VPORP\n"); fprintf(fp,"VPEM VSW VPOT VPOF VPOW VPOX VPOH VSH \n"); } else if(QString(OutInf[vresultIndex].OutName) =="VRESULT_PORTN") { fprintf(fp,"VPRO\n"); fprintf(fp,"VPEM VPEO VPEW VPOT VSW VSWI VSH VFW \n"); } #pragma endregion VRESULT head LPSResult_SP(mrw, index, tempRes, zoneOrder, fp); } else if(QString(name) == "RESULT_POR") { #pragma region RESULT_POR head QStringList del_col; del_col << "0" << "2"; //删除的列 fprintf(fp, "# WELL NAME: "); fprintf(fp, WellName.toUpper().toStdString().c_str()); fprintf(fp, "\n# TABLE NAME: RESULT_POR\n"); fprintf(fp, "# TABLE ROWS: %d\n", mrw->GetTableRecordCount(index)); fprintf(fp, "# TABLE COLS: %d\n", mrw->GetTableFieldCount(index)-1); Slf_TABLE_FIELD *ADSA = new Slf_TABLE_FIELD[mrw->GetTableFieldCount(index)+1]; mrw->GetTableFieldInfo(index, ADSA); for(int ads = 0; ads < mrw->GetTableFieldCount(index); ads++) { if(del_col.contains(QString::number(ads))) continue; QString thisColName = resultColName_map[ADSA[ads].Name]; if(thisColName == "") thisColName = ADSA[ads].Name; fprintf(fp, thisColName.toStdString().c_str()); fprintf(fp, "\t"); } fprintf(fp, "\n"); delete[] ADSA; #pragma endregion RESULT_POR head LPSResult_NOR(mrw, index, fp, del_col,Zero); } else if(QString(name) == "VRESULT_VPO") { #pragma region VRESULT_VPO head QStringList del_col; del_col << "0" << "2"; //删除的列 fprintf(fp, "# WELL NAME: "); fprintf(fp, WellName.toStdString().c_str()); fprintf(fp, "\n# TABLE NAME: VRESULT_VPO\n"); fprintf(fp, "# TABLE ROWS: %d\n", mrw->GetTableRecordCount(index)); fprintf(fp, "# TABLE COLS: %d\n", mrw->GetTableFieldCount(index)-1); Slf_TABLE_FIELD *ADSA = new Slf_TABLE_FIELD[mrw->GetTableFieldCount(index)+1]; mrw->GetTableFieldInfo(index, ADSA); for(int ads = 0; ads < mrw->GetTableFieldCount(index); ads++) { if(del_col.contains(QString::number(ads))) continue; QString thisColName = resultColName_map[ADSA[ads].Name]; if(thisColName == "") thisColName = ADSA[ads].Name; fprintf(fp, thisColName.toStdString().c_str()); fprintf(fp, "\t"); } fprintf(fp, "\n"); delete[] ADSA; //fprintf(fp, "ZONE THICK RESULT VGR VSP VRT VRXO VAC VDEN VCNL VR4 VRN VRL VPOR VPORF VPORX VPORH VPORW VPORT VPORN VSH VPERM VPERO VPERW VSW VSWIR VFW OIL POOROIL OILWATER WATEROIL GAS POORGAS GASWATER WATERGAS CORE\n"); #pragma endregion VRESULT_VPO head LPSResult_NOR(mrw, index, fp, del_col,Zero); } else if(QString(name) == "RESULT_CRA") { #pragma region RESULT_CRA head QStringList del_col; del_col << "0" << "2"; //删除的列 fprintf(fp, "# WELL NAME: "); fprintf(fp, WellName.toStdString().c_str()); fprintf(fp, "\n# TABLE NAME: RESULT_CRA\n"); fprintf(fp, "# TABLE ROWS: %d\n", mrw->GetTableRecordCount(index)); fprintf(fp, "# TABLE COLS: %d\n", mrw->GetTableFieldCount(index)-1); Slf_TABLE_FIELD *ADSA = new Slf_TABLE_FIELD[mrw->GetTableFieldCount(index)+1]; mrw->GetTableFieldInfo(index, ADSA); for(int ads = 0; ads < mrw->GetTableFieldCount(index); ads++) { if(del_col.contains(QString::number(ads))) continue; QString thisColName = resultColName_map[ADSA[ads].Name]; if(thisColName == "") thisColName = ADSA[ads].Name; fprintf(fp, thisColName.toStdString().c_str()); fprintf(fp, "\t"); } fprintf(fp, "\n"); delete[] ADSA; //fprintf(fp, "ZONE THICK RESULT GR SP RT RXO AC DEN CNL R4 RN RL POR POR2 PORT PORN PORA PORD SW PERM DGA SH SAND LIME DOLM OTHR ANDE BASD DIAB CONG TUFF GRAV BASA ANHY SALT COAL OIL POOROIL OILWATER WATEROIL GAS POORGAS GASWATER WATERGAS CORE\n"); #pragma endregion RESULT_CRA head LPSResult_NOR(mrw, index, fp, del_col,Zero); } else if(QString(name) == "VRESULT_VCRA") { #pragma region VRESULT_VCRA head QStringList del_col; del_col << "0" << "2"; //删除的列 fprintf(fp, "# WELL NAME: "); fprintf(fp, WellName.toStdString().c_str()); fprintf(fp, "\n# TABLE NAME: VRESULT_VCRA\n"); fprintf(fp, "# TABLE ROWS: %d\n", mrw->GetTableRecordCount(index)); fprintf(fp, "# TABLE COLS: %d\n", mrw->GetTableFieldCount(index)-1); Slf_TABLE_FIELD *ADSA = new Slf_TABLE_FIELD[mrw->GetTableFieldCount(index)+1]; mrw->GetTableFieldInfo(index, ADSA); for(int ads = 0; ads < mrw->GetTableFieldCount(index); ads++) { if(del_col.contains(QString::number(ads))) continue; QString thisColName = resultColName_map[ADSA[ads].Name]; if(thisColName == "") thisColName = ADSA[ads].Name; fprintf(fp, thisColName.toStdString().c_str()); fprintf(fp, "\t"); } fprintf(fp, "\n"); delete[] ADSA; //fprintf(fp, "ZONE THICK RESULT VGR VSP VRT VRXO VAC VDEN VCNL VR4 VRN VRL VPOR VPOR2 VPORT VPORN VPORA VPORD VSW VPERM VDGA VSH VSAND VLIME VDOLM VOTHR VANDE VBASD VDIAB VCONG VTUFF VGRAV VBASA VANHY VSALT VCOAL OIL POOROIL OILWATER WATEROIL GAS POORGAS GASWATER WATERGAS CORE\n"); #pragma endregion VRESULT_VCRA head LPSResult_NOR(mrw, index, fp, del_col,Zero); } else { QStringList del_col; LPSResult_NOR(mrw, index, fp, del_col,Zero); } mrw->CloseTable(index); fclose(fp); } } } #pragma endregion 输出结论 /* #pragma region 输出井壁取心 if(lps_lib.CoreId>=0) { WALLCORE_DATA mCore; QString cs=PathName+WellName.toLower()+".plt"; if((fp=fopen(cs.toStdString().c_str(),"w+t"))==NULL) { return; } fprintf(fp,"/CORE/ 860 12\n"); int index=mrw->OpenTable("SWALL_CORE"); if(index>=0) { for(int i=0;iGetTableRecordCount(index);i++) { mrw->ReadTable(index,i+1,(void*)&mCore); fprintf(fp,"-%8.1f %4d %3d %5d\n",mCore.Depth,mCore.CoreColor,mCore.CoreOil,mCore.CoreLith); } } mrw->CloseTable(index); fclose(fp); } #pragma endregion 输出井壁取心 */ // gjtutou #pragma region 胜利图头数据生成 bool canGenGJTutou = true; bool hasPltFile = true; //plt文件标志 Slf_FILE_MESSAGE rMessage; QMap tableMap; QMap pltMap; // inf_1 CLogIO * pLogio = dynamic_cast(mrw); if(NULL != pLogio) pLogio->GetFileMessage(rMessage); else{ canGenGJTutou = false; //QMessageBox::information(nullptr,QString::fromLocal8Bit("提示"),QString::fromLocal8Bit("gjtutou生成失败!")); } // inf_3 CString slfPathTemp = mrw->GetWellName(); char *ch = slfPathTemp.GetString(); QString slfPath1 = QString(ch); int iTemp = (slfPath1.lastIndexOf("/") > slfPath1.lastIndexOf("\\")) ? slfPath1.lastIndexOf("/") : slfPath1.lastIndexOf("\\"); QString slfPath = slfPath1.left(iTemp); QString slfName = slfPath1.right(slfPath1.size() - iTemp); slfName = slfName.split(".")[0]; QString pltPath = slfPath + slfName + ".plt"; QFile pltFile(pltPath); if(!pltFile.open(QIODevice::ReadOnly | QIODevice::Text)){ //QMessageBox::information(nullptr,QString::fromLocal8Bit("提示"),QString::fromLocal8Bit("gjtutou生成失败!")); //canGenGJTutou = false; } else{ while(!pltFile.atEnd()){ QByteArray line = pltFile.readLine(); QString str(line); QStringList lineList = str.split(" "); for(int i = 0; i < lineList.size(); i++){ if(lineList[i] == " " || lineList[i] == ""){ lineList.removeAt(i); i--; } } QStringList valueList; if(lineList.size()) { if(lineList[0] == "GR"){valueList.append(QString("%1").arg(lineList[1]));valueList.append(QString("%1").arg(lineList[2]));pltMap.insert("GR", valueList);} else if(lineList[0] == "LVDL"){valueList.append(QString("%1").arg(lineList[1]));valueList.append(QString("%1").arg(lineList[2]));pltMap.insert("LVDL", valueList);} else if(lineList[0] == "CAL"){valueList.append(QString("%1").arg(lineList[1]));valueList.append(QString("%1").arg(lineList[2]));pltMap.insert("CAL", valueList);} else if(lineList[0] == "CBL"){valueList.append(QString("%1").arg(lineList[1]));valueList.append(QString("%1").arg(lineList[2]));pltMap.insert("CBL", valueList);} else if(lineList[0] == "AC"){valueList.append(QString("%1").arg(lineList[1]));valueList.append(QString("%1").arg(lineList[2]));pltMap.insert("AC", valueList);} else if(lineList[0] == "CCL"){valueList.append(QString("%1").arg(lineList[1]));valueList.append(QString("%1").arg(lineList[2]));pltMap.insert("CCL", valueList);} } } pltFile.close(); } // inf_2 int tableID = mrw->OpenTable("测井信息表"); if(tableID < 0){ canGenGJTutou = false; //QMessageBox::information(nullptr,QString::fromLocal8Bit("提示"),QString::fromLocal8Bit("gjtutou生成失败!")); } else { int count = mrw->GetTableFieldCount(tableID); int rec = mrw->GetTableRecordCount(tableID); Slf_TABLE_FIELD *Table_Field = new Slf_TABLE_FIELD[count+1]; mrw->GetTableFieldInfo(tableID, Table_Field); char *buf = new char[mrw->GetTableRecordLength(tableID)]; //临时存放 for(int i = 0; i < rec; i++) { char strKey[500]; char strValue[500]; mrw->ReadTable(tableID, i + 1, buf); int len = 0; QStringList strs=GetSimilarCurves("测井信息表"); strs.removeAll(""); for(int j = 0; j < count; j++) { if(j % 2 == 0) GetData(Table_Field[j].RepCode, &buf[len], strKey); else{ GetData(Table_Field[j].RepCode, &buf[len], strValue); if(strs.indexOf(strKey)>-1) strcpy(strValue,setdec(strValue,2,true).toStdString().c_str()); if(tableMap.find(QString(strKey)) == tableMap.end()) tableMap.insert(QString(strKey), QString(strValue)); else if(QString(strValue).size() > 1){ if(QString(strKey) == "所用曲线") tableMap.insert(QString("变密度所用曲线"), QString(strValue)); else tableMap[QString(strKey)] = QString(strValue); } } len += Table_Field[j].Length; } } delete []buf; delete []Table_Field; } if(canGenGJTutou){ PathName; // 输出路径 rMessage; //基本信息 tableMap; //gj信息表格 pltMap; //plt文件 lps_gjtutouGen(PathName, WellName, rMessage, tableMap, pltMap); lps_tutouGen(PathName, WellName, rMessage, tableMap, pltMap); } #pragma endregion 胜利图头数据生成 #pragma region g1 g2输出 if(outputG1_ind != -1) lps_g1g2Gen(mrw, PathName, QString(OutInf[outputG1_ind].Name)); if(outputG2_ind != -1) lps_g1g2Gen(mrw, PathName, QString(OutInf[outputG2_ind].Name)); #pragma endregion } //whp 数据输出 void TranToAscii(CMemRdWt *mrw,QString Outfile,float sdep,float edep,float rlev,int NumObject0,OUTOBJECTINF *OutInf0,int FileType,bool IsFeet) { #pragma region 获取双深度和采样,默认情况 int Ind[1024]; float minsdep = 99999, maxedep = -9999, maxrlev = -9999; for(int i = 0; i < NumObject0; i++) { Ind[i] = mrw->FindSlfObjectIndex(OutInf0[i].Name,0); if(Ind[i]<0)continue; int type=mrw->GetObjectType(Ind[i]); if(type == CURVE_OBJECT )//常规曲线 { //Slf_CURVE curve; int index = mrw->OpenCurve(OutInf0[i].Name); Slf_CURVE pInfo; mrw->GetCurveInfo(index,&pInfo); if(minsdep > pInfo.StartDepth) minsdep = pInfo.StartDepth; if(maxedep < pInfo.EndDepth) maxedep = pInfo.EndDepth; if(maxrlev < pInfo.DepLevel) maxrlev = pInfo.DepLevel; } else if(type==WAVE_OBJECT)//阵列曲线 { Slf_WAVE pInfo; int index=mrw->OpenWave(OutInf0[i].Name); mrw->GetWaveInfo(index,&pInfo); //20201228 GZL add if(minsdep > pInfo.StartDepth) minsdep = pInfo.StartDepth; if(maxedep < pInfo.EndDepth) maxedep = pInfo.EndDepth; if(maxrlev < pInfo.DepLevel) maxrlev = pInfo.DepLevel; } } #pragma endregion //20201228 GZL add if(sdep == -9999.0) sdep = minsdep; if(edep == -9999.0) edep = maxedep; if(rlev == -9999.0) rlev = maxrlev; #pragma region TranToAscii float temps,tempe,tempr; temps = sdep;tempe = edep;tempr = rlev; //FileType 0--LogPlus文本,2-Forward文本,3-LAS,4-excel float DepScale=GetDepScale(mrw,IsFeet); int DataNum[1024]; Slf_CURVE pInfo;Slf_WAVE wpInfo; int WaveNum=0; int NumObject=0; OUTOBJECTINF *OutInf=new OUTOBJECTINF[NumObject0];//挑出数据表 for(int j=0;jOpenWave(OutInf[NumObject].Name); mrw->GetWaveInfo(Ind[NumObject],&wpInfo); DataNum[NumObject]=wpInfo.TimeSamples; WaveNum++; NumObject++; } else if(OutInf0[j].ObjectType==1) { OutInf[NumObject]=OutInf0[j]; Ind[NumObject]=mrw->OpenCurve(OutInf[NumObject].Name); DataNum[NumObject]=1; NumObject++; } } if(NumObject<=0) { delete []OutInf; return; } FILE *fp; fp=fopen(Outfile.toStdString().c_str(),"wt+"); if(fp==NULL) { QMessageBox::information(NULL,"提示","打开输出文件"+Outfile+"失败"); return; } if(FileType==0)//ascii { fprintf(fp,"SLF_TEXT_FORMAT\nSTDEP ENDEP RLEV NUMLOG\n"); fprintf(fp,"%.3f %.3f %.5f %d\n",sdep*DepScale,edep*DepScale,rlev*DepScale,NumObject); fprintf(fp,"1"); for(int i=0;i=0)fprintf(fp,"%s\t",OutInf[j].OutName); } } else if(FileType==1)//Forward 文本 { fprintf(fp,"FORWARD_TEXT_FORMAT_1.0\n"); fprintf(fp,"STDEP = %10.4f\n",sdep*DepScale); fprintf(fp,"ENDEP = %10.4f\n",edep*DepScale); fprintf(fp,"RLEV = %10.4f\n",rlev*DepScale); fprintf(fp,"CURVENAME = "); BOOL IsFirst=1; for(int j=0;j=0) { if(IsFirst) { IsFirst=0;fprintf(fp,"%s",OutInf[j].OutName); } else fprintf(fp,", %s",OutInf[j].OutName); } } fprintf(fp,"\nEND\n#DEPTH "); for(int j=0;j=0)fprintf(fp,"%11s",OutInf[j].OutName); } } else//las { Slf_FILE_MESSAGE message; // mrw->GetMessage(message); mrw->GetFileMessage(message); fprintf(fp,"# This Data Is Tran By LogPlus From %s\n",mrw->GetWellName().GetString()); fprintf(fp,"~Version Information Block\n");//版本信息 if(!WaveNum)fprintf(fp,"VERS. 2.00: CWLS LOG ASCII STANDARD - VERSION 2.000000\n"); else fprintf(fp,"VERS. 3.0: CWLS log ASCII Standard Version 3.00\n");//有波列数据 fprintf(fp,"WRAP. NO: One Line Per Depth Step\n"); fprintf(fp,"#\n"); fprintf(fp,"~Well Information Block\n");//钻井信息 fprintf(fp,"#MNEM.UNIT Data Information\n"); fprintf(fp,"#---------- ------------------------------------------ ----------------\n"); if(!IsFeet) { fprintf(fp,"STRT.M %-10.4f: Start Depth\n",sdep*DepScale); fprintf(fp,"STOP.M %-10.4f: End Depth\n",edep*DepScale); fprintf(fp,"STEP.M %-10.4f: Depth increment\n",rlev*DepScale); } else { fprintf(fp,"STRT.FEET %-10.4f: Start Depth\n",sdep*DepScale); fprintf(fp,"STOP.FEET %-10.4f: End Depth\n",edep*DepScale); fprintf(fp,"STEP.FEET %-10.4f: Depth increment\n",rlev*DepScale); } fprintf(fp,"NULL. -999.2500:\n"); fprintf(fp,"COMP. %40s: COMPANY\n",message.OilCompanyName); fprintf(fp,"WELL. %40s: WELL\n",message.WellName); fprintf(fp,"FLD . %40s: FIELD\n",message.AreaName); fprintf(fp,"CNTY. : COUNTY\n"); fprintf(fp,"STAT. : STATE\n"); fprintf(fp,"CTRY. : COUNTRY\n"); fprintf(fp,"SRVC. %40s: SERVICE COMPANY\n",message.LogCompanyName); //CTime tim=CTime(message.LoggingDate); char ss[80]=""; //sprintf(ss,"%d-%d-%d",tim.GetYear(),tim.GetMonth(),tim.GetDay()); fprintf(fp,"DATE. %40s: DATE\n",ss); fprintf(fp,"API . : API NUMBER\n"); fprintf(fp," UWI . : UWI NUMBER\n"); fprintf(fp,"#\n"); fprintf(fp,"~Curve Information Block\n"); fprintf(fp,"#MNEM.UNIT API CODE Curve Description\n"); fprintf(fp,"#---------- ------------- -------------------\n"); if(!IsFeet)fprintf(fp,"DEPT .M : Depth in Meters\n"); else fprintf(fp,"DEPT .FEET : Depth in Feet\n"); for( int j=0;j=0)for(int m=0;mSetStruct(&Inc,NULL,&Inp,NULL,&Conc,&Con,&Hd,NULL); mrw->Const(); mrw->In(); Hd.Dep=sdep;Hd.Depo=sdep;Hd.Sdep=sdep;Hd.Edep=edep; int TotalDataNum=0; for(int j=0;j Hd.Edep) _dep = Hd.Edep; fprintf(fp,"%-12.4lf",_dep * DepScale); mrw->In(Dep); for(int j=0;jFindSlfObjectIndex(OutInf[i].Name,0); if(Ind[i]<0)continue; int type=mrw->GetObjectType(Ind[i]); if(type == CURVE_OBJECT )//常规曲线 { //Slf_CURVE curve; int index = mrw->OpenCurve(OutInf[i].Name); Slf_CURVE pInfo; mrw->GetCurveInfo(index,&pInfo); if(minsdep > pInfo.StartDepth) minsdep = pInfo.StartDepth; if(maxedep < pInfo.EndDepth) maxedep = pInfo.EndDepth; if(maxrlev < pInfo.DepLevel) maxrlev = pInfo.DepLevel; if(minrlev > pInfo.DepLevel) minrlev = pInfo.DepLevel; } else if(type==WAVE_OBJECT)//阵列曲线 { Slf_WAVE pInfo; int index=mrw->OpenWave(OutInf[i].Name); mrw->GetWaveInfo(index,&pInfo); //20201228 GZL add if(minsdep > pInfo.StartDepth) minsdep = pInfo.StartDepth; if(maxedep < pInfo.EndDepth) maxedep = pInfo.EndDepth; if(maxrlev < pInfo.DepLevel) maxrlev = pInfo.DepLevel; if(minrlev > pInfo.DepLevel) minrlev = pInfo.DepLevel; } } FILE *fp; QString cs=Outfile; QFileInfo ss(Outfile); if(ss.suffix().isEmpty()) cs=cs+".dat"; else if(ss.suffix().compare("dat",Qt::CaseInsensitive)) cs.replace("."+ss.suffix(),".dat"); if(ss.exists()) { CString str; str.Format("当前dat文件%s已存在,是否覆盖?",Outfile.toUtf8().data()); if(QMessageBox::information(NULL,"提示",QString(str.GetString()),QMessageBox::Yes|QMessageBox::No)==QMessageBox::Yes) { QDir ss; ss.remove(cs); } else return; } if((fp=fopen((char*)cs.toStdString().c_str(),"wb"))==NULL) { return; } memset(&hdt,0,sizeof(hdt)); QFileInfo fs(mrw->GetWellName().GetString()); strncpy(hdt.WelNam,fs.baseName().toStdString().c_str(),8); hdt.a=1101; hdt.a1=8; hdt.a2=1101; hdt.a3=8; hdt.a4=1109; hdt.a5=1; hdt.a6=2; hdt.a7[0]=1; hdt.a7[1]=0; hdt.a7[2]=0; hdt.a7[3]=0; hdt.a7[4]=0; hdt.a7[5]=0; hdt.a7[6]=0; hdt.a7[7]=16; hdt.a7[8]=17; hdt.a7[9]=18; hdt.a7[10]=19; hdt.a7[11]=20; strcpy(hdt.ico," "); strncpy(hdt.iwell,fs.baseName().toStdString().c_str(),8); strcpy(hdt.t1," "); strcpy(hdt.t2," "); strcpy(hdt.OptrNam," "); hdt.numlog=NumObject; if(hdt.numlog>50) hdt.numlog=50; // if(hdt.numlog<50) hdt.maxlog=50; // else hdt.maxlog=NumObject; hdt.rlev=1109; hdt.stdep=0; hdt.endep=0; fwrite(&hdt.WelNam,8,1,fp); fwrite(&hdt.a,2,1,fp); fwrite(&hdt.rlev,0xd2-0xa,1,fp); hdt.log=new char[hdt.maxlog*8]; memset(hdt.log,' ',hdt.maxlog*8); for(int i=0;i8) len=8; strncpy(&hdt.log[i*8],OutInf[i].OutName,len); } fwrite (hdt.log, 8 , hdt.maxlog , fp ); hdt.dim=new int[hdt.maxlog]; memset(hdt.dim,0,sizeof(int)*hdt.maxlog); for(int i=0;iOpenWave(OutInf[j].Name); if(ind<0) { ind=mrw->OpenCurve(OutInf[j].Name); if(ind>-1) { mrw->GetCurveInfo(ind,&curve); ssdep=curve.StartDepth; eedep=curve.EndDepth; rrlev=curve.DepLevel; } } else { iswave=1; mrw->GetWaveInfo(ind,&wave); ssdep=wave.StartDepth; eedep=wave.EndDepth; rrlev=wave.DepLevel; } float sdep=Outsdep; float edep=Outedep; float rlev=Outrlev; if(sdep==-9999) sdep=ssdep; if(edep==-9999) edep=eedep; if(rlev==-9999) rlev=rrlev; int num=(edep-sdep)/rlev+1.5; if(j==0) { hdt.addr[j]=1109; hdt.taddr[j]=sdep; } else { hdt.addr[j]+=2*num; hdt.taddr[j]=sdep; } hdt.lens[j]=num*(iswave?wave.TimeSamples:1); hdt.sdeps[j]=sdep; hdt.edeps[j]=(num-1)/(1.0/rlev); hdt.rlevs[j]=rlev; hdt.points[j]=iswave?wave.TimeSamples:1; } fwrite(&hdt.addr[j],4,1,fp); fwrite(&hdt.sdeps[j],4,1,fp); } fwrite(hdt.lens,4,hdt.maxlog,fp); fwrite(hdt.sdeps,4,hdt.maxlog,fp); fwrite(hdt.edeps,4,hdt.maxlog,fp); for ( int j=0 ; jOpenWave(OutInf[j].Name); if(ind>-1){ mrw->ReadWave(ind,hdt.sdeps[j],hdt.lens[j]/hdt.points[j],buf1); } else { ind=mrw->OpenCurve(OutInf[j].Name); if(ind>-1){ mrw->ReadCurve(ind,hdt.sdeps[j],hdt.lens[j],buf1); } } for(int i=0;i Menu=GetZoneOrder(s2w,false); QList> s2ws; for (int n=0;nFindSlfObjectIndex(OutInf[i].Name,0); if(index<0)continue; int type = mrw->GetObjectType(index); if(type == 0 || type > 5) { m_HaveTranTable = m_Tran.HaveTranTable(); break;//TableList.append(QString(OutInf[i].Name)); } } //if(TableList.count())=m_Tran.HaveTranTable(TableList); int num=mrw->GetObjectCount(); for(int i = 0; i < NumObject; i++) { Ind[i] = mrw->FindSlfObjectIndex(OutInf[i].Name,0); if(Ind[i] < 0) continue; int type = mrw->GetObjectType(Ind[i]); if(type==CURVE_OBJECT )//常规曲线 { #pragma region 常规曲线 //Slf_CURVE curve; int index=mrw->OpenCurve(OutInf[i].Name); #pragma region 提取SLF数据信息 --> Slf_CURVE pInfo //curve info Slf_CURVE pInfo; mrw->GetCurveInfo(index, &pInfo); //20201228 GZL add if(temps == -9999.0) Outsdep = pInfo.StartDepth; if(tempe == -9999.0) Outedep = pInfo.EndDepth; if(tempr == -9999.0) Outrlev = pInfo.DepLevel; //dataLen DWORD count = mrw->GetTableRecordCount(index); DWORD len = count * mrw->GetTableRecordLength(index); char *buf=new char[len+10]; mrw->ReadCurve(index, pInfo.StartDepth, count, (void *)buf); //实际数据 /*CString str; str.Format("%s",pInfo.DepthUnit); if(str.Find("feet")>=0||str.Find("英尺")>=0)strcpy(pInfo.DepthUnit,"feet"); else strcpy(pInfo.DepthUnit,"m");*/ if(IsFeet) strcpy(pInfo.DepthUnit, "feet"); else strcpy(pInfo.DepthUnit, "m"); #pragma endregion #pragma region pInfo --> Slf_CURVE wInfo Slf_CURVE wInfo; strncpy(wInfo.Name,pInfo.Name,16); strncpy(wInfo.AliasName,pInfo.AliasName,16); strncpy(wInfo.AliasUnit,pInfo.AliasUnit,16); strncpy(wInfo.Unit,pInfo.Unit,8); strncpy(wInfo.DepthUnit, pInfo.DepthUnit, 8); wInfo.CodeLen = pInfo.CodeLen; //20201229 GZL change wInfo.StartDepth = Outsdep * DepScale; wInfo.EndDepth = Outedep * DepScale; wInfo.DepLevel = Outrlev * DepScale; /* if(pInfo.StartDepth > Outsdep) wInfo.StartDepth = pInfo.StartDepth*DepScale; // 曲线的起始深度 else wInfo.StartDepth = Outsdep*DepScale; if(pInfo.EndDepth < Outedep) wInfo.EndDepth = pInfo.EndDepth*DepScale; // 曲线的结束深度 else wInfo.EndDepth = Outedep*DepScale;*/ wInfo.MaxValue = pInfo.MaxValue; wInfo.MinValue = pInfo.MinValue; wInfo.RepCode = pInfo.RepCode; #pragma endregion #pragma region 写wis曲线 int index_dest = WisFile.OpenCurve(&wInfo); MyDataTypeEnum vVdl; vVdl.vchar = buf; #pragma region 20201218 GZL add 重采样 //准备 int point2 = (wInfo.EndDepth - wInfo.StartDepth) / wInfo.DepLevel + 0.5; float *rfBuffer, *fvVdl; //fvVdl用于存放转为float的原始数据 //用于存放重采样后的对应格式的数据 short *rsBuffer; int *riBuffer; unsigned int *rlBuffer; double *rdBuffer; if(wInfo.RepCode == 1 ||wInfo.RepCode == 2 || wInfo.RepCode == 3 ||wInfo.RepCode == 4 || wInfo.RepCode == 5) rfBuffer = new float[point2]; //用于存放重采样结果float #pragma region 开辟空间用于存放转换为float和其他格式的数据 if(wInfo.RepCode == 2){ //short转float,用于reRlev方法调用 fvVdl = new float[int(count)]; rsBuffer = new short[point2]; } else if(wInfo.RepCode == 1){ //int转float,用于reRlev方法调用 fvVdl = new float[int(count)]; riBuffer = new int[point2]; } else if(wInfo.RepCode == 3){ //long转float,用于reRlev方法调用 fvVdl = new float[int(count)]; rlBuffer = new unsigned int[point2]; } else if(wInfo.RepCode == 5){ //double转float,用于reRlev方法调用 fvVdl = new float[int(count)]; rdBuffer = new double[point2]; } #pragma endregion if(Outrlev != pInfo.DepLevel || pInfo.StartDepth != wInfo.StartDepth || pInfo.EndDepth != wInfo.EndDepth){ if(wInfo.RepCode == 2){ //short for(int i = 0; i < int(count); i++) fvVdl[i] = float(vVdl.vshort[i]); //short转flaot数据 reRlev(fvVdl, Outrlev, pInfo.DepLevel, int(count), wInfo.StartDepth, pInfo.StartDepth, rfBuffer, point2,1,false); for(int i = 0; i < point2; i++) rsBuffer[i] = short(rfBuffer[i]); //将输出转为其他所需格式 vVdl.vshort = rsBuffer; } else if(wInfo.RepCode == 1){ //int for(int i = 0; i < int(count); i++) fvVdl[i] = float(vVdl.vint[i]); //int转float数据 reRlev(fvVdl, Outrlev, pInfo.DepLevel, int(count), wInfo.StartDepth, pInfo.StartDepth, rfBuffer, point2,1,false); for(int i = 0; i < point2; i++) riBuffer[i] = int(rfBuffer[i]); //将输出转为其他所需格式 vVdl.vint = riBuffer; } else if(wInfo.RepCode == 3){ //long for(int i = 0; i < int(count); i++) fvVdl[i] = float(vVdl.vlong[i]); //long转float数据 reRlev(fvVdl, Outrlev, pInfo.DepLevel, int(count), wInfo.StartDepth, pInfo.StartDepth, rfBuffer, point2,1,false); for(int i = 0; i < point2; i++) rlBuffer[i] = (unsigned int)(rfBuffer[i]); //将输出转为其他所需格式 vVdl.vlong = rlBuffer; } else if(wInfo.RepCode == 5){ //double for(int i = 0; i < int(count); i++) fvVdl[i] = float(vVdl.vlong[i]); //double转float数据 reRlev(fvVdl, Outrlev, pInfo.DepLevel, int(count), wInfo.StartDepth, pInfo.StartDepth, rfBuffer, point2,1, false); for(int i = 0; i < point2; i++) rdBuffer[i] = double(rfBuffer[i]); //将输出转为其他所需格式 vVdl.vdouble = rdBuffer; } else if (wInfo.RepCode == 4){ reRlev(vVdl.vfloat, Outrlev, pInfo.DepLevel, int(count), wInfo.StartDepth, pInfo.StartDepth, rfBuffer, point2,1,true); vVdl.vfloat = rfBuffer; } } #pragma endregion switch(wInfo.RepCode) { #pragma region 写入 case 1: WisFile.WriteCurve(index_dest,wInfo.StartDepth,point2,vVdl.vint); break; case 2: WisFile.WriteCurve(index_dest,wInfo.StartDepth,point2,vVdl.vshort); break; case 3: WisFile.WriteCurve(index_dest,wInfo.StartDepth,point2,vVdl.vlong); break; case 4: WisFile.WriteCurve(index_dest,wInfo.StartDepth,point2,vVdl.vfloat); break; case 5: WisFile.WriteCurve(index_dest,wInfo.StartDepth,point2,vVdl.vdouble); break; case 6: WisFile.WriteCurve(index_dest,wInfo.StartDepth,point2,vVdl.vchar); break; case 7: WisFile.WriteCurve(index_dest,wInfo.StartDepth,point2,vVdl.vchar); break; case 8: WisFile.WriteCurve(index_dest,wInfo.StartDepth,point2,vVdl.vuchar); break; case 9: WisFile.WriteCurve(index_dest,wInfo.StartDepth,point2,vVdl.vushort); break; case 10: WisFile.WriteCurve(index_dest,wInfo.StartDepth,point2,vVdl.vuint); break; case 11: WisFile.WriteCurve(index_dest,wInfo.StartDepth,point2,vVdl.vuint); break; #pragma endregion } #pragma endregion delete[] buf; if(wInfo.RepCode == 1 ||wInfo.RepCode == 2 || wInfo.RepCode == 3 ||wInfo.RepCode == 4 || wInfo.RepCode == 5){ delete[] rfBuffer; if(wInfo.RepCode != 4) delete[] fvVdl; } //else delete rfBuffer; if(wInfo.RepCode == 1) delete[] riBuffer; //else delete riBuffer; if(wInfo.RepCode == 2) delete[] rsBuffer; //else delete rsBuffer; if(wInfo.RepCode == 3) delete[] rlBuffer; //else delete rlBuffer; if(wInfo.RepCode == 5) delete[] rdBuffer; //else delete rdBuffer; mrw->CloseCurve(index); WisFile.CloseCurve(index_dest); #pragma endregion } else if(type == WAVE_OBJECT)//阵列曲线 { #pragma region wave信息 --> pInfo Slf_WAVE pInfo; int index=mrw->OpenWave(OutInf[i].Name); mrw->GetWaveInfo(index,&pInfo); //20201229 GZL add if(temps == -9999.0) Outsdep = pInfo.StartDepth; if(tempe == -9999.0) Outedep = pInfo.EndDepth; if(tempr == -9999.0) Outrlev = pInfo.DepLevel; DWORD count=mrw->GetTableRecordCount(index); DWORD len=count*mrw->GetTableRecordLength(index); char *buf=new char[len+1]; mrw->ReadWave(index,pInfo.StartDepth,count,(void *)buf); /*CString str; str.Format("%s",pInfo.DepthUnit); if(str.Find("feet")>=0||str.Find("英尺")>=0)strcpy(pInfo.DepthUnit,"feet"); else strcpy(pInfo.DepthUnit,"m");*/ if(IsFeet)strcpy(pInfo.DepthUnit,"feet"); else strcpy(pInfo.DepthUnit,"m"); /* if(OutFlag==2) { strncpy(pInfo.Name,OutInf[i].OutName,16); strncpy(pInfo.AliasName,OutInf[i].AliasName,16); strncpy(pInfo.Unit,OutInf[i].Unit,8); strncpy(pInfo.AliasUnit,OutInf[i].AliasUnit,16); }*/ #pragma endregion #pragma region pInfo --> Slf_WAVE wInfo; Slf_WAVE wInfo; strncpy(wInfo.Name,pInfo.Name,16); strncpy(wInfo.AliasName,pInfo.AliasName,16); strncpy(wInfo.AliasUnit,pInfo.AliasUnit,16); strncpy(wInfo.Unit,pInfo.Unit,8); strncpy(wInfo.DepthUnit,pInfo.DepthUnit,8); strncpy(wInfo.TimeUnit,pInfo.TimeUnit,8); wInfo.CodeLen=pInfo.CodeLen; wInfo.MaxValue=pInfo.MaxValue; wInfo.MinValue=pInfo.MinValue; wInfo.RepCode=pInfo.RepCode; wInfo.StartTime=pInfo.StartTime; wInfo.TimeLevel=pInfo.TimeLevel; wInfo.TimeSamples=pInfo.TimeSamples; wInfo.SamplePoint=pInfo.SamplePoint; wInfo.ArrayNum=pInfo.ArrayNum; //20201229 GZL change wInfo.StartDepth = Outsdep * DepScale; wInfo.EndDepth = Outedep * DepScale; wInfo.DepLevel = Outrlev * DepScale; /* if(pInfo.StartDepth > Outsdep) wInfo.StartDepth = pInfo.StartDepth*DepScale; // 曲线的起始深度 else wInfo.StartDepth = Outsdep*DepScale; if(pInfo.EndDepth < Outedep) wInfo.EndDepth = pInfo.EndDepth*DepScale; // 曲线的结束深度 else wInfo.EndDepth = Outedep*DepScale; */ #pragma endregion #pragma region wInfo --> WisFile MyDataTypeEnum vVdl; vVdl.vchar=buf; #pragma region 20201218 GZL add 重采样 //准备 int point2 = (wInfo.EndDepth - wInfo.StartDepth) / wInfo.DepLevel + 0.5; float *rfBuffer, *fvVdl; short *rsBuffer; if(wInfo.RepCode == 2 || wInfo.RepCode == 4) rfBuffer = new float[point2 * wInfo.TimeSamples]; if(wInfo.RepCode == 2){ //short转float,用于reRlev方法调用 fvVdl = new float[int(count) * wInfo.TimeSamples]; rsBuffer = new short[point2 * wInfo.TimeSamples]; } if(Outrlev != pInfo.DepLevel || pInfo.StartDepth != wInfo.StartDepth || pInfo.EndDepth != wInfo.EndDepth){ if(wInfo.RepCode == 2){ for(int i = 0; i < int(count) * wInfo.TimeSamples; i++) //short转float数据 fvVdl[i] = float(vVdl.vshort[i]); reRlev(fvVdl, Outrlev, pInfo.DepLevel, int(count), wInfo.StartDepth, pInfo.StartDepth, rfBuffer, point2, wInfo.TimeSamples,false); for(int i = 0; i < point2 * wInfo.TimeSamples; i++) rsBuffer[i] = short(rfBuffer[i]); vVdl.vshort = rsBuffer; } else if (wInfo.RepCode == 4){ reRlev(vVdl.vfloat, Outrlev, pInfo.DepLevel, int(count), wInfo.StartDepth, pInfo.StartDepth, rfBuffer, point2, wInfo.TimeSamples,true); vVdl.vfloat = rfBuffer; } } #pragma endregion int index_dest=WisFile.OpenWave(&wInfo); // WisFile.WriteWave(index_dest,pInfo.StartDepth,count,(void *)buf); switch(wInfo.RepCode) { #pragma region 写入 case 2: WisFile.WriteWave(index_dest,wInfo.StartDepth,point2,vVdl.vshort); break; case 4: WisFile.WriteWave(index_dest,wInfo.StartDepth,point2,vVdl.vfloat); break; case 6: WisFile.WriteWave(index_dest,wInfo.StartDepth,point2,vVdl.vchar); break; case 7: WisFile.WriteWave(index_dest,wInfo.StartDepth,point2,vVdl.vchar); break; default: { CString str; str.Format("阵列曲线%s的数据类型不是char、short或float,转换结果可能不正确\r\n请于程序员联系",wInfo.Name); AfxMessageBox(str); //处理方法:参照CWisLogIO ::ReadWaveToFloatBuf } WisFile.WriteWave(index_dest,wInfo.StartDepth,point2,vVdl.vchar); break; #pragma endregion } #pragma endregion #pragma region free delete[] buf; if(wInfo.RepCode == 2 || wInfo.RepCode == 4){ delete[] rfBuffer; } //else delete rfBuffer; if(wInfo.RepCode == 2) delete[] fvVdl; //else delete fvVdl; if(wInfo.RepCode == 2) delete[] rsBuffer; //else delete rsBuffer; mrw->CloseWave(index); WisFile.CloseWave(index_dest); #pragma endregion } else if(type==FMT_OBJECT)//fmt曲线 深度单位??? { #pragma region FMT int in=mrw->OpenFMT(OutInf[i].Name); Slf_FMT inf; mrw->GetFMTInfo(in,&inf); Slf_FMT wInfo; strncpy(wInfo.Name,inf.Name,16); strncpy(wInfo.AliasName,inf.AliasName,16); strncpy(wInfo.AliasUnit,inf.AliasUnit,16); strncpy(wInfo.Unit,inf.Unit,8); strncpy(wInfo.DepthUnit,inf.DepthUnit,8); strncpy(wInfo.TimeUnit,inf.TimeUnit,8); wInfo.MaxValue=inf.MaxValue; wInfo.MinValue=inf.MinValue; wInfo.TotalPointNum=inf.TotalPointNum; wInfo.MaxPointSamples=inf.MaxPointSamples;//可能需要给大点 wInfo.StartTime=inf.StartTime; wInfo.TimeLevel=inf.TimeLevel; wInfo.TimeSamples=inf.TimeSamples; int out=WisFile.OpenFMT(&wInfo); float pDep; float *buf; buf=new float[inf.TimeSamples+2]; for(int ii=0;iiReadFMT(in,ii+1,&pDep,buf); WisFile.WriteFMT(out,ii+1,pDep,buf,point); } mrw->CloseFMT(in); WisFile.CloseFMT(out); delete []buf; #pragma endregion } else if(type==TDT_OBJECT )//tdt曲线 { /*int in=mrw->OpenTDT(OutInf[i].Name); Slf_TDT inf; mrw->GetTDTInfo(in,&inf); DWORD TdtPointNum=inf.TotalLogNumber; inf.TotalLogNumber=0; if(OutFlag==2) { strncpy(inf.Name,OutInf[i].OutName,16); strncpy(inf.AliasName,OutInf[i].AliasName,16); strncpy(inf.Unit,OutInf[i].Unit,8); strncpy(inf.AliasUnit,OutInf[i].AliasUnit,8); } Slf_TDT wInfo; strncpy(wInfo.Name,inf.Name,16); strncpy(wInfo.AliasName,inf.AliasName,16); strncpy(wInfo.AliasUnit,inf.AliasUnit,16); strncpy(wInfo.Unit,inf.Unit,8); strncpy(wInfo.DepthUnit,inf.DepthUnit,8); strncpy(wInfo.TimeUnit,inf.TimeUnit,8); strncpy(wInfo.LogTimeUnit,inf.LogTimeUnit,8); wInfo.MaxValue=inf.MaxValue; wInfo.MinValue=inf.MinValue; wInfo.TotalLogNumber=inf.TotalLogNumber; wInfo.MaxLogSamples=inf.MaxLogSamples;//可能需要给大点 int out=WisFile.OpenTDT(&wInfo); float *pDep; pDep=new float[TdtPointNum]; long *pLogTime; pLogTime=new long[TdtPointNum]; long MaxDataPointNum=mrw->GetTDTAllLogTime(in,pLogTime); TDT_DATA **tdt; tdt=new TDT_DATA*[TdtPointNum]; for(int ii=0;iiReadTDT(in,n+1,&pLogTime[n],tdt[n]); WisFile.WriteTDT(out,n+1,pLogTime[n],tdt[n],point[n]); } mrw->CloseTDT(in); WisFile.CloseTDT(out); delete []pDep; delete []pLogTime; for(int ii=0;iiOpenStream(OutInf[i].Name); DWORD length=mrw->GetStreamLength(in); DWORD byte; char *buf=new char[length+10]; mrw->ReadStream(in,length,&byte,(char *)buf); mrw->CloseStream(in); int index; /*if(OutFlag==2) { index=WisFile.CreateStream(PARA_OBJECT,OutInf[i].OutName); } else */index=WisFile.CreateStream(PARA_OBJECT,OutInf[i].Name); DWORD dw; WisFile.SetStreamLength(index,length); WisFile.WriteStream(index,length,&dw,buf); WisFile.CloseStream(index); #pragma endregion } else //table//数据表 { #pragma region 数据表 int in=mrw->OpenTable(OutInf[i].Name); int fieldNum=mrw->GetTableFieldCount(in); Slf_TABLE_FIELD *tableFieldInfo=new Slf_TABLE_FIELD[fieldNum+1]; mrw->GetTableFieldInfo(in,tableFieldInfo); int RecCount=mrw->GetTableRecordCount(in); int Lenght=mrw->GetTableRecordLength(in); int out=-1; bool IsS2W=1;// slf转wis int TranTable=-1;//是第TranTable个需要字段匹配和转换的表,<0-不是 if(m_HaveTranTable)TranTable=m_Tran.GetTranTableNo(QString(OutInf[i].Name),fieldNum,&tableFieldInfo[0],IsS2W); QString tmane; if(TranTable>-1) tmane=m_Tran.m_TTI[TranTable].InName; else tmane=OutInf[i].Name; out=WisFile.CreateTable(0,tmane.toStdString().c_str()); if(out<0) { AfxMessageBox("产生表\""+tmane+"\"错误!"); delete tableFieldInfo; continue; } Slf_TABLE_FIELD *wtableFieldInfo; char *buffer; //检查该表是不是需要字段匹配和转换的表 if(TranTable < 0) { wtableFieldInfo=new Slf_TABLE_FIELD[fieldNum+1]; buffer=new char [Lenght+1]; for(int n=0;nReadTable(in,ii+1,buffer); WisFile.WriteTable(out,ii+1,buffer); } } else {//有匹配表 int wisfieldNum=m_Tran.WisDefTable[TranTable].ZdNum; wtableFieldInfo=new Slf_TABLE_FIELD[wisfieldNum+1]; // Slf_OBJECT_FIELD *pf=new Slf_OBJECT_FIELD[wisfieldNum+1]; m_Tran.GetOutInf(TranTable); int pos=0; for(int n=0;nIsChange=true; char *buf=new char [500]; float v1,v2,val; for(int j=0;jGetTableFieldData(in,m_Tran.SlfDefTable[TranTable].tinfo[n].Name,buf,j+1); if(m_Tran.WisDefTable[TranTable].tinfo[n].RepCode==6)WisFile.SetTableFieldData(out,m_Tran.outinf[n].InName1,buf,j+1); else { if(tableFieldInfo[k].Reserved>0&&tableFieldInfo[k].Reserved<=mrw->m_MenuNumber) { QString cs=toString(buf); if(s2ws.size()>tableFieldInfo[k].Reserved-1) { QMap cc=s2ws[tableFieldInfo[k].Reserved-1]; if(cc.size())strcpy(buf,cc[cs].toStdString().c_str()); else { QStringList css=m_Tran.SlfDefTable[TranTable].menuinfo[k].split(","); if(css.size()>val) cs=css[cs.toInt()]; css=m_Tran.WisDefTable[TranTable].menuinfo[n].split(","); val=css.indexOf(cs); if(val<0) { QStringList strs=QString("空,空白,白色").split(","); for(int kk=0;kk-1) break; } if(val<0) { val=0; } } cs=toString(val); strcpy(buf,cs.toStdString().c_str()); } } else{ QStringList css=m_Tran.SlfDefTable[TranTable].menuinfo[k].split(","); if(css.size()>val) cs=css[cs.toInt()]; css=m_Tran.WisDefTable[TranTable].menuinfo[n].split(","); val=css.indexOf(cs); if(val<0) { QStringList strs=QString("空,空白,白色").split(","); for(int kk=0;kk-1) break; } if(val<0) { val=0; } } cs=toString(val); strcpy(buf,cs.toStdString().c_str()); } } sscanf(buf,"%f",&val); WisFile.SetTableFieldData(out,m_Tran.WisDefTable[TranTable].tinfo[n].Name,(char *)&val,j+1); } break; } /*else//计算变量 { //检查InName1和InName2哪个字段在匹配表中单独匹配过,如BTMDEP-THICK中的BTMDEP已和EDEP匹配 int HaveInName1=-1,HaveInName2=-1; for(int k=0;kGetTableFieldData(in,m_Tran.outinf[n].OutName,buf,j+1); sscanf(buf,"%f",&val); if(HaveInName1>=0){ mrw->GetTableFieldData(in,m_Tran.outinf[HaveInName1].OutName,buf,j+1); sscanf(buf,"%f",&v1); v2=val-v1; if(m_Tran.outinf[n].Sep=="-")v2*=-1; WisFile.SetTableFieldData(out,m_Tran.outinf[n].InName2,(char *)&v2,j+1); } else { mrw->GetTableFieldData(in,m_Tran.outinf[HaveInName2].OutName,buf,j+1); sscanf(buf,"%f",&v2); v2=val-v1; if(m_Tran.outinf[n].Sep=="-") v1=val+v2; else v1=val-v2; WisFile.SetTableFieldData(out,m_Tran.outinf[n].InName1,(char *)&v1,j+1); } } */ } } } delete buf; } mrw->CloseTable(in); WisFile.CloseTable(out); delete []tableFieldInfo; delete []wtableFieldInfo; delete buffer; } #pragma endregion } WisFile.Close(); #pragma endregion } void TranToDLis(CMemRdWt *mrw,QString Outfile,float Outsdep,float Outedep,float Outrlev,int NumObject,OUTOBJECTINF *OutInf,bool IsFeet) { } void TranToLis(CMemRdWt *mrw,QString Outfile,float Outsdep,float Outedep,float Outrlev,int NumObject,OUTOBJECTINF *OutInf,bool IsFeet) { #pragma region 获取双深度和采样,默认情况 int Ind[1024]; float minsdep = 99999, maxedep = -9999, maxrlev = -9999, minrlev = 9999; for(int i = 0; i < NumObject; i++) { Ind[i] = mrw->FindSlfObjectIndex(OutInf[i].Name,0); if(Ind[i]<0)continue; int type=mrw->GetObjectType(Ind[i]); if(type == CURVE_OBJECT )//常规曲线 { //Slf_CURVE curve; int index = mrw->OpenCurve(OutInf[i].Name); Slf_CURVE pInfo; mrw->GetCurveInfo(index,&pInfo); if(minsdep > pInfo.StartDepth) minsdep = pInfo.StartDepth; if(maxedep < pInfo.EndDepth) maxedep = pInfo.EndDepth; if(maxrlev < pInfo.DepLevel) maxrlev = pInfo.DepLevel; if(minrlev > pInfo.DepLevel) minrlev = pInfo.DepLevel; } else if(type==WAVE_OBJECT)//阵列曲线 { Slf_WAVE pInfo; int index=mrw->OpenWave(OutInf[i].Name); mrw->GetWaveInfo(index,&pInfo); //20201228 GZL add if(minsdep > pInfo.StartDepth) minsdep = pInfo.StartDepth; if(maxedep < pInfo.EndDepth) maxedep = pInfo.EndDepth; if(maxrlev < pInfo.DepLevel) maxrlev = pInfo.DepLevel; if(minrlev > pInfo.DepLevel) minrlev = pInfo.DepLevel; } } #pragma endregion //20201228 GZL add if(Outsdep == -9999.0) Outsdep = minsdep; if(Outedep == -9999.0) Outedep = maxedep; if(Outrlev == -9999.0) Outrlev = maxrlev; CString str; //打开xtf文件 QFile w(Outfile); if(w.exists()) { str.Format("当前Lis文件%s已存在,是否覆盖?",Outfile.toUtf8().data()); if(QMessageBox::information(NULL,"提示",QString(str.GetString()),QMessageBox::Yes|QMessageBox::No)==QMessageBox::Yes) { w.remove(); } } DepthProgress MyDepthProgress; MyDepthProgress.CreatProgress(0,100,"正在回转lis数据"); float DepScale=GetDepScale(mrw,IsFeet); //打开lis文件 MyLisLib lis_lib; int ret=lis_lib.OpenDataFile(Outfile,1); if(ret<1) { str.Format("%s 创建失败 !!!",Outfile.toUtf8().data()); AfxMessageBox(str); return; } char Name[64]; int num=mrw->GetObjectCount(); int record_len = 0; int DataPtr[512]={0}; //曲线数据在一条记录里的指针位置 int DataLen[512]={0}; //每个曲线/阵列的数据长度,单位,字节 int curve_num=0; int DataIndex[512]={0}; float LisStartDepth=0; //lIS开始深度 int LisRecordTotal=0; //总记录点数 LisStartDepth=Outsdep; lis_lib.Frame_Step= Outrlev; if(Outrlev < 0) //上测 { lis_lib.LogDir=-1; } else { lis_lib.LogDir=1; } //whp change 2018.10.15 保证读写一致 LisRecordTotal = (int)(( Outedep - Outsdep) / Outrlev+1.5);//0.5); for(int i = 0; i < NumObject; i++) { Ind[i] = mrw->FindSlfObjectIndex(OutInf[i].Name,0); if(Ind[i]<0)continue; int type=mrw->GetObjectType(Ind[i]); if(type == CURVE_OBJECT )//常规曲线 { #pragma region 常规曲线 //Slf_CURVE curve; int index = mrw->OpenCurve(OutInf[i].Name); Slf_CURVE pInfo; mrw->GetCurveInfo(index,&pInfo); DWORD count=mrw->GetTableRecordCount(index); DWORD len=count*mrw->GetTableRecordLength(index); if(IsFeet)strcpy(OutInf[i].AliasUnit,"feet"); else strcpy(OutInf[i].AliasUnit,"m"); strncpy(lis_lib.Curve[curve_num].Name,OutInf[i].OutName,4); strncpy(lis_lib.Curve[curve_num].Unit,OutInf[i].AliasUnit,4); lis_lib.Curve[curve_num].DataType=68; lis_lib.Curve[curve_num].DotCount=1; DataIndex[curve_num]=index; switch(pInfo.RepCode) { case REPR_CHAR: case REPR_UCHAR: lis_lib.Curve[curve_num].DataType=79; //ushort,short lis_lib.Curve[curve_num].DotCount=maxrlev/pInfo.DepLevel+0.5; if(lis_lib.Curve[curve_num].DotCount<1) lis_lib.Curve[curve_num].DotCount=1; lis_lib.Curve[curve_num].BytesNum=2*lis_lib.Curve[curve_num].DotCount; DataPtr[curve_num]=record_len; DataLen[curve_num]=2*lis_lib.Curve[curve_num].DotCount; record_len+=DataLen[curve_num]; curve_num++; // WisFile.WriteCurve(index_dest,wInfo.StartDepth,count,vVdl.vushord); break; case REPR_SHORT: case REPR_USHORT: lis_lib.Curve[curve_num].DataType=73; //ushort,short lis_lib.Curve[curve_num].DotCount=maxrlev/pInfo.DepLevel+0.5; if(lis_lib.Curve[curve_num].DotCount<1) lis_lib.Curve[curve_num].DotCount=1; lis_lib.Curve[curve_num].BytesNum=4*lis_lib.Curve[curve_num].DotCount; DataPtr[curve_num]=record_len; DataLen[curve_num]=4*lis_lib.Curve[curve_num].DotCount; record_len+=DataLen[curve_num]; curve_num++; // WisFile.WriteCurve(index_dest,wInfo.StartDepth,count,vVdl.vushord); break; case REPR_FLOAT: default: lis_lib.Curve[curve_num].DataType=68; //float lis_lib.Curve[curve_num].DotCount=maxrlev/pInfo.DepLevel+0.5; if(lis_lib.Curve[curve_num].DotCount<1) lis_lib.Curve[curve_num].DotCount=1; lis_lib.Curve[curve_num].BytesNum=4*lis_lib.Curve[curve_num].DotCount;//wis_lib.Channle[i]->DimInfo[0].Size; DataPtr[curve_num]=record_len; DataLen[curve_num]=lis_lib.Curve[curve_num].BytesNum; record_len+=DataLen[curve_num]; curve_num++; break; } // delete buf; mrw->CloseCurve(index); //WisFile.CloseCurve(index_dest); #pragma endregion } else if(type==WAVE_OBJECT)//阵列曲线 { #pragma region 阵列曲线 Slf_WAVE pInfo; int index=mrw->OpenWave(OutInf[i].Name); mrw->GetWaveInfo(index,&pInfo); DWORD count=mrw->GetTableRecordCount(index); DWORD len=count*mrw->GetTableRecordLength(index); if(IsFeet)strcpy(OutInf[i].AliasUnit,"feet"); else strcpy(OutInf[i].AliasUnit,"m"); strncpy(lis_lib.Curve[curve_num].Name,OutInf[i].OutName,4); strncpy(lis_lib.Curve[curve_num].Unit,OutInf[i].AliasUnit,4); lis_lib.Curve[curve_num].DataType=68; lis_lib.Curve[curve_num].DotCount=1; DataIndex[curve_num]=index+1000; //加1000当标志用 switch(pInfo.RepCode) { case REPR_CHAR: case REPR_UCHAR: lis_lib.Curve[curve_num].DataType=79; //ushort,short lis_lib.Curve[curve_num].DotCount=maxrlev/pInfo.DepLevel+0.5; if(lis_lib.Curve[curve_num].DotCount<1) lis_lib.Curve[curve_num].DotCount=1; lis_lib.Curve[curve_num].BytesNum=2*lis_lib.Curve[curve_num].DotCount*pInfo.TimeSamples;; DataPtr[curve_num]=record_len; DataLen[curve_num]=lis_lib.Curve[curve_num].BytesNum; record_len+=DataLen[curve_num]; curve_num++; // WisFile.WriteCurve(index_dest,wInfo.StartDepth,count,vVdl.vushord); break; case REPR_SHORT: case REPR_USHORT: lis_lib.Curve[curve_num].DataType=73; //ushort,short lis_lib.Curve[curve_num].DotCount=maxrlev/pInfo.DepLevel+0.5; if(lis_lib.Curve[curve_num].DotCount<1) lis_lib.Curve[curve_num].DotCount=1; lis_lib.Curve[curve_num].BytesNum=4*lis_lib.Curve[curve_num].DotCount*pInfo.TimeSamples;; DataPtr[curve_num]=record_len; DataLen[curve_num]=lis_lib.Curve[curve_num].BytesNum; record_len+=DataLen[curve_num]; curve_num++; // WisFile.WriteCurve(index_dest,wInfo.StartDepth,count,vVdl.vushord); break; case REPR_FLOAT: { lis_lib.Curve[curve_num].DataType=68; //float lis_lib.Curve[curve_num].DotCount=maxrlev/pInfo.DepLevel+0.5; if(lis_lib.Curve[curve_num].DotCount<1) lis_lib.Curve[curve_num].DotCount=1; lis_lib.Curve[curve_num].BytesNum=4*lis_lib.Curve[curve_num].DotCount*pInfo.TimeSamples; DataPtr[curve_num]=record_len; DataLen[curve_num]=lis_lib.Curve[curve_num].BytesNum; record_len+=DataLen[curve_num]; curve_num++; // WisFile.WriteCurve(index_dest,wInfo.StartDepth,count,vVdl.vfloat); break; } case REPR_INT: { lis_lib.Curve[curve_num].DataType=73; //int lis_lib.Curve[curve_num].DotCount=maxrlev/pInfo.DepLevel+0.5; lis_lib.Curve[curve_num].BytesNum=4*lis_lib.Curve[curve_num].DotCount*pInfo.TimeSamples; DataPtr[curve_num]=record_len; DataLen[curve_num]=lis_lib.Curve[curve_num].BytesNum; record_len+=DataLen[curve_num]; if(lis_lib.Curve[curve_num].DotCount<1) lis_lib.Curve[curve_num].DotCount=1; curve_num++; // WisFile.WriteCurve(index_dest,wInfo.StartDepth,count,vVdl.vfloat); break; } default: { lis_lib.Curve[curve_num].DataType=68; //float lis_lib.Curve[curve_num].DotCount=maxrlev/pInfo.DepLevel+0.5; if(lis_lib.Curve[curve_num].DotCount<1) lis_lib.Curve[curve_num].DotCount=1; lis_lib.Curve[curve_num].BytesNum=4*lis_lib.Curve[curve_num].DotCount*pInfo.TimeSamples; DataPtr[curve_num]=record_len; DataLen[curve_num]=lis_lib.Curve[curve_num].BytesNum; record_len+=DataLen[curve_num]; curve_num++; // WisFile.WriteCurve(index_dest,wInfo.StartDepth,count,vVdl.vfloat); break; } } //delete buf; mrw->CloseWave(index); #pragma endregion } } lis_lib.CurveNum=curve_num; if(lis_lib.CurveNum>256) { QMessageBox::information(NULL,"提示","曲线条数大于256"); } lis_lib.Year=2010; lis_lib.Month=10; lis_lib.Day=10; lis_lib.FillLisFileHead(); //写文件头 lis_lib.FillLisDataBolck(); //写曲线信息 lis_lib.Begin_Write(LisStartDepth-minrlev); //开始写数据,写入开始深度 byte *data_buf=new byte[64*5024]; memset(data_buf,0,64*5024); float *tdata_buf=new float[10024]; memset(data_buf,0,10024*4); for(int i=0;iGetCurveInfo(DataIndex[j],&pInfo); mrw->ReadCurveToFloatBuf(DataIndex[j],depth,lis_lib.Curve[j].DotCount,tdata_buf); for(int k=0;kSetData(rep_cord,(char*)&data_buf[DataPtr[j]]+k*vlen,&tdata_buf[k]); } } else{ Slf_WAVE pInfo; mrw->GetWaveInfo(DataIndex[j]-1000,&pInfo); mrw->ReadWaveToFloatBuf(DataIndex[j]-1000,depth,lis_lib.Curve[j].DotCount,tdata_buf); for(int k=0;kSetData(rep_cord,(char*)&data_buf[DataPtr[j]+k*vlen],&tdata_buf[k]); } } } lis_lib.Data_Write(data_buf); } lis_lib.End_Flush(); lis_lib.FillLisFileTail(); lis_lib.CloseDataFile(); mrw->Close(); delete data_buf; delete tdata_buf; } void TranToXtf(CMemRdWt *mrw,QString Outfile,float Outsdep,float Outedep,float Outrlev,int NumObject,OUTOBJECTINF *OutInf,bool IsFeet) { //20201229 GZL add float temps,tempe,tempr; temps = Outsdep; tempe = Outedep; tempr = Outrlev; //遗留问题:只处理了ushort、short或float三种数据类型 CString str; //打开xtf文件 QFile w(Outfile); if(w.exists()) { str.Format("当前xtf文件%s已存在,是否覆盖?",Outfile.toUtf8().data()); if(QMessageBox::information(NULL,"提示",QString(str.GetString()),QMessageBox::Yes|QMessageBox::No)==QMessageBox::Yes) { w.remove(); } } float DepScale = GetDepScale(mrw, IsFeet); int Ind[1024]; //打开xtf文件 MyXtfLib xtf_lib; xtf_lib.MaxCurveNum = 512; //最多512条 xtf_lib.SystemDepthUnit = "m"; //默认为m xtf_lib.BlockNum = 8; //头为8块 int ret = xtf_lib.OpenDataFile(Outfile,1); if(ret < 1) { QMessageBox::information(NULL,"提示",Outfile+"输出文件创建失败 !!!"); return; } char Name[64]; //int num=mrw->GetObjectCount(); int DataLen[512]={0}; //每个曲线/阵列的数据长度,单位,字节 int curve_num=0; int DataIndex[512]={0}; for(int i = 0; i < NumObject; i++) { Ind[i] = mrw->FindSlfObjectIndex(OutInf[i].Name, 0); if(Ind[i] < 0) continue; int type = mrw->GetObjectType(Ind[i]); if(type == CURVE_OBJECT )//常规曲线 基本信息 { #pragma region curve //Slf_CURVE curve; int index=mrw->OpenCurve(OutInf[i].Name); Slf_CURVE pInfo; mrw->GetCurveInfo(index,&pInfo); //20201228 GZL add if(temps == -9999.0) Outsdep = pInfo.StartDepth; if(tempe == -9999.0) Outedep = pInfo.EndDepth; if(tempr == -9999.0) Outrlev = pInfo.DepLevel; DWORD count = mrw->GetTableRecordCount(index); DWORD len = count * mrw->GetTableRecordLength(index); xtf_lib.FileStartDepth = Outsdep; xtf_lib.FileEndDepth = Outedep; xtf_lib.FileDepthLevel= (float)fabs(Outrlev)/*pInfo.DepLevel*/; // char *buf = new char[len + 10]; // mrw->ReadCurve(index, pInfo.StartDepth, count, (void *)buf); if(IsFeet) strcpy(pInfo.DepthUnit,"feet"); else strcpy(pInfo.DepthUnit,"m"); xtf_lib.CurveName[curve_num] = OutInf[i].OutName; xtf_lib.CurveUnit[curve_num] = OutInf[i].AliasUnit; //20201221 GZL change reRlevDepthLevel(xtf_lib, pInfo, Outsdep, Outedep, Outrlev, curve_num); xtf_lib.CurveFlag[curve_num] = 0; xtf_lib.CurveDataType[curve_num]=4; xtf_lib.CurveDimNum[curve_num]=1; //常规数据 xtf_lib.CurveE1Num[curve_num]=1; xtf_lib.CurveE2Num[curve_num]=0; xtf_lib.CurveE3Num[curve_num] = 0; xtf_lib.CurveType[curve_num]=1; xtf_lib.CurveSampleNum[curve_num] = (xtf_lib.CurveEndDepth[curve_num] - xtf_lib.CurveStartDepth[curve_num]) / xtf_lib.CurveDepthLevel[curve_num] + 1.5 /*count*/; xtf_lib.CurveVert[curve_num] = 1; xtf_lib.CurveHorz[curve_num] = 1; int length=4; DataIndex[curve_num] = index; switch(pInfo.RepCode) { case REPR_UINT: //float { xtf_lib.CurveDataType[curve_num] = 4; //float //20201222 GZL add DataLen[curve_num] = writeSEPos(xtf_lib, 4, curve_num, 1); curve_num++; } break; case REPR_INT: //float { xtf_lib.CurveDataType[curve_num] = 10; //float //20201222 GZL add DataLen[curve_num] = writeSEPos(xtf_lib, 4, curve_num, 1); curve_num++; } break; case REPR_FLOAT: //float { xtf_lib.CurveDataType[curve_num] = 4; //float //20201222 GZL add DataLen[curve_num] = writeSEPos(xtf_lib, 4, curve_num, 1); curve_num++; } break; case REPR_DOUBLE: case REPR_LONG: { xtf_lib.CurveDataType[curve_num] = 8; //double //20201222 GZL add DataLen[curve_num] = writeSEPos(xtf_lib, 8, curve_num, 1); curve_num++; } break; case REPR_CHAR: { xtf_lib.CurveDataType[curve_num]=7; //uchar xtf_lib.CurveDimNum[curve_num]=1; //常规数据 xtf_lib.CurveE1Num[curve_num]=1; xtf_lib.CurveE2Num[curve_num]=0; xtf_lib.CurveE3Num[curve_num] = 0; xtf_lib.CurveType[curve_num]=1; xtf_lib.CurveSampleNum[curve_num] = (xtf_lib.CurveEndDepth[curve_num] - xtf_lib.CurveStartDepth[curve_num]) / xtf_lib.CurveDepthLevel[curve_num] + 0.5 /*count*/; xtf_lib.CurveVert[curve_num] = 1; xtf_lib.CurveHorz[curve_num] = 1; DataLen[curve_num] = writeSEPos(xtf_lib, 1, curve_num, 1); curve_num++; } break; case REPR_UCHAR: { xtf_lib.CurveDataType[curve_num]=2; //uchar xtf_lib.CurveDimNum[curve_num]=1; //常规数据 xtf_lib.CurveE1Num[curve_num]=1; xtf_lib.CurveE2Num[curve_num]=0; xtf_lib.CurveE3Num[curve_num] = 0; xtf_lib.CurveType[curve_num]=1; xtf_lib.CurveSampleNum[curve_num] = (xtf_lib.CurveEndDepth[curve_num] - xtf_lib.CurveStartDepth[curve_num]) / xtf_lib.CurveDepthLevel[curve_num] + 0.5 /*count*/; xtf_lib.CurveVert[curve_num] = 1; xtf_lib.CurveHorz[curve_num] = 1; DataLen[curve_num] = writeSEPos(xtf_lib, 2, curve_num, 1); curve_num++; } break; case REPR_SHORT: { xtf_lib.CurveDataType[curve_num]=2; //short xtf_lib.CurveDimNum[curve_num]=1; //常规数据 xtf_lib.CurveE1Num[curve_num]=1; xtf_lib.CurveE2Num[curve_num]=0; xtf_lib.CurveE3Num[curve_num] = 0; xtf_lib.CurveType[curve_num]=1; xtf_lib.CurveSampleNum[curve_num] = (xtf_lib.CurveEndDepth[curve_num] - xtf_lib.CurveStartDepth[curve_num]) / xtf_lib.CurveDepthLevel[curve_num] + 0.5 /*count*/; xtf_lib.CurveVert[curve_num] = 1; xtf_lib.CurveHorz[curve_num] = 1; DataLen[curve_num] = writeSEPos(xtf_lib, 2, curve_num, 1); curve_num++; } break; case REPR_USHORT: { xtf_lib.CurveDataType[curve_num]=10; //short xtf_lib.CurveDimNum[curve_num]=1; //常规数据 xtf_lib.CurveE1Num[curve_num]=1; xtf_lib.CurveE2Num[curve_num]=0; xtf_lib.CurveE3Num[curve_num] = 0; xtf_lib.CurveType[curve_num]=1; xtf_lib.CurveSampleNum[curve_num] = (xtf_lib.CurveEndDepth[curve_num] - xtf_lib.CurveStartDepth[curve_num]) / xtf_lib.CurveDepthLevel[curve_num] + 0.5 /*count*/; xtf_lib.CurveVert[curve_num] = 1; xtf_lib.CurveHorz[curve_num] = 1; DataLen[curve_num] = writeSEPos(xtf_lib, 4, curve_num, 1); curve_num++; } break; default: { CString str; str.Format("曲线%s的数据类型不是ushort、short或float,转换结果可能不正确\r\n请于程序员联系",pInfo.Name); AfxMessageBox(str); //处理方法:参照CWisLogIO ::ReadWaveToFloatBuf } break; } // delete buf; mrw->CloseCurve(index); #pragma endregion } else if(type == WAVE_OBJECT)//阵列曲线 基本信息 { #pragma region Wave Slf_WAVE pInfo; int index=mrw->OpenWave(OutInf[i].Name); mrw->GetWaveInfo(index,&pInfo); //20201228 GZL add if(temps == -9999.0) Outsdep = pInfo.StartDepth; if(tempe == -9999.0) Outedep = pInfo.EndDepth; if(tempr == -9999.0) Outrlev = pInfo.DepLevel; DWORD count=mrw->GetTableRecordCount(index); DWORD len=count*mrw->GetTableRecordLength(index); if(IsFeet) strcpy(pInfo.DepthUnit,"feet"); else strcpy(pInfo.DepthUnit,"m"); xtf_lib.CurveName[curve_num]=OutInf[i].OutName; xtf_lib.CurveUnit[curve_num]=OutInf[i].AliasUnit; if(xtf_lib.CurveUnit[curve_num]=="") xtf_lib.CurveUnit[curve_num]=pInfo.AliasUnit; //20201221 GZL change reRlevDepthLevel(xtf_lib, pInfo, Outsdep, Outedep, Outrlev, curve_num); xtf_lib.CurveDepthLevel[curve_num]= Outrlev/*pInfo.DepLevel*/; xtf_lib.CurveFlag[curve_num] = 0; xtf_lib.curveInfo[curve_num].DACTimeOffset=pInfo.StartTime; xtf_lib.curveInfo[curve_num].TimeValuesLevel=pInfo.TimeLevel; xtf_lib.CurveDimNum[curve_num]=1; //阵列数据 if(pInfo.ArrayNum>1) { xtf_lib.CurveDimNum[curve_num]=2; xtf_lib.CurveE1Num[curve_num]=pInfo.SamplePoint; xtf_lib.CurveE2Num[curve_num]=pInfo.ArrayNum; xtf_lib.CurveType[curve_num] = 3; } else { xtf_lib.CurveDimNum[curve_num]=1; xtf_lib.CurveE1Num[curve_num]=pInfo.TimeSamples; xtf_lib.CurveE2Num[curve_num]=0; xtf_lib.CurveType[curve_num] = 2; //曲线类型 } xtf_lib.CurveE3Num[curve_num]=0; xtf_lib.CurveSampleNum[curve_num] = (xtf_lib.CurveEndDepth[curve_num] - xtf_lib.CurveStartDepth[curve_num]) / xtf_lib.CurveDepthLevel[curve_num] + 1.5 /*count*/; xtf_lib.CurveVert[curve_num] = 1; xtf_lib.CurveHorz[curve_num] = 1; DataIndex[curve_num]=index+1000; int length=0; xtf_lib.CurveDataType[curve_num]=4; switch(pInfo.RepCode) { case REPR_UINT: //float xtf_lib.CurveDataType[curve_num]=4; //float { DataLen[curve_num] = writeSEPos(xtf_lib, 4, curve_num, pInfo.TimeSamples); curve_num++; } break; case REPR_INT: //float xtf_lib.CurveDataType[curve_num]=10; //float { DataLen[curve_num] = writeSEPos(xtf_lib, 4, curve_num, pInfo.TimeSamples); curve_num++; } break; case REPR_FLOAT: //float xtf_lib.CurveDataType[curve_num]=4; //float { DataLen[curve_num] = writeSEPos(xtf_lib, 4, curve_num, pInfo.TimeSamples); curve_num++; } break; case REPR_DOUBLE: case REPR_LONG: xtf_lib.CurveDataType[curve_num]=8; //double { DataLen[curve_num] = writeSEPos(xtf_lib, 8, curve_num, pInfo.TimeSamples); curve_num++; } break; case REPR_CHAR: xtf_lib.CurveDataType[curve_num]=7; //uchar { DataLen[curve_num] = writeSEPos(xtf_lib, 1, curve_num, pInfo.TimeSamples); curve_num++; } break; case REPR_UCHAR: xtf_lib.CurveDataType[curve_num]=2; //uchar { DataLen[curve_num] = writeSEPos(xtf_lib, 2, curve_num, pInfo.TimeSamples); curve_num++; } break; case REPR_SHORT: xtf_lib.CurveDataType[curve_num]=2; //short { DataLen[curve_num] = writeSEPos(xtf_lib, 2, curve_num, pInfo.TimeSamples); curve_num++; } break; case REPR_USHORT: xtf_lib.CurveDataType[curve_num]=10; //short { DataLen[curve_num] = writeSEPos(xtf_lib, 4, curve_num, pInfo.TimeSamples); curve_num++; } break; default: { CString str; str.Format("阵列曲线%s的数据类型不是ushort、short或float,转换结果可能不正确\r\n请于程序员联系",pInfo.Name); AfxMessageBox(str); //处理方法:参照CWisLogIO ::ReadWaveToFloatBuf } } // delete buf; mrw->CloseWave(index); #pragma endregion } } xtf_lib.CurveNum = curve_num; xtf_lib.FileHead_Write(); bool rrlevvalue;//重采样标签 bool ifReDataPos = false; //数据位置信息是否更新 bool ifDelc = false; for(int iii = 0; iii < curve_num; iii++) { rrlevvalue = false; ifDelc = false; xtf_lib.CurveHead_Write(iii); byte* DataBuf = NULL; //1条曲线最大为200M #pragma region 曲线数据读取 --> DataBuf char *rcBuffer=NULL; //存重采样后转char数据 int point2 = (xtf_lib.CurveEndDepth[iii] - xtf_lib.CurveStartDepth[iii]) / xtf_lib.CurveDepthLevel[iii] + 1.5; int codeLength; int TimeSamplesn; int RepCode; //int OldIndex = mrw->OpenCurve((char *)&xtf_lib.CurveName[iii]); if(DataIndex[iii] < 1000) { #pragma region 常规曲线数据部分 Slf_CURVE curve; mrw->GetCurveInfo(DataIndex[iii],&curve); if(temps == -9999.0) Outsdep = curve.StartDepth; if(tempe == -9999.0) Outedep = curve.EndDepth; if(tempr == -9999.0) Outrlev = curve.DepLevel; //20201223 get原始曲线数据量 int count = int(mrw->GetTableRecordCount(DataIndex[iii])); codeLength = int(curve.CodeLen); RepCode = curve.RepCode; int codelen=curve.CodeLen; long long len; if(point2 > count) len = point2* codelen; else len = count * codelen; if(DataLen[iii]>len)len=DataLen[iii]; DataBuf=(byte*)VirtualAlloc(NULL,len,MEM_COMMIT,PAGE_READWRITE); //1条曲线最大为200M mrw->ReadCurve(DataIndex[iii], curve.StartDepth, count, (void *)(DataBuf)); #pragma region 20201218 GZL add 重采样 //准备 { float *rfBuffer = new float[point2]; if(!ifReDataPos){ ifReDataPos = true; xtf_lib.BlockNum = 8; //头为8块,reset } if(!ifDelc) ifDelc = true; rrlevvalue = true; switch(curve.RepCode){ case REPR_INT: //float codeLength = 4; reRlev((int*)DataBuf, Outrlev, curve.DepLevel, count, xtf_lib.CurveStartDepth[iii], curve.StartDepth, rfBuffer, point2,1,false); { int *rdBuffer = new int[point2]; //存放重采样short数据 for(int i = 0; i < point2; i++ ){ rdBuffer[i] = rfBuffer[i]; } delete rfBuffer; rcBuffer = (char *)rdBuffer; } break; case REPR_UINT: //float codeLength = 4; reRlev((uint*)DataBuf, Outrlev, curve.DepLevel, count, xtf_lib.CurveStartDepth[iii], curve.StartDepth, rfBuffer, point2,1,true); rcBuffer = (char *)rfBuffer; break; case REPR_FLOAT: //float codeLength = 4; reRlev((float*)DataBuf, Outrlev, curve.DepLevel, count, xtf_lib.CurveStartDepth[iii], curve.StartDepth, rfBuffer, point2,1,true); rcBuffer = (char *)rfBuffer; break; case REPR_DOUBLE: codeLength = 8; reRlev((double*)DataBuf, Outrlev, curve.DepLevel, count, xtf_lib.CurveStartDepth[iii], curve.StartDepth, rfBuffer, point2, 1,true); { double *rdBuffer = new double[point2]; //存放重采样short数据 for(int i = 0; i < point2; i++ ){ rdBuffer[i] = rfBuffer[i]; } delete rfBuffer; rcBuffer = (char *)rdBuffer; } break; case REPR_LONG: { codeLength = 8; reRlev((LONGLONG*)DataBuf, Outrlev, curve.DepLevel, count, xtf_lib.CurveStartDepth[iii], curve.StartDepth, rfBuffer, point2, 1,true); double *rdBuffer = new double[point2]; //存放重采样short数据 for(int i = 0; i < point2; i++ ){ rdBuffer[i] = rfBuffer[i]; } delete rfBuffer; rcBuffer = (char *)rdBuffer; } break; case REPR_CHAR: codeLength = 1; reRlev((char*)DataBuf, Outrlev, curve.DepLevel, count, xtf_lib.CurveStartDepth[iii], curve.StartDepth, rfBuffer, point2, 1,false); { char *rsBuffer = new char[point2]; //存放重采样short数据 for(int i = 0; i < point2; i++ ){ rsBuffer[i] = rfBuffer[i]; } delete rfBuffer; rcBuffer = (char *)rsBuffer; } break; case REPR_UCHAR: codeLength = 2; reRlev((uchar*)DataBuf, Outrlev, curve.DepLevel, count, xtf_lib.CurveStartDepth[iii], curve.StartDepth, rfBuffer, point2, 1,false); { short *rsBuffer = new short[point2]; //存放重采样short数据 for(int i = 0; i < point2; i++ ){ rsBuffer[i] = rfBuffer[i]; } delete rfBuffer; rcBuffer = (char *)rsBuffer; } break; case REPR_SHORT: codeLength = 2; reRlev((short*)DataBuf, Outrlev, curve.DepLevel, count, xtf_lib.CurveStartDepth[iii], curve.StartDepth, rfBuffer, point2, 1,false); { short *rsBuffer = new short[point2]; //存放重采样short数据 for(int i = 0; i < point2; i++ ){ rsBuffer[i] = rfBuffer[i]; } delete rfBuffer; rcBuffer = (char *)rsBuffer; } break; case REPR_USHORT: codeLength = 4; reRlev((ushort*)DataBuf, Outrlev, curve.DepLevel, count, xtf_lib.CurveStartDepth[iii], curve.StartDepth, rfBuffer, point2, 1,false); { int *rsBuffer = new int[point2]; //存放重采样short数据 for(int i = 0; i < point2; i++ ){ rsBuffer[i] = rfBuffer[i]; } delete rfBuffer; rcBuffer = (char *)rsBuffer; } break; default: codeLength = curve.CodeLen; rcBuffer=(char*)rfBuffer; break; } } #pragma endregion #pragma endregion } else { #pragma region wave Slf_WAVE curve; mrw->GetWaveInfo(DataIndex[iii] - 1000,&curve); if(temps == -9999.0) Outsdep = curve.StartDepth; if(tempe == -9999.0) Outedep = curve.EndDepth; if(tempr == -9999.0) Outrlev = curve.DepLevel; //20201223 get原始曲线数据量 int count = int(mrw->GetTableRecordCount(DataIndex[iii]-1000)); RepCode = curve.RepCode; int codelen=curve.CodeLen; if(DataLen[iii+1]-DataLen[iii]>codelen)codelen=DataLen[iii+1]-DataLen[iii]; long long len; if(point2 > count) len = point2/*count*/ /*xtf_lib.CurveSampleNum[iii]*/ * codelen; else len = count * codelen; TimeSamplesn = curve.TimeSamples; len=len * curve.TimeSamples; if(DataLen[iii]>len)len=DataLen[iii]; DataBuf = (byte*)VirtualAlloc(NULL,len,MEM_COMMIT,PAGE_READWRITE); //1条曲线最大为200M mrw->ReadWave(DataIndex[iii]-1000, curve.StartDepth/*xtf_lib.CurveStartDepth[iii]*/, count /*xtf_lib.CurveSampleNum[iii]*/, (void *)(DataBuf)); #pragma region 20201218 GZL add 重采样 //准备 { float *rfBuffer = new float[point2 * curve.TimeSamples]; //存放重采样float数据 if(!ifReDataPos){ ifReDataPos = true; xtf_lib.BlockNum = 8; //头为8块,reset } if(!ifDelc) ifDelc = true; rrlevvalue = true; switch(curve.RepCode){ case REPR_INT: //float codeLength = 4; reRlev((int*)DataBuf, Outrlev, curve.DepLevel, count /*xtf_lib.CurveSampleNum[iii]*/, xtf_lib.CurveStartDepth[iii], curve.StartDepth, rfBuffer, point2, curve.TimeSamples,false); { int*rdBuffer = new int[point2 * curve.TimeSamples]; //存放重采样short数据 for(int i = 0; i < point2 * curve.TimeSamples; i++ ){ rdBuffer[i] = rfBuffer[i]; } rcBuffer=(char*)rdBuffer; delete rfBuffer; } break; case REPR_UINT: //float codeLength = 4; reRlev((int*)DataBuf, Outrlev, curve.DepLevel, count /*xtf_lib.CurveSampleNum[iii]*/, xtf_lib.CurveStartDepth[iii], curve.StartDepth, rfBuffer, point2, curve.TimeSamples,true); rcBuffer=(char*)rfBuffer; break; case REPR_FLOAT: //float codeLength = 4; reRlev((float*)DataBuf, Outrlev, curve.DepLevel, count /*xtf_lib.CurveSampleNum[iii]*/, xtf_lib.CurveStartDepth[iii], curve.StartDepth, rfBuffer, point2, curve.TimeSamples,true); rcBuffer=(char*)rfBuffer; break; case REPR_LONG: codeLength = 8; { reRlev((long long*)DataBuf, Outrlev, curve.DepLevel, count /*xtf_lib.CurveSampleNum[iii]*/, xtf_lib.CurveStartDepth[iii], curve.StartDepth, rfBuffer, point2, curve.TimeSamples,false); double*rdBuffer = new double[point2 * curve.TimeSamples]; //存放重采样short数据 for(int i = 0; i < point2 * curve.TimeSamples; i++ ){ rdBuffer[i] = rfBuffer[i]; } rcBuffer=(char*)rdBuffer; delete rfBuffer; } break; case REPR_DOUBLE: { codeLength = 8; reRlev((double*)DataBuf, Outrlev, curve.DepLevel, count /*xtf_lib.CurveSampleNum[iii]*/, xtf_lib.CurveStartDepth[iii], curve.StartDepth, rfBuffer, point2, curve.TimeSamples,false); double*rdBuffer = new double[point2 * curve.TimeSamples]; //存放重采样short数据 for(int i = 0; i < point2 * curve.TimeSamples; i++ ){ rdBuffer[i] = rfBuffer[i]; } rcBuffer=(char*)rdBuffer; delete rfBuffer; } break; case REPR_SHORT: { codeLength = 2; reRlev((short*)DataBuf, Outrlev, curve.DepLevel, count /*xtf_lib.CurveSampleNum[iii]*/, xtf_lib.CurveStartDepth[iii], curve.StartDepth, rfBuffer, point2, curve.TimeSamples,false); short*rsBuffer = new short[point2 * curve.TimeSamples]; //存放重采样short数据 for(int i = 0; i < point2 * curve.TimeSamples; i++ ){ rsBuffer[i] = rfBuffer[i]; } rcBuffer=(char*)rsBuffer; delete rfBuffer; break; } case REPR_USHORT: { codeLength = 4; reRlev((ushort*)DataBuf, Outrlev, curve.DepLevel, count /*xtf_lib.CurveSampleNum[iii]*/, xtf_lib.CurveStartDepth[iii], curve.StartDepth, rfBuffer, point2, curve.TimeSamples,false); int*rsBuffer = new int[point2 * curve.TimeSamples]; //存放重采样short数据 for(int i = 0; i < point2 * curve.TimeSamples; i++ ){ rsBuffer[i] = rfBuffer[i]; } rcBuffer=(char*)rsBuffer; delete rfBuffer; break; } break; case REPR_CHAR: { codeLength = 1; reRlev((short*)DataBuf, Outrlev, curve.DepLevel, count /*xtf_lib.CurveSampleNum[iii]*/, xtf_lib.CurveStartDepth[iii], curve.StartDepth, rfBuffer, point2, curve.TimeSamples,false); char*rsBuffer = new char[point2 * curve.TimeSamples]; //存放重采样short数据 for(int i = 0; i < point2 * curve.TimeSamples; i++ ){ rsBuffer[i] = rfBuffer[i]; } rcBuffer=(char*)rsBuffer; delete rfBuffer; break; } break; case REPR_UCHAR: { codeLength = 2; reRlev((short*)DataBuf, Outrlev, curve.DepLevel, count /*xtf_lib.CurveSampleNum[iii]*/, xtf_lib.CurveStartDepth[iii], curve.StartDepth, rfBuffer, point2, curve.TimeSamples,false); short*rsBuffer = new short[point2 * curve.TimeSamples]; //存放重采样short数据 for(int i = 0; i < point2 * curve.TimeSamples; i++ ){ rsBuffer[i] = rfBuffer[i]; } rcBuffer=(char*)rsBuffer; delete rfBuffer; break; } break; default: codeLength = curve.CodeLen; rcBuffer=(char *)rfBuffer; } } #pragma endregion #pragma endregion } #pragma endregion #pragma region reRlev data --> DataBuf[] if(rrlevvalue == true){ byte* rcBuffer_byte = (byte *)rcBuffer; if(DataIndex[iii] < 1000) { for(int i = 0; i < point2 * codeLength; i++) DataBuf[i] = rcBuffer_byte[i]; rrlevvalue = false; xtf_lib.CurveSampleNum[iii] = point2; DataLen[iii] = point2 * codeLength; } else{ for(int i = 0; i < point2 * codeLength * TimeSamplesn; i++) DataBuf[i] = rcBuffer_byte[i]; rrlevvalue = false; xtf_lib.CurveSampleNum[iii] = point2; DataLen[iii] = point2 * codeLength * TimeSamplesn; } if(rcBuffer) delete rcBuffer; } #pragma endregion #pragma region sun 工作站 if(xtf_lib.SystemCode != 1) //sun 工作站 { if(xtf_lib.CurveDataType[iii] == 2//REPR_SHORT || xtf_lib.CurveDataType[iii] == 9//REPR_USHORT ) //short ,ushort { int len = DataLen[iii] / 2; for(int k = 0; k < len; k++) { byte a = DataBuf[k*2]; DataBuf[k*2] = DataBuf[k*2+1]; DataBuf[k*2+1] = a; } } else if( xtf_lib.CurveDataType[iii] == 7//char ||xtf_lib.CurveDataType[iii] == 3//uchar ) //short ,ushort { } else if( xtf_lib.CurveDataType[iii] == 10//REPR_INT ||xtf_lib.CurveDataType[iii] == 11//REPR_UINT ) //short ,ushort { int len=DataLen[iii]/4; for(int k=0;k DataLen[iii])break; } byte yyy[4096] = {0}; int rrr = DataLen[iii] - ccc; if (rrr > 0) { xtf_lib.CurveRecord_Write( DataBuf, ccc, rrr ); xtf_lib.CurveRecord_Write( yyy, 0, 4096 - rrr ); //写补齐块; } #pragma endregion VirtualFree(DataBuf,0,MEM_RELEASE); } //xtf_lib.FileHead_Write(); xtf_lib.CloseDataFile(); delete xtf_lib.dataFile; mrw->Close(); } void lps_gjtutouGen(QString PathName, QString WellName, Slf_FILE_MESSAGE rMessage, QMap tableMap, QMap pltMap) { QString inpName = GJTUTOUFILENAME; QString cs = PathName + /*WellName.toLower() + '_' +*/ inpName; FILE *fp; if((fp = fopen(cs.toStdString().c_str(), "w+b")) == NULL){ QMessageBox::information(nullptr,QString::fromLocal8Bit("提示"),QString::fromLocal8Bit("gjtutou生成失败!")); return; } QString cs2 = PathName + GJVDLBITNAME; FILE *fp_vdl; if((fp_vdl = fopen(cs2.toStdString().c_str(), "w+b")) == NULL){ QMessageBox::information(nullptr,QString::fromLocal8Bit("提示"),QString::fromLocal8Bit("gjtutou生成失败!")); return; } QString str = ""; CGJtutouInfGenerator ttGen; str += ttGen.wellName_Gen(QString(rMessage.WellAliasName), QString("井号"), true); str += ttGen.wellDate_2row_Gen(tableMap["测井日期"], "测井日期"); str += ttGen.wellDate_2row_Gen(tableMap["固井时间"], "固井日期"); str += ttGen.Diameter_3_Gen(rMessage.Bit_Diameter, rMessage.Bit_Depth); str += ttGen.zeroWord("(尾管)", true, false, false); str += ttGen.numWord(tableMap["套管外径"], false, false, true); str += ttGen.blanksWord("套管外径"); str += ttGen.zeroWord("(阻位)", true, false, false); str += ttGen.numWord(tableMap["人工井底"], false, false, true); str += ttGen.blanksWord("人工井底"); str += ttGen.numWord(tableMap["测量井段"], false, false, true); str += ttGen.blanksWord("测量井段"); str += ttGen.numWord(QString(rMessage.AreaName), false, false, true); str += ttGen.blanksWord("地区"); str += ttGen.numWord(tableMap["水泥浆密度"], true, false, false); str += ttGen.zeroWord("0",false, false, true); str += ttGen.blanksWord("水泥浆密度"); str += ttGen.numWord(tableMap["钻井液密度1"], true, false, false); str += ttGen.numWord(tableMap["钻井液密度2"], false, false, true); str += ttGen.blanksWord("泥浆密度"); str += ttGen.numWord(tableMap["水泥上返高度"], false, false, true); str += ttGen.blanksWord("水泥上返高度"); str += ttGen.numWord(tableMap["凡尔位置"], false, false, true); str += ttGen.blanksWord("凡尔位置"); str += ttGen.numWord(tableMap["测井队别1"], true, false, false); str += ttGen.numWord(tableMap["测井队别2"], false, false, true); str += ttGen.blanksWord("井队"); str += ttGen.numWord(tableMap["仪器型号1"], true, false, false); str += ttGen.zeroWord("0", false, false, true); str += ttGen.blanksWord("仪器型号"); str += ttGen.curveGen(tableMap["变密度所用曲线"], "变密度所用曲线"); str += ttGen.voiceCurveGen(); str += ttGen.numWord(tableMap["解释员"], false, false, true); str += ttGen.blanksWord("解释员"); str += ttGen.scale_Gen(pltMap); //刻度 str += ttGen.numWord(tableMap["固井质量评估"], false, false, true); str += ttGen.blanksWord("固井质量评价"); str += ttGen.wellDateGen(tableMap["出图时间"], "出图时间", false); str += ttGen.techHeadGen(tableMap["技术说明"]); str += ttGen.techBodyGen(tableMap["技术说明"]); while(str.indexOf("\r\n") >= 0) str=str.replace("\r\n","\n"); fprintf(fp, str.toStdString().c_str()); fclose(fp); fprintf(fp_vdl, str.toStdString().c_str()); fclose(fp_vdl); return; } void lps_tutouGen(QString PathName, QString WellName, Slf_FILE_MESSAGE rMessage, QMap tableMap, QMap pltMap) { QString inpName = TUTOUFILENAME; QString cs = PathName + /*WellName.toLower() + '_' +*/ inpName; FILE *fp; if((fp = fopen(cs.toStdString().c_str(), "w+b")) == NULL){ QMessageBox::information(nullptr,QString::fromLocal8Bit("提示"),QString::fromLocal8Bit("文件无法打开,tutou.inp生成失败!")); return; } //QStringList tutouMapBit = TUTOUBITNAMELIST; for(int i = 0; i < QString(TUTOUBITNAMELIST).split(",").size(); i++){ FILE *fp2; if((fp2 = fopen((PathName + QString(TUTOUBITNAMELIST).split(",")[i]).toStdString().c_str(), "w+b")) != NULL){ fclose(fp2); } } QString str = ""; CGJtutouInfGenerator ttGen; str += ttGen.wellName_Gen(QString(rMessage.WellAliasName), QString("井 号"), true); str += ttGen.wellName_Gen(tableMap["测井队别1"], QString("队 别 1"), false); str += ttGen.wellName_Gen(tableMap["测井队别2"], QString("队 别 2"), false); str += ttGen.wellDateGen(tableMap["测井日期"], "测井日期----1", false); str += ttGen.blanksWord("0,'2008',0,'42',0,'88 测井日期----2"); str += ttGen.numWord(tableMap["测时井深"], false, false, true); str += ttGen.blanksWord("测时井深"); str += ttGen.Bushing_3_Gen(rMessage.Bushing_Inside_Diameter, rMessage.Bushing_Detpth); str += ttGen.Diameter_3_Gen(rMessage.Bit_Diameter, rMessage.Bit_Depth); str += ttGen.numWord(tableMap["仪器型号1"], true, false, false); str += ttGen.numWord(tableMap["仪器型号2"], false, false, true); str += ttGen.blanksWord("仪器型号"); str += ttGen.numWord(QString(rMessage.AreaName), false, false, true); str += ttGen.blanksWord("地区"); if(rMessage.Kelly > -99){ str += ttGen.numWord(QString("%1").arg(setdec(ConvertDataByFloat(rMessage.Kelly))), false, false, true); str += ttGen.blanksWord("补心高度");} else{ str += ttGen.zeroWord(QString("0"), false, false, true); str += ttGen.blanksWord("补心高度");} str += ttGen.numWord(tableMap["钻井液密度"], true, false, false); str += ttGen.numWord(tableMap["钻井液粘度"], true, false, false); str += ttGen.numWord(tableMap["18度钻井液电阻率"], false, false, true); str += ttGen.blanksWord("钻井液"); str += ttGen.numWord(tableMap["解释员"], false, false, false); str += "\n"; if(tableMap["标准井段"] == "-"){ str += ttGen.zeroWord(tableMap["标准井段"], false, false, true); str += ttGen.blanksWord("井斜-标准测量井段");} else{ str += ttGen.numWord(tableMap["标准井段"], false, false, true); str += ttGen.blanksWord("井斜-标准测量井段");} str += ttGen.tutouTailGen_1(); if(tableMap["垂直标准井段"] == "-"){str += ttGen.zeroWord(tableMap["垂直标准井段"], false, false, true); str += ttGen.blanksWord("标准垂直井段");} else{ str += ttGen.numWord(tableMap["垂直标准井段"], false, false, true); str += ttGen.blanksWord("标准垂直井段");} if(tableMap["组合井段"] == "-"){ str += ttGen.zeroWord(tableMap["组合井段"], false, false, true); str += ttGen.blanksWord("组合 曲线测量井段");} else{ str += ttGen.numWord(tableMap["组合井段"], false, false, true); str += ttGen.blanksWord("组合 曲线测量井段");} str += ttGen.tutouTailGen_2(); if(tableMap["垂直曲线井段"] == "-"){str += ttGen.zeroWord(tableMap["垂直曲线井段"], false, false, true); str += ttGen.blanksWord("组合 曲线垂直井段");} else{ str += ttGen.numWord(tableMap["垂直曲线井段"], false, false, true); str += ttGen.blanksWord("组合 曲线垂直井段");} str += ttGen.tutouTailGen_3(); if(tableMap["放大井段1"] == "-"){ str += ttGen.zeroWord(tableMap["放大井段1"], false, false, true); str += ttGen.blanksWord("放大曲线测量井段");} else{ str += ttGen.numWord(tableMap["放大井段1"], false, false, true); str += ttGen.blanksWord("放大曲线测量井段");} str += ttGen.tutouTailGen_4(); str += ttGen.resultTu(tableMap["解释程序"]); if(tableMap["处理井段"] == "-"){ str += ttGen.zeroWord(tableMap["处理井段"], false, false, true); str += ttGen.blanksWord("成果图处理井段");} else{ str += ttGen.numWord(tableMap["处理井段"], false, false, true); str += ttGen.blanksWord("成果图处理井段");} str += ttGen.numWord(QString(rMessage.JB), true, false, false); str += ttGen.numWord(tableMap["井底温度"], false, false, true); str += ttGen.blanksWord("井底温度"); str += ttGen.tutouCurveGen(tableMap["所用曲线"], "所用曲线"); if(tableMap["垂直处理井段"] == "-"){str += ttGen.zeroWord(tableMap["垂直处理井段"], false, false, true); str += ttGen.blanksWord("成果图垂直井段");} else{ str += ttGen.numWord(tableMap["垂直处理井段"], false, false, true); str += ttGen.blanksWord("成果图垂直井段");} str += ttGen.chaiFenRange(tableMap["处理井段"], false, false, true); str += ttGen.blanksWord("成果表测量井段"); str += ttGen.chaiFenRange(tableMap["垂直处理井段"], false, false, true); str += ttGen.blanksWord("成果表垂直井段"); str += ttGen.tutouTailGen_5(); str += ttGen.numWord(tableMap["井眼"], false, false, true); str += ttGen.blanksWord("第一井眼"); str += ttGen.tutouTailGen_6(); fprintf(fp, str.toStdString().c_str()); fclose(fp); return; } void lps_g1g2Gen(CMemRdWt *mrw, QString pathName, QString tableName) { int tableID = mrw->OpenTable(tableName.toStdString().c_str()); if(tableID < 0) return; int count = mrw->GetTableFieldCount(tableID); int rec = mrw->GetTableRecordCount(tableID); if(count != 4) return; QMap gjreMap; Slf_TABLE_FIELD *Table_Field = new Slf_TABLE_FIELD[count+1]; mrw->GetTableFieldInfo(tableID, Table_Field); char *buf = new char[mrw->GetTableRecordLength(tableID)]; //临时存放 for(int i = 0; i < rec; i++){ mrw->ReadTable(tableID, i + 1, buf); int len = 0; char itemValue[500]; QStringList itemList; for(int j = 0; j < count; j++){ GetData(Table_Field[j].RepCode, &buf[len], itemValue); len += Table_Field[j].Length; if(j < 0) continue; itemList.append(QString(itemValue)); } gjreMap.insert(i, itemList); } delete []buf; delete []Table_Field; QString cs; if(strncmp(tableName.toStdString().c_str(), "GUJING1_RESULT", strlen("GUJING1_RESULT")) == 0) cs = pathName + G1FILENAME; if(strncmp(tableName.toStdString().c_str(), "GUJING2_RESULT", strlen("GUJING2_RESULT")) == 0) cs = pathName + G2FILENAME; FILE *fp; if((fp = fopen(cs.toStdString().c_str(), "w+b")) == NULL) return; QMap reMap; reMap.insert("0", "103"); // 好 reMap.insert("1", "104"); // 中 reMap.insert("2", "105"); // 差 reMap.insert("3", "102"); // 纯 reMap.insert("4", "101"); // 混 reMap.insert("5", "106"); // 自由套管 QString str; for(int i = 0; i < rec; i++){ str += " "; str += reMap[gjreMap[i][3]]; str += " " + QString::number(gjreMap[i][1].toFloat(), 'f', 3) + " " + QString::number(gjreMap[i][2].toFloat(), 'f', 3); str += "\n"; } while(str.indexOf("\r\n") >= 0) str=str.replace("\r\n","\n"); fprintf(fp, str.toStdString().c_str()); fclose(fp); return; } void GetData(int RepCode,char *buffer,char *buf) { float yy; switch(RepCode) { case REPR_INT: //0 yy=(float)(*((int*)buffer)); sprintf(buf,"%g",yy); break; case REPR_SHORT: //1 yy=(float)(*((short *)buffer)); sprintf(buf,"%g",yy); break; case REPR_LONG://2 yy=(float)(*((long *)buffer)); sprintf(buf,"%g",yy); break; case REPR_FLOAT://3 yy=(float)(*((float *)buffer)); sprintf(buf,"%g",yy); break; case REPR_DOUBLE://4 yy=(float)(*((double *)buffer)); sprintf(buf,"%g",yy); break; case REPR_CHAR://5 yy=(float)(*((char *)buffer)); sprintf(buf,"%g",yy); break; case REPR_UCHAR://6 yy=(float)(*((unsigned char *)buffer)); sprintf(buf,"%g",yy); break; case REPR_USHORT://7 yy=(float)(*((unsigned short *)buffer)); sprintf(buf,"%g",yy); break; case REPR_UINT://8 yy=(float)(*((unsigned int *)buffer)); sprintf(buf,"%g",yy); break; case REPR_ULONG://9 yy=(float)(*((unsigned long *)buffer)); sprintf(buf,"%g",yy); break; case REPR_STRING://10 // yy=-99999; sprintf(buf,"%s",buffer); strncpy(buf,buffer,99); buf[99]='\0'; break; } } void WriteLasTableHead(FILE *fp,CMemRdWt *mrw,int count,Slf_TABLE_FIELD *Table_Field) { Slf_FILE_MESSAGE message; // mrw->GetMessage(message); mrw->GetFileMessage(message); fprintf(fp,"~Version\n"); fprintf(fp,"VERS . 3.0 : CWLS LOG ASCII STANDARD - VERSION 3.0\n"); fprintf(fp,"WRAP . NO : ONE LINE PER DEPTH STEP\n"); fprintf(fp,"DLM . SPACE : DELIMITING CHARACTER(SPACE TAB OR COMMA)\n"); fprintf(fp,"~Well Information\n"); fprintf(fp,"#_______________________________________________________________________________\n"); fprintf(fp,"#\n"); fprintf(fp,"#PARAMETER_NAME .UNIT VALUE : DESCRIPTION\n"); fprintf(fp,"#_______________________________________________________________________________\n"); fprintf(fp,"STRT .unitless 1 : First reference value\n"); fprintf(fp,"STOP .unitless%d : Last reference value\n",count); fprintf(fp,"STEP .unitless 1 : Step increment\n"); fprintf(fp,"NULL . -9999 : Missing value\n"); fprintf(fp,"COMP . : Company\n"); fprintf(fp,"WELL . %s : Well name\n",message.WellName); fprintf(fp,"FLD . : Field\n"); fprintf(fp,"LOC . : Location\n"); fprintf(fp,"SRVC . : Service Company\n"); fprintf(fp,"CTRY . : Country\n"); fprintf(fp,"DATE . : Service Date\n"); fprintf(fp,"X . : X or East-West coordinate\n"); fprintf(fp,"Y . : Y or North South coordinate\n"); fprintf(fp,"GDAT . : Geodetic Datum\n"); fprintf(fp,"HZCS . : Horizontal Co-ordinate System\n"); fprintf(fp,"~Parameter Information Block\n"); fprintf(fp,"#_______________________________________________________________________________\n"); fprintf(fp,"#\n"); fprintf(fp,"#PARAMETER_NAME .UNIT VALUE : DESCRIPTION\n"); fprintf(fp,"#_______________________________________________________________________________\n"); fprintf(fp,"SET . Unknown_3 : \n"); for(int i=0;i=6) { QString filename; if(FileType==2)filename=PathName+WellName+QString::fromLocal8Bit(OutInf[m].OutName)+".LAS"; else filename=PathName+WellName+QString::fromLocal8Bit(OutInf[m].OutName)+".TXT"; FILE *fp=fopen(filename.toStdString().c_str(),"w+t"); int table=mrw->OpenTable(OutInf[m].Name); Slf_TABLE_FIELD *Table_Field; int count=mrw->GetTableFieldCount(table); Table_Field=new Slf_TABLE_FIELD[count+1]; mrw->GetTableFieldInfo(table,Table_Field); if(FileType==2)WriteLasTableHead(fp,mrw,count,&Table_Field[0]); else { for(int i=0;iGetTableRecordCount(table); CString ss; float val; int ival; for(int i=0;iGetTableFieldData(table,j,i+1,str); // GetData(Table_Field[j].RepCode,&buf[len],str); // len+=Table_Field[j].Length; if(type!=6&&typeCloseTable(table); fclose(fp); } } } void TranSlf2Data(int FormatType,QMap > OutFileInfVec,OUTOBJECTINF *OutInf,bool *IsCheck,int NumObject,int OutFlag,bool Zero) { int num=OutFileInfVec.count(); //QMessageBox::information(NULL,"提示",QString::number(num)); QMap>::Iterator it=OutFileInfVec.begin(); QString Infile; QString Outfile; std::vectorvalue; float Outsdep,Outedep,Outrlev; DepthProgress MyDepthProgress; MyDepthProgress.CreatProgress(0,num,"正在输出"); MyDepthProgress.SetDepth(1); QString mes; int nn=0; //for OutFlag=1时,按文件信息框制定方案输出,但要剔除不存在的对象 int NumObject0=NumObject; OUTOBJECTINF *OutInf0=new OUTOBJECTINF[NumObject]; memcpy(&OutInf0[0],&OutInf[0],NumObject*sizeof(OUTOBJECTINF)); // while(it!=OutFileInfVec.end()) { nn++; Infile=it.key(); mes="输出:"+QString::number(nn)+"/"+QString::number(num); MyDepthProgress.SetShowName(mes.toStdString().c_str()); MyDepthProgress.SetDepth(nn); value=it.value(); Outfile=value[0]; Outfile = LowerFileName(Outfile); if (Outfile=="") { CString str; str.Format("ttt输出文件名为:%s",Outfile.toStdString().c_str()); AfxMessageBox(str); } if(value[1] == "original") Outsdep = -9999.0; else Outsdep=value[1].toFloat(); if(value[2] == "original") Outedep = -9999.0; else Outedep=value[2].toFloat(); if(Outsdep >= Outedep && Outedep != -9999 && Outsdep != -9999){ CString str; str.Format("深度错误,输出失败"); AfxMessageBox(str); return; } if(value[3] == "original") Outrlev = -9999.0; else Outrlev=value[3].toFloat(); if(Outrlev <= 0 && Outrlev != -9999){ CString str; str.Format("采样间隔错误,输出失败"); AfxMessageBox(str); return; } #pragma region 判断输出对象类型及类型个数 CMemRdWt mrw; int op=mrw.Open(Infile.toStdString().c_str(),CSlfIO::modeRead); if (!op) { CString str; str.Format("打开Slf文件 %s 失败",Infile.toUtf8().data()); AfxMessageBox(str); return; } int Ind[1024]; //int CurveCount=0,WaveCount=0,FmtCount=0,TdtCount=0,TableCount=0,ParCount=0; if(OutFlag==2)//按定制方案输出 { for(int i=0;i=0)OutInf[i].ObjectType=mrw.GetObjectType(Ind[i]); } } else if(OutFlag==1)//按文件信息框制定方案输出 { NumObject=0; for(int i=0;i