This commit is contained in:
DESKTOP-450PEFP\mainc 2026-03-29 16:55:12 +08:00
commit 2484bf32f4
6 changed files with 930 additions and 321 deletions

View File

@ -4,12 +4,14 @@
#include "IConvertor.h" #include "IConvertor.h"
//#include "ObjWelllogRound.h" //#include "ObjWelllogRound.h"
#include <QLineEdit> #include <QLineEdit>
#include <qDebug>
//#include "DataImport.h" //#include "DataImport.h"
#include "CStringType.h" #include "CStringType.h"
#include "MyWelllogRound.h" #include "MyWelllogRound.h"
#include "tishidialog.h" #include "tishidialog.h"
#include "ui_interfaceWidget.h" #include "ui_interfaceWidget.h"
//#include "ObjectEvent.h" //#include "ObjectEvent.h"
#include "ObjWell.h"
#include "MemRdWt.h" #include "MemRdWt.h"
BEGIN_OSGGRAPHICS_NAMESPACE; BEGIN_OSGGRAPHICS_NAMESPACE;
ImportDataDialog::ImportDataDialog(QWidget *parent,QString wellname,QString wellroundname): QDialog(parent),m_FilePath(""),m_ExistSameWellName(false),m_ExistSameWellRoundName(false) 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<int> &OutCurveNo,vector
// } // }
// return 0; // 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;i<curveCount;i++) {
logio->GetObjectName(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;kk<count;kk=kk+10)
{
float buf[200];
buf[0]=0;
float temp=logio->GetData(acurveinfo.RepCode,&vVdl.vchar[kk*acurveinfo.CodeLen],buf);
if(_isnan(temp)||!_finite(temp)) continue;
if(acurveinfo.MaxValue<temp) if(temp!=-9999.0&&temp!=-999.25&&temp!=-99999.0)acurveinfo.MaxValue=temp;
if(acurveinfo.MinValue>temp) 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) bool ImportDataDialog::SelectAndDeleteWellLog(int iRow,InterfaceWidget *pCurrentInterfaceWidget,int ColumnCount,IConvertor *pConvertor)
{ {
InterIConvertor*tpConvertor=dynamic_cast<InterIConvertor*>(pConvertor); InterIConvertor*tpConvertor=dynamic_cast<InterIConvertor*>(pConvertor);
@ -726,7 +998,8 @@ bool ImportDataDialog::SelectAndDeleteWellLog(int iRow,InterfaceWidget *pCurren
((InterIConvertor*)(pCurrentInterfaceWidget->m_pConvertor))->InitWellInfo(outfile); ((InterIConvertor*)(pCurrentInterfaceWidget->m_pConvertor))->InitWellInfo(outfile);
wellRound->SaveMeesge(outfile); wellRound->SaveMeesge(outfile);
} }
//CDataImport::ChangetoSlf(outfile,NULL); // CDataImport::ChangetoSlf(outfile,NULL);
ChangetoSlf(outfile,NULL,true);
} }
for(int i=0;i<OutCurveNo.size();i++) for(int i=0;i<OutCurveNo.size();i++)
{ {

View File

@ -132,7 +132,7 @@ public:
{ {
isFLAG=flag; isFLAG=flag;
} }
// void SetDepth(CObjWell *pWell); void SetDepth(CObjWell *pWell);
/** /**
* *
@ -162,7 +162,7 @@ public:
/* @brief 得到本井次下的对应模板值的井曲线 */ /* @brief 得到本井次下的对应模板值的井曲线 */
/************************************************************************/ /************************************************************************/
// pai::datamodel::CObjWellLog* GetWellLogByTemplate(QString wellroundPath,const QVariant& templateKey); // pai::datamodel::CObjWellLog* GetWellLogByTemplate(QString wellroundPath,const QVariant& templateKey);
// static int ComputeTrajectory(CObjWell *pWell,QString Slffilename); static int ComputeTrajectory(CObjWell *pWell,QString Slffilename);
private: private:
/** /**

View File

@ -0,0 +1,37 @@
// TrackPoints.h : main header file for the TrackPoints DLL
//
#pragma once
// #define bool bool
#if defined(_WIN64)
typedef __int64 INT_PTR, *PINT_PTR;
typedef unsigned __int64 UINT_PTR, *PUINT_PTR;
typedef __int64 LONG_PTR, *PLONG_PTR;
typedef unsigned __int64 ULONG_PTR, *PULONG_PTR;
#define __int3264 __int64
#else
typedef _W64 int INT_PTR, *PINT_PTR;
typedef _W64 unsigned int UINT_PTR, *PUINT_PTR;
typedef _W64 long LONG_PTR, *PLONG_PTR;
typedef _W64 unsigned long ULONG_PTR, *PULONG_PTR;
#define __int3264 __int32
#endif
typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
#define MAKEWORD(a, b) ((WORD)(((BYTE)(((DWORD_PTR)(a)) & 0xff)) | ((WORD)((BYTE)(((DWORD_PTR)(b)) & 0xff))) << 8))
#define MAKELONG(a, b) ((LONG)(((WORD)(((DWORD_PTR)(a)) & 0xffff)) | ((DWORD)((WORD)(((DWORD_PTR)(b)) & 0xffff))) << 16))
#define LOWORD(l) ((WORD)(((DWORD_PTR)(l)) & 0xffff))
#define HIWORD(l) ((WORD)((((DWORD_PTR)(l)) >> 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 &GTD0,double &AZIM0);
int initTrackPoints(double azca,double tvd,double dxe,double dyn,double rlev=0,double GLDDDEP0=30,double hoff=0);
//#include "DepthProgress.h"

View File

@ -45,6 +45,7 @@ HEADERS += \
../include/ObjWelllogINP.h \ ../include/ObjWelllogINP.h \
../include/ObjWelllogTABLE.h \ ../include/ObjWelllogTABLE.h \
../include/ObjWelllogWavefile.h \ ../include/ObjWelllogWavefile.h \
../include/TrackPoints.H \
../include/WellLogWorkflowDataModel.h ../include/WellLogWorkflowDataModel.h
#CPATH = $$system(pwd) #CPATH = $$system(pwd)

View File

@ -13,6 +13,8 @@
// #include "ObjectEvent.h" // #include "ObjectEvent.h"
#include <QSettings> #include <QSettings>
#include <QTextCodec> #include <QTextCodec>
#include "geometryutils.h"
#include "TrackPoints.H"
#pragma warning( pop ) #pragma warning( pop )
@ -129,10 +131,11 @@ void CObjWell::SaveWellHead(QString wellfilename)
delete logio; delete logio;
} }
// int CObjWell::GetAllWellRound(QList<PaiObject*> &wellroundchildren) // int CObjWell::GetAllWellRound(QList<PaiObject*> &wellroundchildren)
// { // {
// this->GetObjectByType(wellroundchildren,GetClassID_WellLogRound()); // this->GetObjectByType(wellroundchildren,GetClassID_WellLogRound());
// return wellroundchildren.size(); // return wellroundchildren.size();
// } // }
// int CObjWell::GetWellRoundCount() // int CObjWell::GetWellRoundCount()
@ -723,332 +726,332 @@ void CObjWell::ClearXYZ()
// } // }
// return bSuccess; // return bSuccess;
// } // }
// void CObjWell::SetDepth(CObjWell *pWell) void CObjWell::SetDepth(CObjWell *pWell)
// { {
// if(pWell) // if(pWell)
// { // {
// int roc=pWell->GetWellRoundCount(); // int roc=pWell->GetWellRoundCount();
// if(roc) // if(roc)
// { // {
// QList<PaiObject*>childs; // QList<PaiObject*>childs;
// pWell->GetAllWellRound(childs); // pWell->GetAllWellRound(childs);
// double stardep=99999,enddep=-99999; // double stardep=99999,enddep=-99999;
// float rlev=100; // float rlev=100;
// for(int i=0;i<roc;i++) // for(int i=0;i<roc;i++)
// { // {
// CObjWelllogRound* pWelllogRound=dynamic_cast<CObjWelllogRound*>(childs[i]); // CObjWelllogRound* pWelllogRound=dynamic_cast<CObjWelllogRound*>(childs[i]);
// if(!pWelllogRound) continue; // if(!pWelllogRound) continue;
// CLogIO * logio=new CLogIO(); // CLogIO * logio=new CLogIO();
// if(!logio->Open(pWelllogRound->GetSlfFileName().toStdString().c_str(),CSlfIO::modeReadWrite)) // if(!logio->Open(pWelllogRound->GetSlfFileName().toStdString().c_str(),CSlfIO::modeReadWrite))
// { // {
// delete logio; // delete logio;
// break; // break;
// } // }
// int curveCount=logio->GetObjectCount(); // int curveCount=logio->GetObjectCount();
// for(int k1=0;k1<curveCount;k1++) // for(int k1=0;k1<curveCount;k1++)
// { // {
// char buf[64]; // char buf[64];
// logio->GetObjectName(k1,buf); // logio->GetObjectName(k1,buf);
// int a=logio->OpenCurve(buf); // int a=logio->OpenCurve(buf);
// if(a>-1) // if(a>-1)
// { // {
// Slf_CURVE acurveinfo; // Slf_CURVE acurveinfo;
// logio->GetCurveInfo(a,&acurveinfo); // logio->GetCurveInfo(a,&acurveinfo);
// if(acurveinfo.StartDepth<stardep) stardep=acurveinfo.StartDepth; // if(acurveinfo.StartDepth<stardep) stardep=acurveinfo.StartDepth;
// if(acurveinfo.EndDepth>enddep) enddep=acurveinfo.EndDepth; // if(acurveinfo.EndDepth>enddep) enddep=acurveinfo.EndDepth;
// if(rlev>acurveinfo.DepLevel) rlev=acurveinfo.DepLevel; // if(rlev>acurveinfo.DepLevel) rlev=acurveinfo.DepLevel;
// } // }
// else { // else {
// int a=logio->OpenWave(buf); // int a=logio->OpenWave(buf);
// if(a>-1) // if(a>-1)
// { // {
// Slf_WAVE acurveinfo; // Slf_WAVE acurveinfo;
// logio->GetWaveInfo(a,&acurveinfo); // logio->GetWaveInfo(a,&acurveinfo);
// if(acurveinfo.StartDepth<stardep) stardep=acurveinfo.StartDepth; // if(acurveinfo.StartDepth<stardep) stardep=acurveinfo.StartDepth;
// if(acurveinfo.EndDepth>enddep) enddep=acurveinfo.EndDepth; // if(acurveinfo.EndDepth>enddep) enddep=acurveinfo.EndDepth;
// if(rlev>acurveinfo.DepLevel) rlev=acurveinfo.DepLevel; // if(rlev>acurveinfo.DepLevel) rlev=acurveinfo.DepLevel;
// } // }
// } // }
// } // }
// if(rlev<=0) rlev=0.125; // if(rlev<=0) rlev=0.125;
// delete logio; // delete logio;
// } // }
// pWell->SetDepth(stardep,enddep,rlev); // pWell->SetDepth(stardep,enddep,rlev);
// } // }
// } // }
// } }
// int CObjWell::ComputeTrajectory(CObjWell *pWell,QString slffilename) int CObjWell::ComputeTrajectory(CObjWell *pWell,QString slffilename)
// { {
// pWell->SetDepth(pWell); pWell->SetDepth(pWell);
// QLibrary Methodlib; // QLibrary Methodlib;
// QString PeModulePath=QCoreApplication::applicationDirPath() + QDir::separator() +"TrackPoints.dll"; // QString PeModulePath=QCoreApplication::applicationDirPath() + QDir::separator() +"TrackPoints.dll";
// Methodlib.setFileName(PeModulePath); // Methodlib.setFileName(PeModulePath);
// Methodlib.load(); // Methodlib.load();
// typedef int (* LPFNDLLFUNC1)(double azca,double tvd,double dxe,double dyn,double rlev0,double Gldddep,double hoff); // typedef int (* LPFNDLLFUNC1)(double azca,double tvd,double dxe,double dyn,double rlev0,double Gldddep,double hoff);
// LPFNDLLFUNC1 initTrackPoints; // LPFNDLLFUNC1 initTrackPoints;
// typedef int (* LPFNDLLFUNC2)(double nDevi,double nAzim,double rlev,double &XE,double &YN,double &ZD,double &HOFF0,double &HOAZ0,double &GTD0,double &AZIM0); // typedef int (* LPFNDLLFUNC2)(double nDevi,double nAzim,double rlev,double &XE,double &YN,double &ZD,double &HOFF0,double &HOAZ0,double &GTD0,double &AZIM0);
// LPFNDLLFUNC2 TrackPoints; // LPFNDLLFUNC2 TrackPoints;
// QString initfname="initTrackPoints"; // QString initfname="initTrackPoints";
// QString funname="TrackPoints"; // QString funname="TrackPoints";
// initTrackPoints = (LPFNDLLFUNC1)(Methodlib.resolve(initfname.toStdString().c_str()));//strDLLFun.toStdString().c_str()) // initTrackPoints = (LPFNDLLFUNC1)(Methodlib.resolve(initfname.toStdString().c_str()));//strDLLFun.toStdString().c_str())
// TrackPoints = (LPFNDLLFUNC2)(Methodlib.resolve(funname.toStdString().c_str()));//strDLLFun.toStdString().c_str()) // TrackPoints = (LPFNDLLFUNC2)(Methodlib.resolve(funname.toStdString().c_str()));//strDLLFun.toStdString().c_str())
// QStringList CurveNames; QStringList CurveNames;
// int iDev=-1,iAZIM=-1,iX=-1,iY=-1,iZ=-1,iDepth=-1; int iDev=-1,iAZIM=-1,iX=-1,iY=-1,iZ=-1,iDepth=-1;
// Slf_FILE_MESSAGE mssage; 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)) if(!logio->Open(slffilename.toStdString().c_str(),CSlfIO::modeReadWrite))
// { {
// delete logio; delete logio;
// QString aa=slffilename+"文件打开失败,请检查!"; QString aa=slffilename+"文件打开失败,请检查!";
// // AppendConsole(pai::log::PAI_ERROR,aa); // AppendConsole(pai::log::PAI_ERROR,aa);
// Methodlib.unload(); // Methodlib.unload();
// return 0; return 0;
// } }
// logio->GetFileMessage(mssage); logio->GetFileMessage(mssage);
// QString path,wen,slfn; QString path,wen,slfn;
// GetWellNameAndPath(slffilename,wen,path,slfn); GetWellNameAndPath(slffilename,wen,path/*,slfn*/);
// if(slfn.indexOf(".well",0,Qt::CaseInsensitive)==-1) if(slfn.indexOf(".well",0,Qt::CaseInsensitive)==-1)
// { {
// QString slf; QString slf;
// if(strlen(mssage.WellName)==0||mssage.WellName[0]==' ') if(strlen(mssage.WellName)==0||mssage.WellName[0]==' ')
// { {
// int len=slffilename.indexOf(".slf",0,Qt::CaseInsensitive); int len=slffilename.indexOf(".slf",0,Qt::CaseInsensitive);
// slf=slffilename.mid(0,len)+".well"; slf=slffilename.mid(0,len)+".well";
// } }
// else slf=path+"/"+mssage.WellName+".well"; else slf=path+"/"+mssage.WellName+".well";
// CMemRdWt sf(slf.toStdString().c_str(),CSlfIO::modeReadWrite); CMemRdWt sf(slf.toStdString().c_str(),CSlfIO::modeReadWrite);
// Slf_FILE_MESSAGE sm; Slf_FILE_MESSAGE sm;
// sf.GetFileMessage(sm); sf.GetFileMessage(sm);
// if(sm.Xcoor!=mssage.Xcoor) if(sm.Xcoor!=mssage.Xcoor)
// { {
// if(sm.Xcoor>1&&(_finite(sm.Xcoor)&&!_isnan(sm.Xcoor))) mssage.Xcoor=sm.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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; else if(mssage.Y0&&(_finite(mssage.Y0)&&!_isnan(mssage.Y0)))sm.Y0=mssage.Y0;
// sf.SetFileMessage(sm); sf.SetFileMessage(sm);
// logio->SetFileMessage(mssage); logio->SetFileMessage(mssage);
// } }
// } }
// int curveCount=logio->GetObjectCount(); int curveCount=logio->GetObjectCount();
// //说明从项目或者井节点发起attachSLF,需要读取slf获得井名和井次信息 //说明从项目或者井节点发起attachSLF,需要读取slf获得井名和井次信息
// QString wellname=""; QString wellname="";
// QString wellRoundname=""; QString wellRoundname="";
// QStringList azims=GetSimilarCurves("AZIM"); QStringList azims=GetSimilarCurves("AZIM");
// foreach(QString cname,azims) foreach(QString cname,azims)
// { {
// iAZIM=logio->OpenCurve(cname.toStdString().c_str()); iAZIM=logio->OpenCurve(cname.toStdString().c_str());
// if(iAZIM>-1) break; if(iAZIM>-1) break;
// } }
// QStringList devis=GetSimilarCurves("DEVI"); QStringList devis=GetSimilarCurves("DEVI");
// foreach(QString cname,devis) foreach(QString cname,devis)
// { {
// iDev=logio->OpenCurve(cname.toStdString().c_str()); iDev=logio->OpenCurve(cname.toStdString().c_str());
// if(iDev>-1) break; if(iDev>-1) break;
// } }
// Slf_CURVE acurveinfo; Slf_CURVE acurveinfo;
// memset(&acurveinfo,0,sizeof(Slf_CURVE)); memset(&acurveinfo,0,sizeof(Slf_CURVE));
// float AZCA=mssage.azca,TVD=mssage.TVD,X0=mssage.X0,Y0=mssage.Y0; float AZCA=mssage.azca,TVD=mssage.TVD,X0=mssage.X0,Y0=mssage.Y0;
// double XE=X0,YN=Y0; double XE=X0,YN=Y0;
// float Altitude=mssage.Altitude; float Altitude=mssage.Altitude;
// float X_COORDINATE=mssage.Xcoor; float X_COORDINATE=mssage.Xcoor;
// float Y_COORDINATE=mssage.Ycoor;//井斜x,y坐标 float Y_COORDINATE=mssage.Ycoor;//井斜x,y坐标
// float KB=ConvertDataByFloat(mssage.Kelly).toFloat(); float KB=ConvertDataByFloat(mssage.Kelly).toFloat();
// double HOFF0=0; double HOFF0=0;
// double HOAZ0=0,gtd=0; double HOAZ0=0,gtd=0;
// double AZIM0=0; double AZIM0=0;
// if(iAZIM>-1) logio->GetCurveInfo(iAZIM,&acurveinfo); if(iAZIM>-1) logio->GetCurveInfo(iAZIM,&acurveinfo);
// WellHead &mWellHead=pWell->GetWellHead(); WellHead &mWellHead=pWell->GetWellHead();
// mWellHead.x=X_COORDINATE; mWellHead.x=X_COORDINATE;
// mWellHead.y=Y_COORDINATE; mWellHead.y=Y_COORDINATE;
// if(KB==-9999) KB=0; if(KB==-9999) KB=0;
// if(KB==-99999) KB=0; if(KB==-99999) KB=0;
// mWellHead.dEle=KB; mWellHead.dEle=KB;
// mWellHead.earthEle=Altitude; mWellHead.earthEle=Altitude;
// mWellHead.depth=acurveinfo.StartDepth; mWellHead.depth=acurveinfo.StartDepth;
// mWellHead.startDepth=acurveinfo.StartDepth; mWellHead.startDepth=acurveinfo.StartDepth;
// mWellHead.azca=AZCA; mWellHead.azca=AZCA;
// mWellHead.endDepth=acurveinfo.EndDepth; mWellHead.endDepth=acurveinfo.EndDepth;
// if(TVD==0) TVD=mWellHead.startDepth; if(TVD==0) TVD=mWellHead.startDepth;
// mWellHead.tvd=TVD; mWellHead.tvd=TVD;
// mWellHead.z=mWellHead.earthEle+mWellHead.dEle-TVD; mWellHead.z=mWellHead.earthEle+mWellHead.dEle-TVD;
// mWellHead.dxe=X0; mWellHead.dxe=X0;
// mWellHead.dyn=Y0; mWellHead.dyn=Y0;
// // if(mWellHead.tvd==0) mWellHead.tvd=TVD; // if(mWellHead.tvd==0) mWellHead.tvd=TVD;
// double ZD=mWellHead.tvd; double ZD=mWellHead.tvd;
// if(mWellHead.tvd==0) ZD=TVD; if(mWellHead.tvd==0) ZD=TVD;
// //TVD=mWellHead.tvd; //TVD=mWellHead.tvd;
// std::vector<double>vX; std::vector<double>vX;
// std::vector<double>vY; std::vector<double>vY;
// std::vector<double>vZ; std::vector<double>vZ;
// std::vector<float>vTVD; std::vector<float>vTVD;
// if(iAZIM>=0&&iDev>=0&&acurveinfo.DepLevel) { if(iAZIM>=0&&iDev>=0&&acurveinfo.DepLevel) {
// initTrackPoints(AZCA,TVD,X0,Y0,acurveinfo.DepLevel,30,0); initTrackPoints(AZCA,TVD,X0,Y0,acurveinfo.DepLevel,30,0);
// int point=(mWellHead.endDepth-mWellHead.startDepth)/acurveinfo.DepLevel+1.5; int point=(mWellHead.endDepth-mWellHead.startDepth)/acurveinfo.DepLevel+1.5;
// float *nDevi=new float[point+1]; float *nDevi=new float[point+1];
// memset(nDevi,0,sizeof(float)*point); memset(nDevi,0,sizeof(float)*point);
// float *nAzim=new float[point+1]; float *nAzim=new float[point+1];
// memset(nAzim,0,sizeof(float)*point); memset(nAzim,0,sizeof(float)*point);
// vX.resize(point); vX.resize(point);
// vY.resize(point); vY.resize(point);
// vZ.resize(point); vZ.resize(point);
// vTVD.resize(point); vTVD.resize(point);
// int point1=(acurveinfo.EndDepth-acurveinfo.StartDepth)/acurveinfo.DepLevel+1.5; int point1=(acurveinfo.EndDepth-acurveinfo.StartDepth)/acurveinfo.DepLevel+1.5;
// int point2=(acurveinfo.EndDepth-mWellHead.startDepth)/acurveinfo.DepLevel+0.5; int point2=(acurveinfo.EndDepth-mWellHead.startDepth)/acurveinfo.DepLevel+0.5;
// logio->ReadCurve(iAZIM,acurveinfo.StartDepth,point1,nAzim); logio->ReadCurve(iAZIM,acurveinfo.StartDepth,point1,nAzim);
// logio->ReadCurve(iDev,acurveinfo.StartDepth,point1,nDevi); logio->ReadCurve(iDev,acurveinfo.StartDepth,point1,nDevi);
// for(int i=point2;i<point-1;i++) for(int i=point2;i<point-1;i++)
// { {
// nDevi[i]=nDevi[point2-1]; nDevi[i]=nDevi[point2-1];
// nAzim[i]=nAzim[point2-1]; nAzim[i]=nAzim[point2-1];
// } }
// for(int i=0;i<point;i++) { for(int i=0;i<point;i++) {
// TrackPoints(nDevi[i],nAzim[i],acurveinfo.DepLevel,XE,YN,ZD,HOFF0,HOAZ0,gtd,AZIM0); TrackPoints(nDevi[i],nAzim[i],acurveinfo.DepLevel,XE,YN,ZD,HOFF0,HOAZ0,gtd,AZIM0);
// //x0; //x0;
// //y0; //xy偏移 //y0; //xy偏移
// //tvd; //井口垂直高度 //tvd; //井口垂直高度
// //depth; //测量深度 //depth; //测量深度
// //Altitude ; //地面海拔 //Altitude ; //地面海拔
// //KB; // 补心高 //KB; // 补心高
// //azca; // 闭合方位,磁偏角 //azca; // 闭合方位,磁偏角
// double z=mWellHead.earthEle-ZD+mWellHead.dEle; double z=mWellHead.earthEle-ZD+mWellHead.dEle;
// double x=X_COORDINATE+XE; double x=X_COORDINATE+XE;
// double y=Y_COORDINATE+YN;//井斜x,y坐标 double y=Y_COORDINATE+YN;//井斜x,y坐标
// float tvd=ZD; float tvd=ZD;
// vX[i]=x; vX[i]=x;
// vY[i]=y; vY[i]=y;
// vZ[i]=z; vZ[i]=z;
// vTVD[i]=tvd; vTVD[i]=tvd;
// } }
// delete nDevi; delete nDevi;
// delete nAzim; delete nAzim;
// } }
// else { else {
// int curveindex=-1; int curveindex=-1;
// for(int i=0;i<curveCount;i++) { for(int i=0;i<curveCount;i++) {
// if(logio->GetObjectStatus(i)!=OBJECT_NORMAL) continue; if(logio->GetObjectStatus(i)!=OBJECT_NORMAL) continue;
// short curvetype=logio->GetObjectType(i); short curvetype=logio->GetObjectType(i);
// if(curvetype==CURVE_OBJECT) { if(curvetype==CURVE_OBJECT) {
// char* curvename=new char[65]; char* curvename=new char[65];
// curvename[64]='\0'; curvename[64]='\0';
// char* aliasname=new char[65]; char* aliasname=new char[65];
// aliasname[64]='\0'; aliasname[64]='\0';
// logio->GetObjectName(i,curvename,NULL,aliasname); logio->GetObjectName(i,curvename,NULL,aliasname);
// logio->GetCurveInfo(i,&acurveinfo); logio->GetCurveInfo(i,&acurveinfo);
// if(acurveinfo.DepLevel==0|| if(acurveinfo.DepLevel==0||
// acurveinfo.DepLevel==0xcdcdcdcd acurveinfo.DepLevel==0xcdcdcdcd
// ||acurveinfo.DepLevel>=2.226e+008|| ||acurveinfo.DepLevel>=2.226e+008||
// acurveinfo.StartDepth==acurveinfo.EndDepth){ acurveinfo.StartDepth==acurveinfo.EndDepth){
// logio->DiscardObject(i); logio->DiscardObject(i);
// delete curvename; delete curvename;
// delete aliasname; delete aliasname;
// continue; continue;
// } }
// else { else {
// curveindex=logio->OpenCurve(curvename); curveindex=logio->OpenCurve(curvename);
// delete curvename; delete curvename;
// delete aliasname; delete aliasname;
// } }
// break; break;
// } }
// } }
// float sdep=TVD,edep=TVD,rlev=0.125; float sdep=TVD,edep=TVD,rlev=0.125;
// if(curveindex>-1) { if(curveindex>-1) {
// logio->GetCurveInfo(curveindex,&acurveinfo); logio->GetCurveInfo(curveindex,&acurveinfo);
// sdep=acurveinfo.StartDepth; sdep=acurveinfo.StartDepth;
// edep=acurveinfo.EndDepth; edep=acurveinfo.EndDepth;
// rlev=acurveinfo.DepLevel; rlev=acurveinfo.DepLevel;
// ZD=sdep; ZD=sdep;
// double z=mWellHead.earthEle-ZD+mWellHead.dEle; double z=mWellHead.earthEle-ZD+mWellHead.dEle;
// double x=X_COORDINATE+XE+X0; double x=X_COORDINATE+XE+X0;
// double y=Y_COORDINATE+YN+Y0;//井斜x,y坐标 double y=Y_COORDINATE+YN+Y0;//井斜x,y坐标
// int count=(edep-sdep)/rlev+1.5; int count=(edep-sdep)/rlev+1.5;
// vX.resize(count); vX.resize(count);
// vY.resize(count); vY.resize(count);
// vZ.resize(count); vZ.resize(count);
// vTVD.resize(count); vTVD.resize(count);
// for(int i=0;i<count;i++) { for(int i=0;i<count;i++) {
// z-=rlev; z-=rlev;
// ZD+=rlev; ZD+=rlev;
// vX[i]=x; vX[i]=x;
// vY[i]=y; vY[i]=y;
// vZ[i]=z; vZ[i]=z;
// vTVD[i]=ZD; vTVD[i]=ZD;
// } }
// } }
// else { else {
// memset(&acurveinfo,0,sizeof(Slf_CURVE)); memset(&acurveinfo,0,sizeof(Slf_CURVE));
// } }
// } }
// // if(acurveinfo.DepLevel&&acurveinfo.StartDepth!=acurveinfo.EndDepth) // if(acurveinfo.DepLevel&&acurveinfo.StartDepth!=acurveinfo.EndDepth)
// { {
// Slf_CURVE xinfo; Slf_CURVE xinfo;
// memset(&xinfo,0,sizeof(xinfo)); memset(&xinfo,0,sizeof(xinfo));
// xinfo.DepLevel=acurveinfo.DepLevel; xinfo.DepLevel=acurveinfo.DepLevel;
// if(xinfo.DepLevel==0) xinfo.DepLevel=0.125; if(xinfo.DepLevel==0) xinfo.DepLevel=0.125;
// xinfo.StartDepth=acurveinfo.StartDepth; xinfo.StartDepth=acurveinfo.StartDepth;
// xinfo.EndDepth=acurveinfo.EndDepth; xinfo.EndDepth=acurveinfo.EndDepth;
// xinfo.MaxValue=-999999; xinfo.MaxValue=-999999;
// xinfo.MinValue=999999; xinfo.MinValue=999999;
// xinfo.CodeLen=sizeof(double); xinfo.CodeLen=sizeof(double);
// xinfo.RepCode=REPR_DOUBLE; xinfo.RepCode=REPR_DOUBLE;
// strcpy(xinfo.AliasName,"X"); strcpy(xinfo.AliasName,"X");
// strcpy(xinfo.Name,"X"); strcpy(xinfo.Name,"X");
// int index=logio->CreateCurve(&xinfo); int index=logio->CreateCurve(&xinfo);
// if(index>-1&&vX.size()) { if(index>-1&&vX.size()) {
// logio->WriteCurve(index,xinfo.StartDepth,vX.size(),(double *)&vX[0]); logio->WriteCurve(index,xinfo.StartDepth,vX.size(),(double *)&vX[0]);
// logio->CloseCurve(index); logio->CloseCurve(index);
// } }
// strcpy(xinfo.AliasName,"Y"); strcpy(xinfo.AliasName,"Y");
// strcpy(xinfo.Name,"Y"); strcpy(xinfo.Name,"Y");
// index=logio->CreateCurve(&xinfo); index=logio->CreateCurve(&xinfo);
// if(index>-1&&vY.size()) { if(index>-1&&vY.size()) {
// logio->WriteCurve(index,xinfo.StartDepth,vY.size(),(double *)&vY[0]); logio->WriteCurve(index,xinfo.StartDepth,vY.size(),(double *)&vY[0]);
// logio->CloseCurve(index); logio->CloseCurve(index);
// } }
// strcpy(xinfo.AliasName,"Z"); strcpy(xinfo.AliasName,"Z");
// strcpy(xinfo.Name,"Z"); strcpy(xinfo.Name,"Z");
// index=logio->CreateCurve(&xinfo); index=logio->CreateCurve(&xinfo);
// if(index>-1&&vZ.size()) { if(index>-1&&vZ.size()) {
// logio->WriteCurve(index,xinfo.StartDepth,vZ.size(),(double *)&vZ[0]); logio->WriteCurve(index,xinfo.StartDepth,vZ.size(),(double *)&vZ[0]);
// logio->CloseCurve(index); logio->CloseCurve(index);
// } }
// strcpy(xinfo.AliasName,"TVD"); strcpy(xinfo.AliasName,"TVD");
// strcpy(xinfo.Name,"TVD"); strcpy(xinfo.Name,"TVD");
// xinfo.CodeLen=sizeof(float); xinfo.CodeLen=sizeof(float);
// xinfo.RepCode=REPR_FLOAT; xinfo.RepCode=REPR_FLOAT;
// index=logio->CreateCurve(&xinfo); index=logio->CreateCurve(&xinfo);
// if(index>-1&&vTVD.size()) { if(index>-1&&vTVD.size()) {
// logio->WriteCurve(index,xinfo.StartDepth,vTVD.size(),(float *)&vTVD[0]); logio->WriteCurve(index,xinfo.StartDepth,vTVD.size(),(float *)&vTVD[0]);
// logio->CloseCurve(index); logio->CloseCurve(index);
// } }
// } }
// delete logio; delete logio;
// Methodlib.unload(); // Methodlib.unload();
// return vTVD.size(); return vTVD.size();
// } }
// void CObjWell::Compute2DTrajectory(float _ProjAngle,double _HorizBoreXE,double _HorizBoreYN,float _HScale,float _VScale) // void CObjWell::Compute2DTrajectory(float _ProjAngle,double _HorizBoreXE,double _HorizBoreYN,float _HScale,float _VScale)
// { // {

View File

@ -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 &GTD0,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 &GTD0,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(DEP0<GLDDDEP) {
GTD=0;
}
else {
GTD=sqrt(pow((DEVI-oldnDevi1[0])/GLDDDEP,2)+
pow((AZIM-oldnAzim1[0]>180?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;
}