logplus/common/geometryutils.h

438 lines
14 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef GEOMETRYUTILS_H
#define GEOMETRYUTILS_H
#include <QString>
#include <QStatusBar>
#include <QComboBox>
//#include <osg/Vec3f>
#include <QUuid>
#include <QDir>
#include<cmath>
#pragma execution_character_set("utf-8")
#define PAITOTALCOLOR_MIN 2 // 最小总颜色数目
#define PAITOTALCOLOR_MAX 65 // 最大总颜色数目
#define SECTIONVIEW_NUM 255
#define SYSTEM_INPOLATION 65 // 系统缺省颜色需要插值成的数目
struct My_ColorItem
{
QRgb color; // 颜色值
float fromValue; // 对应的振幅开始值
float toValue; // 对应的振幅的结束值
char strComments[64]; // 描述信息
};
class MyColorItem
{
public:
MyColorItem()
{
color=QColor(0,0,0);
fromValue=toValue=0;
strComments="";
}
MyColorItem(const QColor &color,float value=0)
{
this->color=color;
this->fromValue=this->toValue=value;
strComments="";
}
MyColorItem(const MyColorItem &other)
{
color=other.color;
fromValue=other.fromValue;
toValue=other.toValue;
strComments=other.strComments;
}
MyColorItem & operator=(const MyColorItem &other)
{
color=other.color;
fromValue=other.fromValue;
toValue=other.toValue;
strComments=other.strComments;
return *this;
}
QColor color; // 颜色值
float fromValue; // 对应的振幅开始值
float toValue; // 对应的振幅的结束值
QString strComments; // 描述信息
};
/**
* @class SchemeColor
* @brief 描述一种颜色方案
*/
struct Scheme_Color
{
char schemeName[64];
int size;
struct My_ColorItem colorList[256];
bool isDirty;
bool isCustom;
int currentIndex; // 当前编辑的位置
};
class SchemeColor
{
public:
SchemeColor()
{
schemeName="";
colorList.clear();
isDirty=isCustom=false;
currentIndex=0;
}
SchemeColor(const SchemeColor &other)
{
schemeName=other.schemeName;
colorList=other.colorList;
isDirty=other.isDirty;
isCustom=other.isCustom;
currentIndex=other.currentIndex;
}
SchemeColor & operator=(const SchemeColor &other)
{
schemeName=other.schemeName;
colorList=other.colorList;
isDirty=other.isDirty;
isCustom=other.isCustom;
currentIndex=other.currentIndex;
return *this;
}
QString schemeName;
QVector<MyColorItem> colorList;
bool isDirty;
bool isCustom;
int currentIndex; // 当前编辑的位置
};
//const double PI = osg::PI;
const double PI = 3.14159265358979323846;
struct LayerInfo
{
QString name;
float top;
float bottom;
float rlev;
int shape;
QUuid m_DataSourceX;
QUuid m_DataSourceY;
QUuid m_DataSourceZ;
std::vector<float> m_vXData;
std::vector<float> m_vYData;
std::vector<float> m_vZData;
public:
void SetDataSourceX(QUuid id)
{
m_DataSourceX = id;
}
void SetDataSourceY(QUuid id)
{
m_DataSourceY = id;
}
void SetDataSourceZ(QUuid id)
{
m_DataSourceZ = id;
}
QUuid GetDataSourceX()
{
return m_DataSourceX;
}
QUuid GetDataSourceY()
{
return m_DataSourceY;
}
QUuid GetDataSourceZ()
{
return m_DataSourceZ;
}
};
QString GetProjectFolder();
QString GetLogdataPath();
void GetWellNameAndPath(QString slf,QString &wellname,QString &path);
int chakan(QString path, QStringList &wellfs, QString strSuffix);
QString GetOilFieldName(QString c=QDir::separator());
QString ReadOilFieldName();
QString GetLogPlusPath();
QMap<QString,QString> GetZoneOrder(QString table,bool isOilFile=true,QWidget *pW=NULL);
QMap<QString,QString> GetZoneOrder(bool isOilFile=true,QWidget *pW=NULL);
bool IsInvalidString(QString filename);
bool IsValidWellName(QString wellname);
QString toString(QString cs);
QString toString(int value,char f='f',int dem=3,bool iscut=1,bool ise=true);
QString toString(float value,char f='f',int dem=3,bool iscut=1,bool ise=true);
QString toString(double value,char f='f',int dem=3,bool iscut=1,bool ise=true);
QString setdec(QString text,int dec=2,bool all=false);
QStringList GetSimilarCurves(QString curvename,char *INI=NULL,bool isEQU=true);
QString GetImagePath();
QString GetOutDataPath();
QString GetDate(time_t mDate);
QString GetConfPath();
bool RenameWellName(QString filename, QString strNewName);
void ComboxFromConfigFile( QComboBox *aCombox ,QString configCategory);
QStatusBar * GetStatusBar();
QString GetDataPath();
QString DoubleToString(double dValue, int nDecimal,int *pReallyDecimal);
void SetSystemExisting(bool exiting);
bool SystemExiting();
bool getAllSlf(QString prjname, QVector<QString> &vecSlfList, QVector<QString> &vecWellList);//直方图获取当前工程下的slf
bool getAliasNameFromIni(QString CurveName, QString &strAliasName, QString &strUnit);//曲线别名,单位
/**
* @brief 获取系统缺省的系统颜色
* @param nIndex 系统颜色序号
* @param colorList 返回颜色列表
* @param 当前颜色方案使用的总颜色数目
*/
int getSystemColor(int nIndex,QVector<MyColorItem> &colorList,bool inpolation);
int getSystemColorNumber(QStringList &names);
/**
* @brief 将制定的颜色表插值成指定的颜色
* @param colorList 控制颜色表
* @param 当掐颜色方案使用的总颜色数目
* @return 返回插值以后的颜色
*/
QVector<MyColorItem> myInpolation(const QVector<MyColorItem> &colorList,int totalColorNum);
// 读取定制的颜色方案
void ReadColorSettings(QList<SchemeColor> &shcemeLis);
struct WellHead
{
WellHead()
{
rlev=0.125; //深度采样间隔
x=0,y=0,z=0; //井口坐标
dxe=0,dyn=0; //xy偏移
tvd=0; //井口垂直高度
depth=0; //测量深度
earthEle=0; //地面海拔
dEle=0; // 补心高
azca=0; // 闭合方位,磁偏角
m_ShowWellHead=true; //是否显示井
m_ShowLabel=true; //是否显示井标注
strWellType="";//1表示采油井、2 注水井、产水井、气井、干井、报废井、设计井
WellID=0; //井的内置ID号
wellName=""; //井名
startDepth=0; //起始深度
endDepth=0; //终止深度
_ProjAngle=0;
_HorizBoreXE=0;
_HorizBoreYN=0;
_EndXE=0;
_EndYN=0;//
maxz=-9999999;
minz=9999999;
};
~WellHead()
{
};
bool m_ShowWellHead; //是否显示井头
bool m_ShowLabel; //是否显示井标注
bool m_bShowCurve; //是否显示测井曲线
bool m_bShow; //是否显示井
//========================================================
QColor lableColor; //是否显示井标注
//========================================================
public:
QString strWellType;//1表示采油井、2 注水井、产水井、气井、干井、报废井、设计井
int WellID; //井的内置ID号
QString wellName; //井名
float startDepth; //起始深度
float endDepth; //终止深度
float rlev; //深度采样间隔
double x,y,z; //井口坐标
float dxe,dyn; //xy偏移
float tvd; //井口垂直高度
float depth; //测量深度
float earthEle ; //地面海拔
float dEle; // 补心高
float azca; // 闭合方位,磁偏角
float _ProjAngle;
double _HorizBoreXE;
double _HorizBoreYN;
double _EndXE, _EndYN;//
float maxz;
float minz;
QString path;
void Serializable(QDataStream& ds)
{
if(ds.device()->isWritable())
{
ds<<m_ShowWellHead; //是否显示井头
ds<<m_ShowLabel; //是否显示井标注
ds<<lableColor; //是否显示井标注
ds<<strWellType;//1表示采油井、2 注水井、产水井、气井、干井、报废井、设计井
ds<<WellID; //井的内置ID号
ds<<wellName; //井名
ds<<path;
ds<<startDepth; //起始深度
ds<<endDepth; //终止深度
ds<<rlev; //深度采样间隔
ds<<x<<y<<z; //井口坐标
ds<<dxe,dyn; //xy偏移
ds<<tvd; //井口垂直高度
ds<<depth; //测量深度
ds<<earthEle; //地面海拔
ds<<dEle; // 补心高
ds<<azca; // 闭合方位,磁偏角
}
else
{
ds>>m_ShowWellHead; //是否显示井头
ds>>m_ShowLabel; //是否显示井标注
ds>>lableColor; //是否显示井标注
ds>>strWellType;//1表示采油井、2 注水井、产水井、气井、干井、报废井、设计井
ds>>WellID; //井的内置ID号
ds>>wellName; //井名
ds>>path;
ds>>startDepth; //起始深度
ds>>endDepth; //终止深度
ds>>rlev; //深度采样间隔
ds>>x>>y>>z; //井口坐标
ds>>dxe,dyn; //xy偏移
ds>>tvd; //井口垂直高度
ds>>depth; //测量深度
ds>>earthEle; //地面海拔
ds>>dEle; // 补心高
ds>>azca; // 闭合方位,磁偏角
}
}
void Method(float DEVI,float AZIM,float &AZCA,float &RLEA,float &AZA0,int &FLAG,float &DEV1,float &AZIM1,float &DEV2,float &AZIM2,float &FLSA,float &XE,float &YN,float &DZDA,float &ZD,float &TVDS,float &HOFF,float &HOAZ)
{
float 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;
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) ;
label_11 :
;
}
};
#endif // GEOMETRYUTILS_H