|
|
/************************************************************
|
|
|
* @ file Function2D.h 逆断层网格类
|
|
|
* @ version 1.0
|
|
|
* @ date 2011-2012
|
|
|
网格结构:
|
|
|
①在背景网格上构建连接线(CFLineLink),连接线由数据节点(CFPointLink)
|
|
|
指针构成;
|
|
|
②每根垂直连接线都分布在网格线上,包括盘号,起始点(i,j),起始结点指针数组和结点个数等。
|
|
|
在网格平面上,逆断层外部的连接线盘号都为0,逆断层内部为相应盘号。如图
|
|
|
|0
|
|
|
|
|
|
|
----|-|------------- 逆断层 -10
|
|
|
-10 | |10 逆断层
|
|
|
----|-|------------- 逆断层 10
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 0
|
|
|
|
|
|
而正断层不会产生新连接线
|
|
|
|0
|
|
|
|
|
|
|
----|-------------- 正断层10
|
|
|
| 正断层
|
|
|
----|-------------- 正断层10
|
|
|
|
|
|
|
|
|
|
|
|0
|
|
|
************************************************************/
|
|
|
|
|
|
#pragma once
|
|
|
#include "grid.h"
|
|
|
#include ".\plane.h"
|
|
|
#include "ContourCreate.h"
|
|
|
#include "ContourValue.h"
|
|
|
#include <vector>
|
|
|
using namespace std;
|
|
|
|
|
|
namespace NContour
|
|
|
{
|
|
|
class CDimension2D;
|
|
|
class AFX_EXT_CLASS CFunction2D :
|
|
|
public CGrid
|
|
|
{
|
|
|
public:
|
|
|
CFunction2D(void);
|
|
|
~CFunction2D(void);
|
|
|
CString bjSurfacePath;
|
|
|
void SetBJSurfacePath(CString pSurfacePath);
|
|
|
//生成等值线,生成文件
|
|
|
void ContourCreate(CString m_contour, double cmin, double cmax, double step, long markNameStep, CString m_color);
|
|
|
void ContourCreate(CString m_contour, double cmin, double cmax, double step, long markNameStep, CString m_flt, CString m_color);
|
|
|
void ContourCreate(CString m_contour, double cmin, double cmax, double step, long markNameStep, LPCTSTR markLayer, LPCTSTR otherLayer , CString m_color);
|
|
|
void ContourCreate(CString m_contour, double cmin, double cmax, double step, long markNameStep, LPCTSTR markLayer, LPCTSTR otherLayer , CString m_flt, CString m_color);
|
|
|
void ContourCreate(FILE* fw, double cmin, double cmax, double step, long markNameStep, CString m_color);
|
|
|
void ContourCreate(FILE* fw, double cmin, double cmax, double step, long markNameStep, LPCTSTR markLayer, LPCTSTR otherLayer , CString m_color, LPCTSTR lpszDfgFileName);
|
|
|
//内存中生成`
|
|
|
void ContourCreate( POSITION AddContourCurve(CCurve* pCurve, CString strLayer),
|
|
|
double cmin, double cmax, double step, long markNameStep, LPCTSTR markLayer, LPCTSTR otherLayer );
|
|
|
void ContourCreate( POSITION AddContourCurve(CCurve* pCurve, CString strLayer), CContour& cv, LPCTSTR markLayer, LPCTSTR otherLayer );
|
|
|
|
|
|
void ContourCreate(std::vector<CCurve*>* curves, std::vector<CString*>* layers, CContour& cv, CString markLayer, CString otherLayer);
|
|
|
|
|
|
// 得到限定范围的子曲面
|
|
|
CFunction2D* SubFunction2D(int ib, int jb,int it,int jt);
|
|
|
/** @brief 将指定曲线外的点赋空值 */
|
|
|
void NullPtOutside(CCurve* pCurve);
|
|
|
/** @brief 将指定曲线外的点赋空值 */
|
|
|
void NullPtInside(CCurve* pCurve);
|
|
|
|
|
|
/** @brief 对网格结点的z值进行加减乘的运算,0代表+ ,1 为减,2为乘,3为除*/
|
|
|
void ChangeZValue(double cv, int mode);
|
|
|
|
|
|
virtual void Empty(); //清空
|
|
|
virtual int WriteDfg(LPCTSTR m_output);
|
|
|
|
|
|
virtual void Serialize(CArchive& ar, const short& ver);
|
|
|
virtual int Read(CFile& fr); //扩展名为*.fxy
|
|
|
virtual void Write(CFile& fw);
|
|
|
|
|
|
/**@brief 重写基类的Smooth函数*/
|
|
|
virtual void Smooth(double smooth_coef = 1.0 );
|
|
|
|
|
|
int ReadOld(CFile& fr); //扩展名为*.f(x,y)
|
|
|
void WriteOld(CFile& fw);
|
|
|
/** @brief 从Dimension2D对象中读取数据 */
|
|
|
int ReadDimension2D(CDimension2D* dim);
|
|
|
/** @brief 将网格数据写入Dimension2D对象中 */
|
|
|
int WriteDimension2D(CDimension2D* dim);
|
|
|
int Read(LPCTSTR m_input);
|
|
|
int Write(LPCTSTR strOutput);
|
|
|
|
|
|
protected:
|
|
|
int ReadOther(CFile& fr);
|
|
|
void WriteOther(CFile& fw);
|
|
|
|
|
|
std::vector<CCurve*>* m_pCurves = nullptr;
|
|
|
std::vector<CString*>* m_pLayers = nullptr;
|
|
|
|
|
|
public:
|
|
|
void WriteLine(FILE *fw);
|
|
|
void WriteLink(LPCTSTR m_link);
|
|
|
int WriteLine(LPCTSTR m_output);
|
|
|
void WriteDifferential(LPCTSTR m_output,int IsNo,int IsDY);
|
|
|
void WriteDifferential(FILE *fw,int IsNo,int IsDY);
|
|
|
|
|
|
/** @brief 得到z值的范围,返回有效值个数 */
|
|
|
int GetRange(double minValidValue=-1e100, double maxValidValue=1e100);
|
|
|
|
|
|
double Differential(double &x, double &y,int no,int dy);
|
|
|
/** @brief 计算直线与曲面的交点,l为交点处的直线参数值,pre为精度,返回迭代计算的次数*/
|
|
|
int Cross(CLine3D& line, double& l, double pre);
|
|
|
|
|
|
/** @brief 计算线段与曲面的交点坐标, 精确度由pre控制, 若无交点,返回false */
|
|
|
bool Cross(CPoint3D& pt1, CPoint3D& pt2, CPoint3D& csPt, double pre);
|
|
|
/** @brief 计算曲线与曲面的交点坐标, 精确度由pre控制, 若无交点,返回false */
|
|
|
bool Cross(CCurve& curve, CPoint3D& csPt, double pre);
|
|
|
|
|
|
/** @brief 得到曲面上任一点坐标点的z值,由目标点右上角结点处pPoint与周围三点组成的矩形进行插值
|
|
|
B---*-A
|
|
|
| P. |
|
|
|
|___*_| 插值方法为线性插值,AB插值出*1,CD插值出*2,*1*2插值出P
|
|
|
C D
|
|
|
*/
|
|
|
virtual double Value(double x0, double y0);
|
|
|
/** @brief 得到网格结点(i,j)的值,为该结点上所有CPointLink点的平均值*/
|
|
|
virtual double Value(int i, int j);
|
|
|
virtual void SetValue(int i, int j, double v);
|
|
|
|
|
|
/** @brief 得到坐标(x,y)处盘号为no的结点插值得到的值*/
|
|
|
double f(double x, double y, int no);
|
|
|
/** @brief 得到坐标(x,y)处所有Z值,以及对应盘号 存入pValue 和 pNo */
|
|
|
int f(double x, double y, int *pNo, double *pValue);
|
|
|
|
|
|
/** @brief 得到第(i,j)个网格结点处的所有pPoint指针pPointIj和对应CLineX编号__ValueNoIJ */
|
|
|
int GetValueNumber(int i, int j);
|
|
|
void * GetValue(int i, int j,int no);
|
|
|
int GetValue(int i, int j,int *__ValueNoIJ,double *pValue);
|
|
|
double ValueFaultage(double& x, double& y, int no);
|
|
|
int Float(double& rx, double& ry, double& rz);
|
|
|
double GetNo(double x, double y,double z,int &m_No);//返回为垂直距离,“0”为最合理
|
|
|
void GetOther(void);
|
|
|
|
|
|
virtual CGrid* CloneObject(void); //克隆自己
|
|
|
void operator=(CFunction2D& d2d);
|
|
|
|
|
|
public:
|
|
|
/** @brief 结点连接类,包括结点值和与之连接的相邻点指针*/
|
|
|
class AFX_EXT_CLASS CPointLink
|
|
|
{
|
|
|
public:
|
|
|
CPointLink(void);
|
|
|
~CPointLink(void);
|
|
|
|
|
|
int Read (CFile& fr, CFunction2D* pGrid2D);
|
|
|
void Write(CFile& fw, CFunction2D* pGrid2D);
|
|
|
|
|
|
void WriteLink(FILE* fw);
|
|
|
|
|
|
void operator=(CPointLink& pk);
|
|
|
|
|
|
/** @插值得到与距离该结点为(i,j)的点z值 i = 插值点.x - 网格点.x
|
|
|
j = 插值点.y - 网格点.y
|
|
|
*/
|
|
|
int GetValue(double i, double j, double& m_result);
|
|
|
int Differential(double& m_result,int dy);
|
|
|
void SetOther(void);
|
|
|
int IsFlt(void);
|
|
|
|
|
|
public:
|
|
|
/** @brief 四个方向上与该PointLink相连的指针,顺序为
|
|
|
|1
|
|
|
2--+--0
|
|
|
|3
|
|
|
*/
|
|
|
CPointLink** m_pLink;
|
|
|
double value;
|
|
|
char IsOther;
|
|
|
char nCount; ///< 记录该结点是否被追踪过
|
|
|
};
|
|
|
|
|
|
/* @brief 单条垂直网格线*/
|
|
|
class AFX_EXT_CLASS CLineX
|
|
|
{
|
|
|
public:
|
|
|
CLineX(void);
|
|
|
~CLineX(void);
|
|
|
|
|
|
int Read (CFile& fr, CFunction2D* pGrid2D);
|
|
|
void Write(CFile& fw, CFunction2D* pGrid2D);
|
|
|
|
|
|
///< 得到该纵向第j个网格点在此条CLineX上的指针
|
|
|
void *GetValue(int j);
|
|
|
void operator=(CLineX& lx);
|
|
|
|
|
|
public:
|
|
|
short nCount; ///< 列中网格点数目
|
|
|
CPointLink* pPoint; ///< 网格结点数组
|
|
|
short j0; ///< 第一个点所处的网格点在该网格列的序号,比如i方向3 j方向5,j0为5
|
|
|
short No; ///< 盘号
|
|
|
};
|
|
|
|
|
|
/* @brief 网格线组(垂直)类
|
|
|
|
|
|
|
|
|
|
|
| CLineX1
|
|
|
|
|
|
|
|
|
|
| CLineX2
|
|
|
|
|
|
|
CLine
|
|
|
*/
|
|
|
class AFX_EXT_CLASS CLine
|
|
|
{
|
|
|
public:
|
|
|
CLine(void);
|
|
|
~CLine(void);
|
|
|
|
|
|
int Read (CFile& fr, CFunction2D* pGrid2D);
|
|
|
void Write(CFile& fw, CFunction2D* pGrid2D);
|
|
|
|
|
|
void operator=(CLine& line);
|
|
|
|
|
|
public:
|
|
|
CLineX *pX;
|
|
|
_int32 nCount;
|
|
|
};
|
|
|
|
|
|
public:
|
|
|
int GetFaultageNo(int i, int j, CPointLink* pPl);
|
|
|
int GetFaultageNo(CPointLink* pPl);
|
|
|
|
|
|
public:
|
|
|
CPoint2D _ContourIJ,_LastContourIJ;
|
|
|
CPoint2D _ContourXY;
|
|
|
char _ContourDirect;
|
|
|
double _ContourValue,t;
|
|
|
CList<CPoint2D,CPoint2D>_ContourXyList; ///< 临时存放当前等值线上的点
|
|
|
|
|
|
CLine* pLine; ///< 网格列数组
|
|
|
CPointLink* pPoint; ///< 单个结点指针
|
|
|
_int32 total; ///< 所有结点的数目
|
|
|
|
|
|
char IsTail;
|
|
|
CPointLink** pPointIJ; ///< 临时变量,记录(i,j)网格点对应的所有pPoint结点指针
|
|
|
int * __ValueNoIJ; ///< 临时变量,记录(i,j)网格点覆盖的所有ClineX的No
|
|
|
CMap<int,int,void *,void *> CurveMap;
|
|
|
|
|
|
protected:
|
|
|
void ContourPointLink(CPointLink *&pPl);
|
|
|
double ContourPointLink(CPointLink* pLink, char m_direct);
|
|
|
void Contour(double cv);
|
|
|
void ContourWrite(void);
|
|
|
int ContourTrim(int IsTail,int fn);
|
|
|
//void Contour(double cmin, double cmax, double step, long markNameStep);
|
|
|
void Contour(CContour& cv);
|
|
|
|
|
|
CContourCreate m_contourCreate;
|
|
|
};
|
|
|
|
|
|
|
|
|
}//namespace
|
|
|
|
|
|
|