|
|
#pragma once
|
|
|
#include "dllExport.h"
|
|
|
#include "XJPoint2D.h"
|
|
|
#include "XJPoint3D.h"
|
|
|
#include "Isopleth.h"
|
|
|
#include "ControlPoint2d.h"
|
|
|
#include "ColorItem.h"
|
|
|
#include "PLineList.h"
|
|
|
#include "FaultPLine.h"
|
|
|
#include "kdtree.hpp"
|
|
|
#include <string>
|
|
|
#include <vector>
|
|
|
#include <limits>
|
|
|
#include <mutex>
|
|
|
#include "RectificationMeshWell.h"
|
|
|
|
|
|
#define FAULT_Z 1
|
|
|
#define INVALID_Z 2
|
|
|
#define FAULT_OPEN 4
|
|
|
#define HIDE_Z 7
|
|
|
#define FIXED_Z 8
|
|
|
|
|
|
|
|
|
|
|
|
struct IntPos
|
|
|
{
|
|
|
IntPos(uint64_t x = 0, uint64_t y = 0)
|
|
|
{
|
|
|
ix = x;
|
|
|
iy = y;
|
|
|
}
|
|
|
uint64_t ix;
|
|
|
uint64_t iy;
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class PeriodicLattice
|
|
|
{
|
|
|
public:
|
|
|
PeriodicLattice();
|
|
|
virtual ~PeriodicLattice();
|
|
|
|
|
|
/***************读取文件*********************/
|
|
|
bool ReadGRD(const std::string& sFileName);
|
|
|
|
|
|
bool ReadKEV(const std::string& sFileName, bool isOffset);
|
|
|
|
|
|
/***************写文件*********************/
|
|
|
bool WriteGRD(const std::string& sFileName);
|
|
|
|
|
|
bool WriteKEV(const std::string& sFileName);
|
|
|
|
|
|
//设置Z值范围
|
|
|
void SetZRange(double zMin, double zMax);
|
|
|
|
|
|
//创建网格
|
|
|
int Create(unsigned int numx, unsigned int numy, double x0, double y0, double dx, double dy, double* values);
|
|
|
|
|
|
//设置颜色模版
|
|
|
void SetColor(const std::vector<ColorItem>& colorList);
|
|
|
|
|
|
//设置等值线
|
|
|
void SetContourList(const std::vector<PlineList>& contourList);
|
|
|
|
|
|
//设置断层线
|
|
|
void SetFaultList(const std::vector<PlineList>& faultList, bool isOffset);
|
|
|
void SetFaultFootwall(const PlineList& footwalls);
|
|
|
|
|
|
//控制点
|
|
|
void SetControlPointList(const std::vector<ControlPoint2d>& pointList);
|
|
|
|
|
|
//边界
|
|
|
void SetBound(const PlineList& bound);
|
|
|
void SetOtherLines(const PlineList& lines);
|
|
|
|
|
|
/********************抬升、下压、涂抹、平滑操作**********************/
|
|
|
void StretchlUp(const Point2D& cen, float rad, float per, int type, float wellrad);
|
|
|
|
|
|
void DuabAway(const Point2D& cen1, const Point2D& cen2, float rad, float per, int type, float wellrad);
|
|
|
|
|
|
void Smooth3x3(const Point2D& cen, float rad, float per, int type, float wellrad);
|
|
|
void Smooth5x5(const Point2D& cen, float rad, float per, int type, float wellrad);
|
|
|
|
|
|
/**
|
|
|
* 检测表达式合法性
|
|
|
*
|
|
|
* \param expression 表达式,exprtk 库支持的格式,https://github.com/ArashPartow/exprtk
|
|
|
*/
|
|
|
bool CompileExpressionZ(const std::string& expressionString);
|
|
|
|
|
|
/**
|
|
|
* 根据表达式计算 z 值
|
|
|
*
|
|
|
* \param expression 表达式,exprtk 库支持的格式,https://github.com/ArashPartow/exprtk
|
|
|
*/
|
|
|
bool CalculateZByExpression(const std::string& expressionString);
|
|
|
|
|
|
//更新等值线
|
|
|
void UpdateIsopleths();
|
|
|
void UpdateIsopleths_MultiThread();
|
|
|
|
|
|
//断层先切割等值线
|
|
|
void CutIsopleths();
|
|
|
|
|
|
//更新控制点
|
|
|
void UpdateWellPoints();
|
|
|
|
|
|
/*****************获取数据************************/
|
|
|
unsigned int GetRawCount() { return static_cast<unsigned int>(m_row); }
|
|
|
|
|
|
unsigned int GetColCount() { return static_cast<unsigned int>(m_col); }
|
|
|
|
|
|
Point2D GetMinPoint() { return m_minPoint; }
|
|
|
|
|
|
Point2D GetMaxPoint() { return m_maxPoint; }
|
|
|
|
|
|
void GetVertexColors(std::vector<float>& colorData);
|
|
|
void GetVertexColors2(std::vector<float>& colorData);
|
|
|
void GetDirtyColorData(unsigned& minX, unsigned& maxX,
|
|
|
unsigned& minY, unsigned& maxY,
|
|
|
std::vector<float>& colors) const;
|
|
|
|
|
|
void GetFaultData(std::vector<std::vector<Point2D>>& faults, std::vector<bool>& vClosed) const;
|
|
|
|
|
|
//断层下盘线
|
|
|
const std::vector<Polyline2d>& GetFaultFootwallData() const;
|
|
|
|
|
|
void GetControlPointData(std::vector<Point3D>& cps, std::vector<std::string>& names);
|
|
|
const std::vector<ControlPoint2d>& GetControlPointData() const;
|
|
|
void ClearWellPointsDirty();
|
|
|
|
|
|
const std::vector<Polyline2d>& GetBoundaryData() const;
|
|
|
const std::vector<Polyline2d>& GetOtherLineData() const;
|
|
|
|
|
|
//获取等值线
|
|
|
void GetDirtyLays(std::vector<unsigned int>& layList) const;
|
|
|
void GetDirtyPlineEdges(unsigned int lay, std::vector<std::vector<Point2D>>& edges);
|
|
|
double GetLayZValue(unsigned int lay);
|
|
|
bool IsLayMarked(unsigned int lay);
|
|
|
void GetContourList(std::vector<PlineList>& contourList);
|
|
|
|
|
|
//获取Z值
|
|
|
double GetZValue(uint64_t idx) const { return m_data[idx]; }
|
|
|
void SetZValue(uint64_t idx, double val) {
|
|
|
m_data[idx] = val;
|
|
|
if (val < m_zMin || val > m_zMax)
|
|
|
m_fault[idx] |= INVALID_Z;
|
|
|
else
|
|
|
m_fault[idx] &= (~INVALID_Z);
|
|
|
}
|
|
|
double* GetValue() { return m_data; }
|
|
|
double GetZMin() const { return m_zMin; }
|
|
|
double GetZMax() const { return m_zMax; }
|
|
|
|
|
|
//undo/redo用
|
|
|
const std::vector<uint64_t>& GetBackupIdxs() { return m_backupIdx; }
|
|
|
const std::vector<double>& GetBackupValues() { return m_backupVal; }
|
|
|
|
|
|
//返回更新包围盒(范围)
|
|
|
const BBox& GetBBox() const { return m_bbox; }
|
|
|
void SetUpdateBBox(const BBox& bbox) { m_bbox = bbox; }
|
|
|
|
|
|
//获取等值线间隔
|
|
|
double GetIsoplethStep() const { return m_isoplethStep; }
|
|
|
//获取上数间隔
|
|
|
int GetMarkIsoplethStep() const { return m_markStep; }
|
|
|
//获取等值线计算范围
|
|
|
double GetMinIsopleth() const { return m_isoplethMin; }
|
|
|
double GetMaxIsopleth() const { return m_isoplethMax; }
|
|
|
|
|
|
void SetIsoplethParameter(double isopStep, int markStep, double minIsop, double maxIsop,
|
|
|
double zMin, double zMax);
|
|
|
void SetIsoplethProperty(double isopStep, int markStep, double minIsop, double maxIsop,
|
|
|
double zMin, double zMax);
|
|
|
|
|
|
//设置无效值颜色
|
|
|
void SetInvalidColor(int r, int g, int b);
|
|
|
|
|
|
//断层Z值往内偏置
|
|
|
void OffsetFault();
|
|
|
void OffsetFault2(bool bFlag = false);
|
|
|
|
|
|
double GetNearPoint(Point2D& pt);
|
|
|
|
|
|
//井点Z值自动匹配
|
|
|
void WellAdaptiveAdjustment(double rad, double range, double miu = 1.0);
|
|
|
|
|
|
//过滤等值线
|
|
|
void FilterIsopleths(int per);
|
|
|
|
|
|
//修改范围多边形
|
|
|
void SetPolygon(const std::vector<Point2D>& poly);
|
|
|
void StretchlUpPolygon(const std::vector<Point2D>& poly, float per, float wellrad, bool state = false);
|
|
|
void SmoothPolygon(const std::vector<Point2D>& poly, float per, float wellrad, bool state = false);
|
|
|
|
|
|
//平滑断层
|
|
|
void TransitFault(const Point2D& cen, const Point2D& cen2, float rad, float per);
|
|
|
|
|
|
// 获取网格行数
|
|
|
int Rows() const;
|
|
|
|
|
|
// 获取网格列数
|
|
|
int Columns() const;
|
|
|
|
|
|
void setDecimalNumber(int num);
|
|
|
int getDecimalNumber();
|
|
|
|
|
|
//断层控制状态 (是否可操作断层区域断层控制点)
|
|
|
void setFaultControlState(bool state) { m_sFaultControl = state; }
|
|
|
bool getFaultControlState() { return m_sFaultControl; }
|
|
|
|
|
|
//井点校正
|
|
|
bool RectificationMeshWellCompute(double deltaz, int type = 0, double factor = 1);
|
|
|
void MeshWellThreadStop();
|
|
|
|
|
|
//井点校正 进度回调
|
|
|
void OnRectificationProgress(int progress);
|
|
|
int GetMeshWellRectificationProgress();
|
|
|
|
|
|
//用于更新井点校正后的数据(多线程需要)
|
|
|
void UpdataMeshWellRectificationView();
|
|
|
|
|
|
private:
|
|
|
bool calZval(const Point2D& pt, double& val);
|
|
|
|
|
|
void calColor(ColorItem& val) const;
|
|
|
|
|
|
void RemoveEdges(const BBox& bb, Isopleth& isopleth);
|
|
|
|
|
|
int getState(float z, uint64_t a, uint64_t b, uint64_t c, uint64_t d);
|
|
|
int getState2(float z, uint64_t a, uint64_t b, uint64_t c, uint64_t d);
|
|
|
|
|
|
void MarchingSquare(const BBox& bb, Isopleth& isopleth);
|
|
|
|
|
|
void addFaultPolyline();
|
|
|
|
|
|
IntPos getStartPos(const Point2D& pt);
|
|
|
|
|
|
float ControlPointWeight(const Point2D& pt, float wellrad);
|
|
|
|
|
|
void UpdateWellPoints(const Point2D& pt, double r);
|
|
|
|
|
|
void UpdateIsopleth(const BBox& bb, Isopleth& isopleth);
|
|
|
|
|
|
double dTruncateToDecimal(double value, int decimal_places = 4);
|
|
|
|
|
|
float fTruncateToDecimal(float value, int decimal_places = 4);
|
|
|
|
|
|
private:
|
|
|
uint64_t m_row; //行数
|
|
|
uint64_t m_col; //列数
|
|
|
|
|
|
int m_decimalNumber; //小数位数
|
|
|
bool m_sFaultControl; //断层控制状态
|
|
|
|
|
|
Point2D m_minPoint; //最小点
|
|
|
Point2D m_maxPoint; //最大点
|
|
|
double m_zMin;
|
|
|
double m_zMax;
|
|
|
double m_stepX; //步长
|
|
|
double m_stepY;
|
|
|
|
|
|
double m_isoplethStep; //等值线间隔
|
|
|
int m_markStep; //标注间隔
|
|
|
double m_isoplethMin; //最小等值线
|
|
|
double m_isoplethMax; //最大等值线
|
|
|
Point3D m_invalidColor; //无效值颜色
|
|
|
bool m_isOffset; //是否内缩断层线
|
|
|
BBox m_bbox; //更新范围
|
|
|
|
|
|
double* m_data; //z值数据
|
|
|
std::vector<ColorItem> m_colorCard; //颜色卡
|
|
|
|
|
|
std::vector<Isopleth> m_isopleths; //等值线
|
|
|
std::vector<FaultPline> m_faultPaths; //断层线
|
|
|
std::vector<uint8_t> m_fault; //断层点
|
|
|
|
|
|
std::vector<ControlPoint2d> m_controlPnts; //控制点
|
|
|
Kdtree::KdNodeVector m_nodes; // 控制点数据
|
|
|
Kdtree::KdTree* m_kdtree; // 井点kdtree
|
|
|
|
|
|
std::vector<Polyline2d> m_boundarys; // 边界
|
|
|
std::vector<Polyline2d> m_footwalls; // 下盘线
|
|
|
std::vector<Polyline2d> m_otherLines; // 其它线
|
|
|
|
|
|
//undo
|
|
|
std::vector<uint64_t> m_backupIdx; //每一次处理备份数据
|
|
|
std::vector<double> m_backupVal;
|
|
|
|
|
|
std::shared_ptr<RectificationMeshWell> m_rectMeshPtr; // 井点校正
|
|
|
int m_progress; // 井点校正进度(可线程安全,实际项目用atomic或mutex保护)
|
|
|
std::mutex m_rectMeshPtrMutex; // 添加互斥锁
|
|
|
};
|
|
|
|
|
|
|