diff --git a/ConvertorManager/src/ImportdataDialog.cpp b/ConvertorManager/src/ImportdataDialog.cpp index c83313a..cfc2f61 100644 --- a/ConvertorManager/src/ImportdataDialog.cpp +++ b/ConvertorManager/src/ImportdataDialog.cpp @@ -4,12 +4,14 @@ #include "IConvertor.h" //#include "ObjWelllogRound.h" #include +#include //#include "DataImport.h" #include "CStringType.h" #include "MyWelllogRound.h" #include "tishidialog.h" #include "ui_interfaceWidget.h" //#include "ObjectEvent.h" +#include "ObjWell.h" #include "MemRdWt.h" BEGIN_OSGGRAPHICS_NAMESPACE; ImportDataDialog::ImportDataDialog(QWidget *parent,QString wellname,QString wellroundname): QDialog(parent),m_FilePath(""),m_ExistSameWellName(false),m_ExistSameWellRoundName(false) @@ -604,6 +606,276 @@ bool ImportDataDialog::IsHaveSameCurve(int NumLog,vector &OutCurveNo,vector // } // return 0; // } + +void CreateWellFile(CLogIO *logio,Slf_FILE_MESSAGE &mssage,QString wellFile,CObjWell *pWell) +{ + if(logio) { + CLogIO * logiowell=new CLogIO(); + Slf_FILE_MESSAGE ms=mssage; + strcpy(ms.Item,"井基本信息"); + logiowell->Open(wellFile.toStdString().c_str(),CSlfIO::modeWrite); + logiowell->SetFileMessage(ms); + QStringList azims=GetSimilarCurves("AZIM"); + int iAZIM=-1; + QString AZIM; + foreach(QString cname,azims) + { + iAZIM=logio->FindObjectName((char *)cname.toStdString().c_str()); + if(iAZIM>-1) { + AZIM=cname; + break; + } + } + int iDev=-1; + QStringList devis=GetSimilarCurves("DEVI"); + QString DEV; + foreach(QString cname,devis) + { + iDev=logio->FindObjectName((char *)cname.toStdString().c_str()); + if(iDev>-1) { + DEV=cname; + break; + } + } + // if(logio->FindObjectIndex("井基本信息")>-1) { + // logiowell->CopyFromFile((CSlfIO &)(*logio),"井基本信息"); + // } + if(iAZIM>-1)logiowell->CopyFromFile((CSlfIO &)(*logio),(char *)AZIM.toStdString().c_str()); + if(iDev>-1)logiowell->CopyFromFile((CSlfIO &)(*logio),(char *)DEV.toStdString().c_str()); + delete logiowell; + if(iDev>-1&&iAZIM>-1) { + pWell->ComputeTrajectory(pWell,wellFile); + } + } +} +// 参考 CObjWell *CDataImport::ChangetoSlf(QString wellFile1,DiDepthProgress *pDepthProgress,bool IsTran) +CObjWell *ChangetoSlf(QString wellFile1,DiDepthProgress *pDepthProgress,bool IsTran) +{ + QString filename=wellFile1; + QString slffilename=filename; + + ///从文件内部读取井名 + CLogIO * logio=new CLogIO(); + if(!logio->Open(slffilename.toStdString().c_str(),CSlfIO::modeRead)) + { + delete logio; + QString aa=slffilename+"文件打开失败,请检查!"; + return NULL; + // AppendConsole(pai::log::PAI_ERROR,aa); + // return pWell; + } + //说明从项目或者井节点发起attachSLF,需要读取slf获得井名和井次信息 + QString wellname=""; + Slf_FILE_MESSAGE mssage; + logio->GetFileMessage(mssage); + wellname=mssage.WellName; + wellname=wellname.toUpper(); + //辨别井名是否有效,无效则采用文件名 + QFileInfo fileInfo(filename); + QString strWellName = fileInfo.completeBaseName(); + strWellName=strWellName.toUpper(); + QString wellRoundname=strWellName; + + CObjWell *pWell = new CObjWell(); + CObjWelllogRound* pWelllogRound=new CObjWelllogRound(); + pWelllogRound->SetWell(pWell); + // pWell->AddChild(pWelllogRound); + + pWell->SetCurrentObjWellRound(pWelllogRound); + + wellRoundname=wellRoundname.toUpper(); + // pWelllogRound->SetName(wellRoundname); + pWelllogRound->SetSlfFileName(filename); + if (wellname.isEmpty()||wellname.length()>64||wellname.indexOf('&')>-1) + { + wellname=strWellName.toStdString().c_str(); + int len=strlen(strWellName.toStdString().c_str()); + if(len>sizeof(mssage.WellName)) len=sizeof(mssage.WellName); + strncpy(mssage.WellName,strWellName.toStdString().c_str(),len); + mssage.WellName[len]=0; + logio->SetFileMessage(mssage); + } + wellname=wellname.toUpper(); + QString welln; + if(filename.endsWith(".slf",Qt::CaseInsensitive)) + { + // QString dirpath=GetLogdataPath()+GetProject()->GetName(); + + // welln=GetWellFileFromDir(dirpath,wellname,".well"); + // if(welln.isEmpty()||(!pWell->GetName().isEmpty()&&wellname!=pWell->GetName())) { + // wellname=pWell->GetName(); + int index=filename.lastIndexOf("\\"); + int index1=filename.lastIndexOf("/"); + if(index1>index) index=index1; + // welln=GetWellFileFromCurrentDir(filename.left(index+1),wellname,".well"); + + if(welln.isEmpty()) { + welln=filename.left(index+1)+wellname+".well"; + QFileInfo check_file(welln); + if (!check_file.exists() || !check_file.isFile()) {//文件不存在 + CreateWellFile(logio,mssage,welln,pWell); + } + + // CDataTree::SetTree(welln,pWell,NULL,(DepthProgress *)pDepthProgress,1); + } + } + int iX=-1,iY=-1,iZ=-1; + int isrefress=true; + QString temp = ::GetConfPath()+"data.ini"; + QSettings settings(temp,QSettings::IniFormat,0); + settings.setIniCodec(QTextCodec::codecForName("UTF-8")); + QStringList serials=settings.value("wellType",0).toStringList(); + int type=serials.indexOf(mssage.WellType); + + if(type>-1) pWell->SetWellSymbol("well" + QString::number(type) + ".png"); + + //else isrefress=true; + float Altitude=mssage.Altitude; + float X_COORDINATE=mssage.Xcoor; + float Y_COORDINATE=mssage.Ycoor;//井斜x,y坐标 + WellHead &mWellHead=pWell->GetWellHead(); + if(mssage.Kelly==9999999) mssage.Kelly=0; + if(mssage.Kelly==-9999) mssage.Kelly=0; + if(mssage.Kelly==-99999) mssage.Kelly=0; + if(mssage.azca) mWellHead.azca=mssage.azca; + if(mssage.Kelly)mWellHead.dEle=ConvertDataByFloat(mssage.Kelly).toFloat(); + if(mssage.WellName[0])mWellHead.wellName=mssage.WellName; + if(X_COORDINATE)mWellHead.x=X_COORDINATE; + if(Y_COORDINATE)mWellHead.y=Y_COORDINATE; + if(Altitude)mWellHead.earthEle=Altitude; + if(mssage.X0)mWellHead.dxe=mssage.X0; + if(mssage.Y0)mWellHead.dyn=mssage.Y0; + if(mssage.TVD)mWellHead.tvd=mssage.TVD; + Slf_CURVE acurveinfo; + memset(&acurveinfo,0,sizeof(Slf_CURVE)); + int curveCount=logio->GetObjectCount(); + if(isrefress) { + logio->DiscardObject("X"); + logio->DiscardObject("Y"); + logio->DiscardObject("Z"); + logio->DiscardObject("TVD"); + } + iX=logio->OpenCurve("X"); + iY=logio->OpenCurve("Y"); + iZ=logio->OpenCurve("Z"); + if(iX>-1) logio->GetCurveInfo(iX,&acurveinfo); + + mWellHead.depth=acurveinfo.StartDepth; + if(mWellHead.tvd==0&&acurveinfo.StartDepth!=0)mWellHead.tvd=acurveinfo.StartDepth; + mWellHead.z=mWellHead.earthEle-mWellHead.tvd+mWellHead.dEle; + mWellHead.startDepth=acurveinfo.StartDepth; + mWellHead.endDepth=acurveinfo.EndDepth; + mWellHead.rlev=acurveinfo.DepLevel; + int iDepth=-1; + iDepth=logio->OpenCurve("TVD"); + if(iX>=0&&iY>=0&&iZ>=0&&iDepth>=0) { + logio->GetCurveInfo(iX,&acurveinfo); + if(acurveinfo.DepLevel==0) { + logio->DiscardObject(iX); + logio->DiscardObject(iY); + logio->DiscardObject(iZ); + logio->DiscardObject(iDepth); + delete logio; + pWell->ComputeTrajectory(pWell,filename); + } else { + delete logio; + pWell->SetDepth(pWell); + } + } + else { + delete logio; + pWell->ComputeTrajectory(pWell,slffilename); + } + logio=new CLogIO(); + if(!logio->Open(slffilename.toStdString().c_str(),CSlfIO::modeRead)) + { + delete logio; + QString aa=slffilename+"文件打开失败,请检查!"; + // AppendConsole(pai::log::PAI_ERROR,aa); + return pWell; + } + curveCount=logio->GetObjectCount(); + char* curvename=new char[65]; + curvename[64]='\0'; + char* aliasname=new char[65]; + aliasname[64]='\0'; + for(int i=0;iGetObjectName(i,curvename,NULL,aliasname); + if(!logio->IsObject(i)) { + logio->DiscardObject(i); + continue; + }; + if(logio->GetObjectStatus(i)!=OBJECT_NORMAL) continue; + short curvetype=logio->GetObjectType(i); + short Attribute=0,SubAttribute=0; + logio->GetObjectAttribute(i,&Attribute,&SubAttribute); + if(curvetype==CURVE_OBJECT) + { + Slf_CURVE acurveinfo; + logio->GetCurveInfo(i,&acurveinfo); + if(acurveinfo.DepLevel!=0&&(acurveinfo.EndDepth-acurveinfo.StartDepth>0)) + { + if(acurveinfo.MaxValue==acurveinfo.MinValue||acurveinfo.MaxValue==-99999||acurveinfo.MaxValue==-9999||acurveinfo.MinValue==999999||acurveinfo.MinValue==999999||acurveinfo.MinValue==99999||acurveinfo.MinValue==99999||acurveinfo.MinValue==-9999){ + int curveindex=logio->OpenSlfTable(i,-1); + if(curveindex>-1) + { + MyDataTypeEnum vVdl; + DWORD count=(acurveinfo.EndDepth-acurveinfo.StartDepth)/acurveinfo.DepLevel+1.5; + DWORD len=count*acurveinfo.CodeLen; + acurveinfo.MinValue=99999999; + acurveinfo.MaxValue=-99999999; + if(acurveinfo.CodeLen==8) acurveinfo.MinValue=99999999; + vVdl.vchar=new char[len]; + len=logio->ReadCurve(curveindex, acurveinfo.StartDepth,count,(void *)vVdl.vchar); + if(!len) { + QString cs; + char buf[1000]; + sprintf(buf,"%s %f-%f",acurveinfo.Name,acurveinfo.StartDepth,acurveinfo.EndDepth); + cs=buf; + int flag = QMessageBox::warning(NULL,"提示",QString(cs+"\n曲线信息异常!删除该曲线可能需要较长时间,建议复制正常曲线等信息到新文件,然后删除此文件。是否此时直接将该曲线删除?"),QMessageBox::Yes,QMessageBox::No); + if(flag==QMessageBox::Yes) logio->DiscardObject(i); + delete vVdl.vchar; + continue; + } + for(int kk=0;kkGetData(acurveinfo.RepCode,&vVdl.vchar[kk*acurveinfo.CodeLen],buf); + if(_isnan(temp)||!_finite(temp)) continue; + + if(acurveinfo.MaxValuetemp) if(temp!=-9999.0&&temp!=-999.25&&temp!=-99999.0)acurveinfo.MinValue=temp; + } + logio->SetCurveInfo(curveindex,&acurveinfo); + delete vVdl.vchar; + } + } + } + else if(acurveinfo.DepLevel==0||acurveinfo.StartDepth<-100000||acurveinfo.StartDepth>100000) + { + QString cs; + char buf[1000]; + sprintf(buf,"%s %f-%f",acurveinfo.Name,acurveinfo.StartDepth,acurveinfo.EndDepth); + cs=buf; + int flag = QMessageBox::warning(NULL,"提示",QString(cs+"\n曲线信息异常!删除该曲线可能需要较长时间,建议复制正常曲线等信息到新文件,然后删除此文件。是否此时直接将该曲线删除?"),QMessageBox::Yes,QMessageBox::No); + if(flag==QMessageBox::Yes) logio->DiscardObject(i); + continue; + } + } + } + delete []curvename; + delete []aliasname; + DepthProgress *pd=new DepthProgress; + pd->CreatProgress(0,2,"正在整理数据..."); + pd->SetDepth(1); + delete logio; + delete pd; + + delete pWelllogRound; + delete pWell; +} + bool ImportDataDialog::SelectAndDeleteWellLog(int iRow,InterfaceWidget *pCurrentInterfaceWidget,int ColumnCount,IConvertor *pConvertor) { InterIConvertor*tpConvertor=dynamic_cast(pConvertor); @@ -726,7 +998,8 @@ bool ImportDataDialog::SelectAndDeleteWellLog(int iRow,InterfaceWidget *pCurren ((InterIConvertor*)(pCurrentInterfaceWidget->m_pConvertor))->InitWellInfo(outfile); wellRound->SaveMeesge(outfile); } - //CDataImport::ChangetoSlf(outfile,NULL); + // CDataImport::ChangetoSlf(outfile,NULL); + ChangetoSlf(outfile,NULL,true); } for(int i=0;i> 16) & 0xffff)) +#define LOBYTE(w) ((BYTE)(((DWORD_PTR)(w)) & 0xff)) +#define HIBYTE(w) ((BYTE)((((DWORD_PTR)(w)) >> 8) & 0xff)) + +int TrackPoints(double nDevi,double nAzim,double rlev,double &XE,double &YN,double &ZD,double &HOFF0,double &HOAZ0,double >D0,double &AZIM0); +int initTrackPoints(double azca,double tvd,double dxe,double dyn,double rlev=0,double GLDDDEP0=30,double hoff=0); +//#include "DepthProgress.h" diff --git a/OSGDataModel/src/OSGDataModel.pro b/OSGDataModel/src/OSGDataModel.pro index cf6df78..0741936 100644 --- a/OSGDataModel/src/OSGDataModel.pro +++ b/OSGDataModel/src/OSGDataModel.pro @@ -45,6 +45,7 @@ HEADERS += \ ../include/ObjWelllogINP.h \ ../include/ObjWelllogTABLE.h \ ../include/ObjWelllogWavefile.h \ + ../include/TrackPoints.H \ ../include/WellLogWorkflowDataModel.h #CPATH = $$system(pwd) diff --git a/OSGDataModel/src/ObjWell.cpp b/OSGDataModel/src/ObjWell.cpp index 0b498ad..46cd005 100644 --- a/OSGDataModel/src/ObjWell.cpp +++ b/OSGDataModel/src/ObjWell.cpp @@ -13,6 +13,8 @@ // #include "ObjectEvent.h" #include #include +#include "geometryutils.h" +#include "TrackPoints.H" #pragma warning( pop ) @@ -129,10 +131,11 @@ void CObjWell::SaveWellHead(QString wellfilename) delete logio; } + // int CObjWell::GetAllWellRound(QList &wellroundchildren) // { -// this->GetObjectByType(wellroundchildren,GetClassID_WellLogRound()); -// return wellroundchildren.size(); +// this->GetObjectByType(wellroundchildren,GetClassID_WellLogRound()); +// return wellroundchildren.size(); // } // int CObjWell::GetWellRoundCount() @@ -723,332 +726,332 @@ void CObjWell::ClearXYZ() // } // return bSuccess; // } -// void CObjWell::SetDepth(CObjWell *pWell) -// { -// if(pWell) -// { -// int roc=pWell->GetWellRoundCount(); -// if(roc) -// { -// QListchilds; -// pWell->GetAllWellRound(childs); -// double stardep=99999,enddep=-99999; -// float rlev=100; -// for(int i=0;i(childs[i]); -// if(!pWelllogRound) continue; -// CLogIO * logio=new CLogIO(); +void CObjWell::SetDepth(CObjWell *pWell) +{ + // if(pWell) + // { + // int roc=pWell->GetWellRoundCount(); + // if(roc) + // { + // QListchilds; + // pWell->GetAllWellRound(childs); + // double stardep=99999,enddep=-99999; + // float rlev=100; + // for(int i=0;i(childs[i]); + // if(!pWelllogRound) continue; + // CLogIO * logio=new CLogIO(); -// if(!logio->Open(pWelllogRound->GetSlfFileName().toStdString().c_str(),CSlfIO::modeReadWrite)) -// { -// delete logio; -// break; -// } -// int curveCount=logio->GetObjectCount(); -// for(int k1=0;k1GetObjectName(k1,buf); -// int a=logio->OpenCurve(buf); -// if(a>-1) -// { -// Slf_CURVE acurveinfo; -// logio->GetCurveInfo(a,&acurveinfo); -// if(acurveinfo.StartDepthenddep) enddep=acurveinfo.EndDepth; -// if(rlev>acurveinfo.DepLevel) rlev=acurveinfo.DepLevel; -// } -// else { -// int a=logio->OpenWave(buf); -// if(a>-1) -// { -// Slf_WAVE acurveinfo; -// logio->GetWaveInfo(a,&acurveinfo); -// if(acurveinfo.StartDepthenddep) enddep=acurveinfo.EndDepth; -// if(rlev>acurveinfo.DepLevel) rlev=acurveinfo.DepLevel; -// } -// } -// } -// if(rlev<=0) rlev=0.125; -// delete logio; -// } -// pWell->SetDepth(stardep,enddep,rlev); -// } -// } -// } -// int CObjWell::ComputeTrajectory(CObjWell *pWell,QString slffilename) -// { -// pWell->SetDepth(pWell); -// QLibrary Methodlib; -// QString PeModulePath=QCoreApplication::applicationDirPath() + QDir::separator() +"TrackPoints.dll"; -// Methodlib.setFileName(PeModulePath); -// Methodlib.load(); -// typedef int (* LPFNDLLFUNC1)(double azca,double tvd,double dxe,double dyn,double rlev0,double Gldddep,double hoff); -// LPFNDLLFUNC1 initTrackPoints; -// typedef int (* LPFNDLLFUNC2)(double nDevi,double nAzim,double rlev,double &XE,double &YN,double &ZD,double &HOFF0,double &HOAZ0,double >D0,double &AZIM0); -// LPFNDLLFUNC2 TrackPoints; -// QString initfname="initTrackPoints"; -// QString funname="TrackPoints"; -// initTrackPoints = (LPFNDLLFUNC1)(Methodlib.resolve(initfname.toStdString().c_str()));//strDLLFun.toStdString().c_str()) -// TrackPoints = (LPFNDLLFUNC2)(Methodlib.resolve(funname.toStdString().c_str()));//strDLLFun.toStdString().c_str()) -// QStringList CurveNames; -// int iDev=-1,iAZIM=-1,iX=-1,iY=-1,iZ=-1,iDepth=-1; -// Slf_FILE_MESSAGE mssage; + // if(!logio->Open(pWelllogRound->GetSlfFileName().toStdString().c_str(),CSlfIO::modeReadWrite)) + // { + // delete logio; + // break; + // } + // int curveCount=logio->GetObjectCount(); + // for(int k1=0;k1GetObjectName(k1,buf); + // int a=logio->OpenCurve(buf); + // if(a>-1) + // { + // Slf_CURVE acurveinfo; + // logio->GetCurveInfo(a,&acurveinfo); + // if(acurveinfo.StartDepthenddep) enddep=acurveinfo.EndDepth; + // if(rlev>acurveinfo.DepLevel) rlev=acurveinfo.DepLevel; + // } + // else { + // int a=logio->OpenWave(buf); + // if(a>-1) + // { + // Slf_WAVE acurveinfo; + // logio->GetWaveInfo(a,&acurveinfo); + // if(acurveinfo.StartDepthenddep) enddep=acurveinfo.EndDepth; + // if(rlev>acurveinfo.DepLevel) rlev=acurveinfo.DepLevel; + // } + // } + // } + // if(rlev<=0) rlev=0.125; + // delete logio; + // } + // pWell->SetDepth(stardep,enddep,rlev); + // } + // } +} +int CObjWell::ComputeTrajectory(CObjWell *pWell,QString slffilename) +{ + pWell->SetDepth(pWell); + // QLibrary Methodlib; + // QString PeModulePath=QCoreApplication::applicationDirPath() + QDir::separator() +"TrackPoints.dll"; + // Methodlib.setFileName(PeModulePath); + // Methodlib.load(); + // typedef int (* LPFNDLLFUNC1)(double azca,double tvd,double dxe,double dyn,double rlev0,double Gldddep,double hoff); + // LPFNDLLFUNC1 initTrackPoints; + // typedef int (* LPFNDLLFUNC2)(double nDevi,double nAzim,double rlev,double &XE,double &YN,double &ZD,double &HOFF0,double &HOAZ0,double >D0,double &AZIM0); + // LPFNDLLFUNC2 TrackPoints; + // QString initfname="initTrackPoints"; + // QString funname="TrackPoints"; + // initTrackPoints = (LPFNDLLFUNC1)(Methodlib.resolve(initfname.toStdString().c_str()));//strDLLFun.toStdString().c_str()) + // TrackPoints = (LPFNDLLFUNC2)(Methodlib.resolve(funname.toStdString().c_str()));//strDLLFun.toStdString().c_str()) + QStringList CurveNames; + int iDev=-1,iAZIM=-1,iX=-1,iY=-1,iZ=-1,iDepth=-1; + Slf_FILE_MESSAGE mssage; -// CObjWelllogRound* pWelllogRound; + CObjWelllogRound* pWelllogRound; -// CMemRdWt * logio=new CMemRdWt(); + CMemRdWt * logio=new CMemRdWt(); -// if(!logio->Open(slffilename.toStdString().c_str(),CSlfIO::modeReadWrite)) -// { -// delete logio; -// QString aa=slffilename+"文件打开失败,请检查!"; -// // AppendConsole(pai::log::PAI_ERROR,aa); -// Methodlib.unload(); -// return 0; -// } -// logio->GetFileMessage(mssage); -// QString path,wen,slfn; -// GetWellNameAndPath(slffilename,wen,path,slfn); -// if(slfn.indexOf(".well",0,Qt::CaseInsensitive)==-1) -// { -// QString slf; -// if(strlen(mssage.WellName)==0||mssage.WellName[0]==' ') -// { -// int len=slffilename.indexOf(".slf",0,Qt::CaseInsensitive); -// slf=slffilename.mid(0,len)+".well"; -// } -// else slf=path+"/"+mssage.WellName+".well"; -// CMemRdWt sf(slf.toStdString().c_str(),CSlfIO::modeReadWrite); -// Slf_FILE_MESSAGE sm; -// sf.GetFileMessage(sm); -// if(sm.Xcoor!=mssage.Xcoor) -// { -// if(sm.Xcoor>1&&(_finite(sm.Xcoor)&&!_isnan(sm.Xcoor))) mssage.Xcoor=sm.Xcoor; -// else if(mssage.Xcoor>1&&(_finite(mssage.Xcoor)&&!_isnan(mssage.Xcoor)))sm.Xcoor=mssage.Xcoor; -// if(sm.Ycoor>1&&(_finite(sm.Ycoor)&&!_isnan(sm.Ycoor))) mssage.Ycoor=sm.Ycoor; -// else if(mssage.Ycoor>1&&(_finite(mssage.Ycoor)&&!_isnan(mssage.Ycoor)))sm.Ycoor=mssage.Ycoor; -// if(sm.azca&&(_finite(sm.azca)&&!_isnan(sm.azca))) mssage.azca=sm.azca; -// else if(mssage.azca&&(_finite(mssage.azca)&&!_isnan(mssage.azca)))sm.azca=mssage.azca; -// if(sm.Altitude&&(_finite(sm.Altitude)&&!_isnan(sm.Altitude))) mssage.Altitude=sm.Altitude; -// else if(mssage.Altitude&&(_finite(mssage.Altitude)&&!_isnan(mssage.Altitude)))sm.Altitude=mssage.Altitude; -// if(sm.Kelly&&(_finite(sm.Kelly)&&!_isnan(sm.Kelly))) mssage.Kelly=sm.Kelly; -// else if(mssage.Kelly&&(_finite(mssage.Kelly)&&!_isnan(mssage.Kelly)))sm.Kelly=mssage.Kelly; -// if(sm.TVD&&(_finite(sm.TVD)&&!_isnan(sm.TVD))) mssage.TVD=sm.TVD; -// else if(mssage.TVD&&(_finite(mssage.TVD)&&!_isnan(mssage.TVD)))sm.TVD=mssage.TVD; -// if(sm.X0&&(_finite(sm.X0)&&!_isnan(sm.X0))) mssage.X0=sm.X0; -// else if(mssage.X0&&(_finite(mssage.X0)&&!_isnan(mssage.X0)))sm.X0=mssage.X0; -// if(sm.Y0&&(_finite(sm.Y0)&&!_isnan(sm.Y0))) mssage.Y0=sm.Y0; -// else if(mssage.Y0&&(_finite(mssage.Y0)&&!_isnan(mssage.Y0)))sm.Y0=mssage.Y0; -// sf.SetFileMessage(sm); -// logio->SetFileMessage(mssage); -// } -// } -// int curveCount=logio->GetObjectCount(); -// //说明从项目或者井节点发起attachSLF,需要读取slf获得井名和井次信息 -// QString wellname=""; -// QString wellRoundname=""; -// QStringList azims=GetSimilarCurves("AZIM"); -// foreach(QString cname,azims) -// { -// iAZIM=logio->OpenCurve(cname.toStdString().c_str()); -// if(iAZIM>-1) break; -// } -// QStringList devis=GetSimilarCurves("DEVI"); -// foreach(QString cname,devis) -// { -// iDev=logio->OpenCurve(cname.toStdString().c_str()); -// if(iDev>-1) break; -// } -// Slf_CURVE acurveinfo; -// memset(&acurveinfo,0,sizeof(Slf_CURVE)); -// float AZCA=mssage.azca,TVD=mssage.TVD,X0=mssage.X0,Y0=mssage.Y0; -// double XE=X0,YN=Y0; -// float Altitude=mssage.Altitude; -// float X_COORDINATE=mssage.Xcoor; -// float Y_COORDINATE=mssage.Ycoor;//井斜x,y坐标 -// float KB=ConvertDataByFloat(mssage.Kelly).toFloat(); -// double HOFF0=0; -// double HOAZ0=0,gtd=0; -// double AZIM0=0; -// if(iAZIM>-1) logio->GetCurveInfo(iAZIM,&acurveinfo); -// WellHead &mWellHead=pWell->GetWellHead(); + if(!logio->Open(slffilename.toStdString().c_str(),CSlfIO::modeReadWrite)) + { + delete logio; + QString aa=slffilename+"文件打开失败,请检查!"; + // AppendConsole(pai::log::PAI_ERROR,aa); + // Methodlib.unload(); + return 0; + } + logio->GetFileMessage(mssage); + QString path,wen,slfn; + GetWellNameAndPath(slffilename,wen,path/*,slfn*/); + if(slfn.indexOf(".well",0,Qt::CaseInsensitive)==-1) + { + QString slf; + if(strlen(mssage.WellName)==0||mssage.WellName[0]==' ') + { + int len=slffilename.indexOf(".slf",0,Qt::CaseInsensitive); + slf=slffilename.mid(0,len)+".well"; + } + else slf=path+"/"+mssage.WellName+".well"; + CMemRdWt sf(slf.toStdString().c_str(),CSlfIO::modeReadWrite); + Slf_FILE_MESSAGE sm; + sf.GetFileMessage(sm); + if(sm.Xcoor!=mssage.Xcoor) + { + if(sm.Xcoor>1&&(_finite(sm.Xcoor)&&!_isnan(sm.Xcoor))) mssage.Xcoor=sm.Xcoor; + else if(mssage.Xcoor>1&&(_finite(mssage.Xcoor)&&!_isnan(mssage.Xcoor)))sm.Xcoor=mssage.Xcoor; + if(sm.Ycoor>1&&(_finite(sm.Ycoor)&&!_isnan(sm.Ycoor))) mssage.Ycoor=sm.Ycoor; + else if(mssage.Ycoor>1&&(_finite(mssage.Ycoor)&&!_isnan(mssage.Ycoor)))sm.Ycoor=mssage.Ycoor; + if(sm.azca&&(_finite(sm.azca)&&!_isnan(sm.azca))) mssage.azca=sm.azca; + else if(mssage.azca&&(_finite(mssage.azca)&&!_isnan(mssage.azca)))sm.azca=mssage.azca; + if(sm.Altitude&&(_finite(sm.Altitude)&&!_isnan(sm.Altitude))) mssage.Altitude=sm.Altitude; + else if(mssage.Altitude&&(_finite(mssage.Altitude)&&!_isnan(mssage.Altitude)))sm.Altitude=mssage.Altitude; + if(sm.Kelly&&(_finite(sm.Kelly)&&!_isnan(sm.Kelly))) mssage.Kelly=sm.Kelly; + else if(mssage.Kelly&&(_finite(mssage.Kelly)&&!_isnan(mssage.Kelly)))sm.Kelly=mssage.Kelly; + if(sm.TVD&&(_finite(sm.TVD)&&!_isnan(sm.TVD))) mssage.TVD=sm.TVD; + else if(mssage.TVD&&(_finite(mssage.TVD)&&!_isnan(mssage.TVD)))sm.TVD=mssage.TVD; + if(sm.X0&&(_finite(sm.X0)&&!_isnan(sm.X0))) mssage.X0=sm.X0; + else if(mssage.X0&&(_finite(mssage.X0)&&!_isnan(mssage.X0)))sm.X0=mssage.X0; + if(sm.Y0&&(_finite(sm.Y0)&&!_isnan(sm.Y0))) mssage.Y0=sm.Y0; + else if(mssage.Y0&&(_finite(mssage.Y0)&&!_isnan(mssage.Y0)))sm.Y0=mssage.Y0; + sf.SetFileMessage(sm); + logio->SetFileMessage(mssage); + } + } + int curveCount=logio->GetObjectCount(); + //说明从项目或者井节点发起attachSLF,需要读取slf获得井名和井次信息 + QString wellname=""; + QString wellRoundname=""; + QStringList azims=GetSimilarCurves("AZIM"); + foreach(QString cname,azims) + { + iAZIM=logio->OpenCurve(cname.toStdString().c_str()); + if(iAZIM>-1) break; + } + QStringList devis=GetSimilarCurves("DEVI"); + foreach(QString cname,devis) + { + iDev=logio->OpenCurve(cname.toStdString().c_str()); + if(iDev>-1) break; + } + Slf_CURVE acurveinfo; + memset(&acurveinfo,0,sizeof(Slf_CURVE)); + float AZCA=mssage.azca,TVD=mssage.TVD,X0=mssage.X0,Y0=mssage.Y0; + double XE=X0,YN=Y0; + float Altitude=mssage.Altitude; + float X_COORDINATE=mssage.Xcoor; + float Y_COORDINATE=mssage.Ycoor;//井斜x,y坐标 + float KB=ConvertDataByFloat(mssage.Kelly).toFloat(); + double HOFF0=0; + double HOAZ0=0,gtd=0; + double AZIM0=0; + if(iAZIM>-1) logio->GetCurveInfo(iAZIM,&acurveinfo); + WellHead &mWellHead=pWell->GetWellHead(); -// mWellHead.x=X_COORDINATE; -// mWellHead.y=Y_COORDINATE; -// if(KB==-9999) KB=0; -// if(KB==-99999) KB=0; -// mWellHead.dEle=KB; -// mWellHead.earthEle=Altitude; -// mWellHead.depth=acurveinfo.StartDepth; -// mWellHead.startDepth=acurveinfo.StartDepth; -// mWellHead.azca=AZCA; -// mWellHead.endDepth=acurveinfo.EndDepth; -// if(TVD==0) TVD=mWellHead.startDepth; -// mWellHead.tvd=TVD; + mWellHead.x=X_COORDINATE; + mWellHead.y=Y_COORDINATE; + if(KB==-9999) KB=0; + if(KB==-99999) KB=0; + mWellHead.dEle=KB; + mWellHead.earthEle=Altitude; + mWellHead.depth=acurveinfo.StartDepth; + mWellHead.startDepth=acurveinfo.StartDepth; + mWellHead.azca=AZCA; + mWellHead.endDepth=acurveinfo.EndDepth; + if(TVD==0) TVD=mWellHead.startDepth; + mWellHead.tvd=TVD; -// mWellHead.z=mWellHead.earthEle+mWellHead.dEle-TVD; -// mWellHead.dxe=X0; -// mWellHead.dyn=Y0; + mWellHead.z=mWellHead.earthEle+mWellHead.dEle-TVD; + mWellHead.dxe=X0; + mWellHead.dyn=Y0; -// // if(mWellHead.tvd==0) mWellHead.tvd=TVD; -// double ZD=mWellHead.tvd; -// if(mWellHead.tvd==0) ZD=TVD; +// if(mWellHead.tvd==0) mWellHead.tvd=TVD; + double ZD=mWellHead.tvd; + if(mWellHead.tvd==0) ZD=TVD; -// //TVD=mWellHead.tvd; + //TVD=mWellHead.tvd; -// std::vectorvX; -// std::vectorvY; -// std::vectorvZ; -// std::vectorvTVD; -// if(iAZIM>=0&&iDev>=0&&acurveinfo.DepLevel) { -// initTrackPoints(AZCA,TVD,X0,Y0,acurveinfo.DepLevel,30,0); -// int point=(mWellHead.endDepth-mWellHead.startDepth)/acurveinfo.DepLevel+1.5; -// float *nDevi=new float[point+1]; -// memset(nDevi,0,sizeof(float)*point); -// float *nAzim=new float[point+1]; -// memset(nAzim,0,sizeof(float)*point); -// vX.resize(point); -// vY.resize(point); -// vZ.resize(point); -// vTVD.resize(point); -// int point1=(acurveinfo.EndDepth-acurveinfo.StartDepth)/acurveinfo.DepLevel+1.5; -// int point2=(acurveinfo.EndDepth-mWellHead.startDepth)/acurveinfo.DepLevel+0.5; -// logio->ReadCurve(iAZIM,acurveinfo.StartDepth,point1,nAzim); -// logio->ReadCurve(iDev,acurveinfo.StartDepth,point1,nDevi); -// for(int i=point2;iGetObjectStatus(i)!=OBJECT_NORMAL) continue; -// short curvetype=logio->GetObjectType(i); -// if(curvetype==CURVE_OBJECT) { -// char* curvename=new char[65]; -// curvename[64]='\0'; -// char* aliasname=new char[65]; -// aliasname[64]='\0'; -// logio->GetObjectName(i,curvename,NULL,aliasname); -// logio->GetCurveInfo(i,&acurveinfo); -// if(acurveinfo.DepLevel==0|| -// acurveinfo.DepLevel==0xcdcdcdcd -// ||acurveinfo.DepLevel>=2.226e+008|| -// acurveinfo.StartDepth==acurveinfo.EndDepth){ -// logio->DiscardObject(i); -// delete curvename; -// delete aliasname; -// continue; -// } -// else { -// curveindex=logio->OpenCurve(curvename); -// delete curvename; -// delete aliasname; -// } -// break; -// } -// } -// float sdep=TVD,edep=TVD,rlev=0.125; -// if(curveindex>-1) { -// logio->GetCurveInfo(curveindex,&acurveinfo); -// sdep=acurveinfo.StartDepth; -// edep=acurveinfo.EndDepth; -// rlev=acurveinfo.DepLevel; -// ZD=sdep; -// double z=mWellHead.earthEle-ZD+mWellHead.dEle; -// double x=X_COORDINATE+XE+X0; -// double y=Y_COORDINATE+YN+Y0;//井斜x,y坐标 -// int count=(edep-sdep)/rlev+1.5; -// vX.resize(count); -// vY.resize(count); -// vZ.resize(count); -// vTVD.resize(count); -// for(int i=0;iCreateCurve(&xinfo); -// if(index>-1&&vX.size()) { -// logio->WriteCurve(index,xinfo.StartDepth,vX.size(),(double *)&vX[0]); -// logio->CloseCurve(index); -// } -// strcpy(xinfo.AliasName,"Y"); -// strcpy(xinfo.Name,"Y"); -// index=logio->CreateCurve(&xinfo); -// if(index>-1&&vY.size()) { -// logio->WriteCurve(index,xinfo.StartDepth,vY.size(),(double *)&vY[0]); -// logio->CloseCurve(index); -// } -// strcpy(xinfo.AliasName,"Z"); -// strcpy(xinfo.Name,"Z"); -// index=logio->CreateCurve(&xinfo); -// if(index>-1&&vZ.size()) { -// logio->WriteCurve(index,xinfo.StartDepth,vZ.size(),(double *)&vZ[0]); -// logio->CloseCurve(index); -// } -// strcpy(xinfo.AliasName,"TVD"); -// strcpy(xinfo.Name,"TVD"); -// xinfo.CodeLen=sizeof(float); -// xinfo.RepCode=REPR_FLOAT; -// index=logio->CreateCurve(&xinfo); -// if(index>-1&&vTVD.size()) { -// logio->WriteCurve(index,xinfo.StartDepth,vTVD.size(),(float *)&vTVD[0]); -// logio->CloseCurve(index); -// } -// } -// delete logio; -// Methodlib.unload(); -// return vTVD.size(); -// } + std::vectorvX; + std::vectorvY; + std::vectorvZ; + std::vectorvTVD; + if(iAZIM>=0&&iDev>=0&&acurveinfo.DepLevel) { + initTrackPoints(AZCA,TVD,X0,Y0,acurveinfo.DepLevel,30,0); + int point=(mWellHead.endDepth-mWellHead.startDepth)/acurveinfo.DepLevel+1.5; + float *nDevi=new float[point+1]; + memset(nDevi,0,sizeof(float)*point); + float *nAzim=new float[point+1]; + memset(nAzim,0,sizeof(float)*point); + vX.resize(point); + vY.resize(point); + vZ.resize(point); + vTVD.resize(point); + int point1=(acurveinfo.EndDepth-acurveinfo.StartDepth)/acurveinfo.DepLevel+1.5; + int point2=(acurveinfo.EndDepth-mWellHead.startDepth)/acurveinfo.DepLevel+0.5; + logio->ReadCurve(iAZIM,acurveinfo.StartDepth,point1,nAzim); + logio->ReadCurve(iDev,acurveinfo.StartDepth,point1,nDevi); + for(int i=point2;iGetObjectStatus(i)!=OBJECT_NORMAL) continue; + short curvetype=logio->GetObjectType(i); + if(curvetype==CURVE_OBJECT) { + char* curvename=new char[65]; + curvename[64]='\0'; + char* aliasname=new char[65]; + aliasname[64]='\0'; + logio->GetObjectName(i,curvename,NULL,aliasname); + logio->GetCurveInfo(i,&acurveinfo); + if(acurveinfo.DepLevel==0|| + acurveinfo.DepLevel==0xcdcdcdcd + ||acurveinfo.DepLevel>=2.226e+008|| + acurveinfo.StartDepth==acurveinfo.EndDepth){ + logio->DiscardObject(i); + delete curvename; + delete aliasname; + continue; + } + else { + curveindex=logio->OpenCurve(curvename); + delete curvename; + delete aliasname; + } + break; + } + } + float sdep=TVD,edep=TVD,rlev=0.125; + if(curveindex>-1) { + logio->GetCurveInfo(curveindex,&acurveinfo); + sdep=acurveinfo.StartDepth; + edep=acurveinfo.EndDepth; + rlev=acurveinfo.DepLevel; + ZD=sdep; + double z=mWellHead.earthEle-ZD+mWellHead.dEle; + double x=X_COORDINATE+XE+X0; + double y=Y_COORDINATE+YN+Y0;//井斜x,y坐标 + int count=(edep-sdep)/rlev+1.5; + vX.resize(count); + vY.resize(count); + vZ.resize(count); + vTVD.resize(count); + for(int i=0;iCreateCurve(&xinfo); + if(index>-1&&vX.size()) { + logio->WriteCurve(index,xinfo.StartDepth,vX.size(),(double *)&vX[0]); + logio->CloseCurve(index); + } + strcpy(xinfo.AliasName,"Y"); + strcpy(xinfo.Name,"Y"); + index=logio->CreateCurve(&xinfo); + if(index>-1&&vY.size()) { + logio->WriteCurve(index,xinfo.StartDepth,vY.size(),(double *)&vY[0]); + logio->CloseCurve(index); + } + strcpy(xinfo.AliasName,"Z"); + strcpy(xinfo.Name,"Z"); + index=logio->CreateCurve(&xinfo); + if(index>-1&&vZ.size()) { + logio->WriteCurve(index,xinfo.StartDepth,vZ.size(),(double *)&vZ[0]); + logio->CloseCurve(index); + } + strcpy(xinfo.AliasName,"TVD"); + strcpy(xinfo.Name,"TVD"); + xinfo.CodeLen=sizeof(float); + xinfo.RepCode=REPR_FLOAT; + index=logio->CreateCurve(&xinfo); + if(index>-1&&vTVD.size()) { + logio->WriteCurve(index,xinfo.StartDepth,vTVD.size(),(float *)&vTVD[0]); + logio->CloseCurve(index); + } + } + delete logio; + // Methodlib.unload(); + return vTVD.size(); +} // void CObjWell::Compute2DTrajectory(float _ProjAngle,double _HorizBoreXE,double _HorizBoreYN,float _HScale,float _VScale) // { diff --git a/OSGDataModel/src/TrackPoints.cpp b/OSGDataModel/src/TrackPoints.cpp new file mode 100644 index 0000000..55da7bf --- /dev/null +++ b/OSGDataModel/src/TrackPoints.cpp @@ -0,0 +1,295 @@ +// TrackPoints.cpp : Defines the initialization routines for the DLL. +// +#include "TrackPoints.h" +#include "stdio.h" +#include "stdlib.h" +#include "qmath.h" +#include "memory.h" +#include "string.h" +using namespace std; +// extern "C" +// { +// __declspec (dllexport) int TrackPoints(double nDevi,double nAzim,double rlev,double &XE,double &YN,double &ZD,double &HOFF0,double &HOAZ0,double >D0,double &AZIM0); +// __declspec (dllexport) int initTrackPoints(double azca,double tvd,double dxe,double dyn,double rlev=0,double GLDDDEP0=30,double hoff=0); +// } +double AZA0=0 ; //主投影方位 +double AZCA=0; //磁偏角 AZCA +//double DXS;//初始值 +//double DYS;//初始值 +double TVDS=0;//初始值 +double DZDA=0;//全局变量 +double FLSA=0; //FLSA=0.0为最小曲率法 FLSA=1.0为折线法 +double PI=3.1415926f; +double RLEA=0.125; //采样间隔 +double FLAG=1; //全局变量 +double XE=0; //东西位移 +double YN=0; //南北位移 +double ZD=0; //垂直深度 + +float OLDDEVI=0; +float OLDAZIM=0; + +double DEV1=0,AZIM1=0,DEV2=0,AZIM2=0;//全局变量 +double HOFF=0,HOAZ=0;//叫水平位移,后者叫闭合方位 +double rlev=0.125; +double oldnDevi=0; +double oldnAzim=0; +double oldnDevi1[1000]; +double oldnAzim1[1000]; +double GLDDDEP=30; +double DEP0=0; +int no=0; +int NON=1; +int initTrackPoints(double azca,double tvd,double dxe,double dyn,double rlev0,double GLDDDEP0,double hoff) +{ + //==================================================================== + AZA0=180 ; //主投影方位 + AZCA=azca; //磁偏角 AZCA + TVDS=tvd;//初始值????????? + DZDA=0;//全局变量 + FLSA=0; //FLSA=0.0为最小曲率法 FLSA=1.0为折线法 + FLAG=0; //全局变量 + XE=dyn; + YN=dxe;//井斜x,y坐标 + DEV1=0,AZIM1=0,DEV2=0,AZIM2=0;//全局变量 + HOFF=hoff,HOAZ=0;//叫水平位移,后者叫闭合方位 + ZD=tvd;//-w.earthEle-w.dEle ; //?????????? + OLDDEVI=0; + OLDAZIM=0; + oldnDevi=0; + oldnAzim=0; + memset(oldnDevi1,0,sizeof(double)*1000); + memset(oldnAzim1,0,sizeof(double)*1000); + GLDDDEP=GLDDDEP0; + DEP0=0; + no=0; + rlev=rlev0; + if(rlev) NON=GLDDDEP/rlev+0.5; + if(NON<1) NON=1; + return 1; +} + +int TrackPoints(double nDevi,double nAzim,double RLEA,double &XE0,double &YN0,double &ZD0,double &HOFF0,double &HOAZ0,double >D0,double &AZIM0) +{ + if(no<0) no=0; + if(nDevi!=-9999.0&&nDevi!=-999.25&&nDevi!=-99999.0) + { + oldnDevi=nDevi; + oldnAzim=nAzim; + } + double DEVI=oldnDevi; + double AZIM=oldnAzim; + if(RLEA==0) RLEA=rlev; + if(AZCA+nAzim<0) AZIM=AZCA+nAzim+360; + else AZIM=AZCA+nAzim; + double GTD=0; + + if(FLAG==1) + { + ZD=ZD+(1-pow((DEVI-OLDDEVI)*PI/180,2)/24.0)*RLEA*cos((OLDDEVI+DEVI)*PI/360); + XE=XE+(1-(pow((DEVI-OLDDEVI)*PI/180,2)+ + pow(((AZIM-OLDAZIM<-180?AZIM-OLDAZIM+360: + (AZIM-OLDAZIM>180?AZIM-OLDAZIM-360:AZIM-OLDAZIM)))*PI/180,2))/24)*RLEA + *sin((DEVI+OLDDEVI)/2*PI/180)*cos( + (AZIM-OLDAZIM>180?(AZIM+OLDAZIM-360)*PI/360: + (AZIM-OLDAZIM<-180?(AZIM+OLDAZIM+360)*PI/360:(AZIM+OLDAZIM)*PI/360))); + YN=YN+(1-(pow((DEVI-OLDDEVI)*PI/180,2)+pow(( + (AZIM-OLDAZIM<-180?AZIM-OLDAZIM+360: + (AZIM-OLDAZIM>180,AZIM-OLDAZIM-360,AZIM-OLDAZIM)))*PI/180,2))/24)*RLEA*sin((DEVI+OLDDEVI)/2*PI/180)*sin( + (AZIM-OLDAZIM>180?(AZIM+OLDAZIM-360)*PI/360: + (AZIM-OLDAZIM<-180?(AZIM+OLDAZIM+360)*PI/360:(AZIM+OLDAZIM)*PI/360))); + HOFF=sqrt(XE*XE+YN*YN); + + float val1=(XE>0)?((YN>0)?0:360):0; + float val2=(XE<0)?180:0; + + HOAZ=atan(YN/XE)*180/PI+val1+val2; + if(DEP0180?AZIM-oldnAzim1[0]-360: + AZIM-oldnAzim1[0]<-180?AZIM-oldnAzim1[0]+360:AZIM-oldnAzim1[0])/GLDDDEP,2)* + pow(sin((DEVI+oldnDevi1[0])/2*PI/180),2))*GLDDDEP;//30 + } + } + else { + HOFF=sqrt(XE*XE+YN*YN)+HOFF; + float val1=(XE>0)?((YN>0)?0:360):0; + float val2=(XE<0)?180:0; + float X=abs(XE); + float Y=abs(YN) ; + if((XE>0.0) && (YN>0.0)) HOAZ=atan2(X,Y) ; + if((XE>0.0) && (YN<0.0)) HOAZ=PI-atan2(X,Y); + if((XE<0.0) && (YN<0.0)) HOAZ=PI+atan2(X,Y); + if((XE<0.0) && (YN>0.0)) HOAZ=2*PI-atan2(X,Y) ; + if((XE==0.0) && (YN>0.0)) HOAZ=0.; + if((YN==0.0) && (XE>0.0)) HOAZ=0.5*PI; + if((XE==0.0) && (YN<0.0)) HOAZ=PI ; + if((YN==0.0) && (XE<0.0)) HOAZ=1.5*PI ; + HOAZ=(HOAZ*360.)/(2*PI) ; + GTD=0; + } + FLAG=1; + OLDDEVI=DEVI; + OLDAZIM=AZIM; + DEP0+=RLEA; + if(DEP0>GLDDDEP) DEP0=GLDDDEP; + if(rlev) { + if(no>=NON) { + no=NON-1; + memmove(&oldnDevi1[0],&oldnDevi1[1],no*sizeof(double)); + memmove(&oldnAzim1[0],&oldnAzim1[1],no*sizeof(double)); + } + } + oldnDevi1[no]=DEVI; + oldnAzim1[no]=AZIM; + no++; + /* + double oldnDevi=0; + double oldnAzim=0; + //////////////////////////////////////////////////////////////////////////// + if(nDevi!=-9999.0) + { + oldnDevi=nDevi; + oldnAzim=nAzim; + } + + + double DEVI=oldnDevi; + double AZIM=oldnAzim; + double RLES,DX,DY,TVD,DDB,DDV,DDE,DDA,X,Y; + + DEVI=(DEVI/180.)*PI; + AZIM= fmod(AZIM+AZCA+360.0,360.0); //AZCA=??? + RLES=RLEA; + AZIM=(AZIM/360.)*(2*PI); //AZA0=??? + if(RLEA==0.1524) + { + if((AZA0>=90.0) && (AZA0<180.0)) RLES=0.15241f; + if((AZA0>=180.0) && (AZA0<270.0)) RLES=0.152422f; + if((AZA0>=270.0) && (AZA0<=360.0)) RLES=0.1524333f; + if((AZA0>=0.0) && (AZA0 <15.0)) RLES=0.152388f; + if((AZA0>=15.0) && (AZA0 <90.0)) RLES=0.15242f; + } + if(RLEA==0.0762) + { + if((AZA0>=90.0) && (AZA0<140.0)) RLES=0.07623f; + if((AZA0>=140.0) && (AZA0<180.0)) RLES=0.0762332f; + if((AZA0>=180.0) && (AZA0<270.0)) RLES=0.0762331f; + if((AZA0>=270.0) && (AZA0<=360.0)) RLES=0.0762332f; + if((AZA0>=0.0) && (AZA0<15.0)) RLES=0.076188f; + if((AZA0>=15.0) && (AZA0<90.0)) RLES=0.07623325f; + } + + if(FLAG==1.0) // FLAG =???? + goto label_22; + FLAG=1.0; + DEV1=DEVI; + AZIM1=AZIM; + goto label_11; +label_22 : + DEV2=DEVI; + AZIM2=AZIM; + if(FLSA==0.0) + { + if((DEV2==DEV1) && (AZIM2==AZIM1)) goto label_100; + if((DEV2==DEV1) && (AZIM2!=AZIM1)) goto label_300; + if((DEV2!=DEV1) && (AZIM2==AZIM1)) goto label_200; + if ((AZIM1<=1.5*PI) && (AZIM1>=0.5*PI)) goto label_500; + if((AZIM2<=1.5*PI) && (AZIM2>=0.5*PI)) goto label_500; + if((AZIM1>1.5*PI) && (AZIM2>1.5*PI)) goto label_500; + if((AZIM1<0.5*PI) && (AZIM2<0.5*PI)) goto label_500; + if((AZIM1<0.5*PI) && (AZIM2>1.5*PI)) goto label_400; + DDA=(DEV2-DEV1)*(AZIM2+2*PI-AZIM1); + DDV=(cos(DEV1)-cos(DEV2))*(cos(AZIM1)-cos(AZIM2)); + DDE=(cos(DEV1)-cos(DEV2))*(sin(AZIM2)-sin(AZIM1)); + DX=(RLES*DDV)/DDA; + DY=(RLES*DDE)/DDA; + goto label_510; +label_400 : DDB=(DEV2-DEV1)*(AZIM2-2*PI-AZIM1); + DDV=(cos(DEV1)-cos(DEV2))*(cos(AZIM1)-cos(AZIM2)); + DDE=(cos(DEV1)-cos(DEV2))*(sin(AZIM2)-sin(AZIM1)); + DX=(RLES*DDV)/DDB; + DY=(RLES*DDE)/DDB; + goto label_510; +label_500 : DDB=(DEV2-DEV1)*(AZIM2-AZIM1); + DDV=(cos(DEV1)-cos(DEV2))*(cos(AZIM1)-cos(AZIM2)); + DDE=(cos(DEV1)-cos(DEV2))*(sin(AZIM2)-sin(AZIM1)); + DX=(RLES*DDV)/DDB; + DY=(RLES*DDE)/DDB; +label_510 : TVD=(RLES*(sin(DEV2)-sin(DEV1)))/(DEV2-DEV1); + goto label_666; +label_100 : DX=RLES*sin(DEV2)*sin(AZIM2); + DY=RLES*sin(DEV2)*cos(AZIM2); + TVD=RLES*cos(DEV2); + goto label_666; +label_200 : DX=(RLES*(cos(DEV1)-cos(DEV2))*sin(AZIM2))/(DEV2-DEV1); + DY=(RLES*(cos(DEV1)-cos(DEV2))*cos(AZIM2))/(DEV2-DEV1); + TVD=(RLES*(sin(DEV2)-sin(DEV1)))/(DEV2-DEV1); + goto label_666; +label_300 : if ((AZIM1<=1.5*PI) && (AZIM1>=0.5*PI)) goto label_600; + if((AZIM2<=1.5*PI) && (AZIM2>=0.5*PI)) goto label_600; + if((AZIM1>1.5*PI) && (AZIM2>1.5*PI)) goto label_600; + if((AZIM1<0.5*PI) && (AZIM2<0.5*PI)) goto label_600; + if((AZIM1<0.5*PI) && (AZIM2>1.5*PI)) goto label_550; + DX=(RLES*(cos(AZIM1)-cos(AZIM2))*sin(DEV2))/(2*PI+AZIM2-AZIM1); + DY=(RLES*(sin(AZIM2)-sin(AZIM1))*sin(DEV2))/(2*PI+AZIM2-AZIM1); + goto label_650; +label_550 : DX=(RLES*(cos(AZIM1)-cos(AZIM2))*sin(DEV2))/(AZIM2-AZIM1-2*PI); + DY=(RLES*(sin(AZIM2)-sin(AZIM1))*sin(DEV2))/(AZIM2-AZIM1-2*PI); + goto label_650; +label_600 : DX=(RLES*(cos(AZIM1)-cos(AZIM2))*sin(DEV2))/(AZIM2-AZIM1); + DY=(RLES*(sin(AZIM2)-sin(AZIM1))*sin(DEV2))/(AZIM2-AZIM1); +label_650 : TVD=RLES*cos(DEV2); +label_666 : + XE=XE+DX; + YN=YN+DY; + DZDA=DZDA+TVD; //DZDA=? + ZD=TVDS+DZDA; //TVDS=? + } + if(FLSA==1.0) + { + DX=RLES*sin(DEV2)*sin(AZIM2); + DY=RLES*sin(DEV2)*cos(AZIM2); + TVD=RLES*cos(DEV2); + XE=XE+DX; + YN=YN+DY; + DZDA=DZDA+TVD; + ZD=TVDS+DZDA; + } + DEV1=DEV2; + AZIM1=AZIM2; + +label_11 : ; + HOFF=sqrt(XE*XE+YN*YN); + X=abs(XE); + Y=abs(YN) ; + if((XE>0.0) && (YN>0.0)) HOAZ=atan2(X,Y) ; + if((XE>0.0) && (YN<0.0)) HOAZ=PI-atan2(X,Y); + if((XE<0.0) && (YN<0.0)) HOAZ=PI+atan2(X,Y); + if((XE<0.0) && (YN>0.0)) HOAZ=2*PI-atan2(X,Y) ; + if((XE==0.0) && (YN>0.0)) HOAZ=0.; + if((YN==0.0) && (XE>0.0)) HOAZ=0.5*PI; + if((XE==0.0) && (YN<0.0)) HOAZ=PI ; + if((YN==0.0) && (XE<0.0)) HOAZ=1.5*PI ; + HOAZ=(HOAZ*360.)/(2*PI) ; + float GTD=0; + GTD=sqrt(pow((DEVI-OLDDEVI)/RLEA,2)+ + pow((AZIM-OLDAZIM>180?AZIM-OLDAZIM-360: + AZIM-OLDAZIM<-180?AZIM-OLDAZIM+360:AZIM-OLDAZIM)/RLEA,2)* + pow(sin((DEVI+OLDDEVI)/2*PI/180),2))*RLEA;//30 + + OLDDEVI=DEVI; + OLDAZIM=AZIM; +*/ + XE0=YN; + YN0=XE; + ZD0=ZD; + HOAZ0=HOAZ; + HOFF0=HOFF; + GTD0=GTD; + AZIM0=AZIM; + return 1; +}