You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

394 lines
7.9 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#ifndef LIBRARY_VTKINTERFACE_H
#define LIBRARY_VTKINTERFACE_H
#include <list>
#include <map>
#include <memory>
#pragma region KevVtkDataDefine
/**
* @brief 数据类型.
*/
enum KevVtkDataType
{
UnknowDataType,
MeshDataType,
PointDataType,
CurveDataType,
ImageDataType,
WellDataType, //井数据
FaultMeshType, //断层数据
MeshMaskType, //网格图像遮罩
};
/**
* @brief 曲线类型.
*/
enum KevVtkCurveType
{
UnknowCurveType,
Fault,//断层
Boundary,//边界
WorkArea,//工区
MiniRight,//矿权
Contour,//等值线
};
/**
* @brief 选择模式.
*/
enum KevVtkSelectMode
{
RectangleMode,//矩形
CircleMode,//圆形
};
/**
* @brief 曲线类型.
*/
enum KevVtkPropertyID
{
UnknowID = 0,
ActorAmbientColor,
ActorDiffusedColor,
ActorSpecularColor,
ActorAmbient,
ActorDiffused,
ActorSpecular,
};
/**
* @brief 井类型.
*/
enum KevVtkWellType
{
UnknowWellType,
oil,
gas,
water,
};
/**
* @brief 井数据.
*/
class KevVtkPointData
{
public:
KevVtkWellType m_wellType;
std::string m_name;
std::string m_layerName;
double m_x;
double m_y;
double m_z;
};
/**
* @brief 曲线数据.
*/
class KevVtkCurveData
{
public:
std::string m_name;
std::string m_layerName;
double* x;
double* y;
double* z;
double* l;
long m_nPoint;
long m_num;
bool isClosed;//是否闭合
};
/**
* @brief 颜色对象.
*/
class KevVtkColorItem
{
public:
double z;
unsigned char color[4];
bool gradient;
};
/**
* @brief 网格数据.
*/
class KevVtkMeshData
{
public:
KevVtkMeshData()
{
shadow_u = nullptr;
}
~KevVtkMeshData()
{
if (shadow_u != nullptr)
{
delete[]shadow_u;
shadow_u = nullptr;
}
for (auto it = m_colorList.begin(); it != m_colorList.end(); ++it)
{
KevVtkColorItem* ptr = static_cast<KevVtkColorItem*>(*it); // 将 void* 转换为实际类型
delete ptr; // 释放内存
*it = nullptr; // 将指针置为 nullptr
}
m_colorList.clear(); // 清空列表
}
public:
double m_zMin;
double m_zMax;
double *origin_u;
double *shadow_u;
long n; ///< n表示维数曲面为2体网格为3
long *num; ///< 各方向网络个数
long numX; //X方向数据个数
long numY; //X方向数据个数
double x0;
double y0;
double dx;
double dy;
double *P0; ///< 原点坐标
double *delt; ///< 间隔
double *range; ///< z值范围范围外的值认为无效
std::string m_layerName;
std::list<void*> m_colorList;
int64_t id{ -1 };
};
/**
* @brief 网格数据.
*/
class KepVtkMeshData
{
public:
KepVtkMeshData()
{
n = 2;
u = nullptr;
}
~KepVtkMeshData()
{
if (u != nullptr)
{
delete[] u;
u = nullptr;
}
for (auto it = m_colorList.begin(); it != m_colorList.end(); ++it)
{
KevVtkColorItem* ptr = static_cast<KevVtkColorItem*>(*it); // 将 void* 转换为实际类型
delete ptr; // 释放内存
*it = nullptr; // 将指针置为 nullptr
}
m_colorList.clear(); // 清空列表
}
public:
double x0;
double y0;
double dx;
double dy;
long numX; //X方向数据个数
long numY; //X方向数据个数
double m_zMin;
double m_zMax;
long n; ///< n表示维数曲面为2体网格为3
long num[2]; ///< 各方向网络个数
double P0[2]; ///< 原点坐标
double delt[2]; ///< 间隔
double range[2]; ///< z值范围范围外的值认为无效
double* u; ///< 网格Z数据
std::string m_layerName;
std::list<void*> m_colorList;
};
/**
* @brief 图像数据.
*/
class KevVtkImageData
{
public:
double m_x;
double m_y;
double m_width;
double m_height;
std::string m_fileName;
std::string m_layerName;
};
/**
* @brief 三维参数.
*/
class KevVtkSceneParameter
{
public:
~KevVtkSceneParameter()
{
}
//general
bool m_showAxies;
bool m_showScalarBar;
bool m_showMeshLinearExtrusion;
bool m_ShowCoordinateGridLine;
bool m_ShowMeshEdgeColorGradient;
int m_zScale;
//background
double m_background_color_r;
double m_background_color_g;
double m_background_color_b;
//camera
double m_camera_distance;
double m_camera_position_x;
double m_camera_position_y;
double m_camera_position_z;
double m_camera_focalPoint_x;
double m_camera_focalPoint_y;
double m_camera_focalPoint_z;
double m_camera_viewUp_x;
double m_camera_viewUp_y;
double m_camera_viewUp_z;
double m_camera_azimuth;
double m_camera_elevation;
double m_camera_roll;
double m_camera_viewAngle;
double m_camera_clippingRange_0;
double m_camera_clippingRange_1;
//actor
double m_actor_ambientColor_r;
double m_actor_ambientColor_g;
double m_actor_ambientColor_b;
double m_actor_diffuseColor_r;
double m_actor_diffuseColor_g;
double m_actor_diffuseColor_b;
double m_actor_specularColor_r;
double m_actor_specularColor_g;
double m_actor_specularColor_b;
double m_actor_ambient;
double m_actor_diffuse;
double m_actor_specular;
//light
int m_light_mode;
double m_light_intensity;
double m_light_color_r;
double m_light_color_g;
double m_light_color_b;
double m_light_ambientColor_r;
double m_light_ambientColor_g;
double m_light_ambientColor_b;
double m_light_diffuseColor_r;
double m_light_diffuseColor_g;
double m_light_diffuseColor_b;
double m_light_specularColor_r;
double m_light_specularColor_g;
double m_light_specularColor_b;
double m_light_position_x;
double m_light_position_y;
double m_light_position_z;
double m_light_focalPoint_x;
double m_light_focalPoint_y;
double m_light_focalPoint_z;
double m_light_azimuth;
double m_light_elevation;
//vtk mesh edge color
double m_mesh_edge_color_r;
double m_mesh_edge_color_g;
double m_mesh_edge_color_b;
int32_t m_mesh_edge_mode = 0;
//面角过滤
bool m_singularValueFilterFlag = false;
int32_t m_singularThreshold = 65;
// 垂直比例
double m_zMaxScale = 100.0;
// 业务参数
int32_t m_thickness = 100;
/**** 井显示参数 ***/
int32_t m_wellMode = 0; // 显示模式
double m_wellColumnHeight = 100.0; // 井柱高亮
double m_wellColumnRadius = 10; // 井住半径
uint32_t m_wellColumnColor = 0xffffffff; // 井柱颜色
uint32_t m_wellColumnNameColor = 0xffffffff; // 井名颜色
int32_t m_wellColumnNameSize = 15; // 井名大小
int32_t m_wellColumnNameGap = 10; // 井名间距
int32_t m_faultModeEnum = 0; // 井显示模式
int32_t m_wellSymbalRadius{25}; //井头半径
bool m_wellColumnThrough{false};
std::string m_wellTypeColors; // 井别颜色,为了 C++ 结构体能够直接映射到 C# 结构体,这里使用了 BSTR 这个指针类型,使用 CString 无法做到这一点
};
/**
* @BRIEF@END.vtk图层树节点
* 每个节点可能包括网格、点、线、图像数据
* 节点下可能有字节点
* 每个节点可能是选中或非选中状态
* 每个节点对应二维图的图层节点
*/
class KevVtkDataNode
{
public:
bool m_checked;
bool m_hide;
bool m_bCreateVtkObject;
bool m_bWellLayer;
bool m_bFaultLayer;
bool m_bBorderLayer;
std::string m_layerName;
KevVtkSceneParameter* m_sceneParameter;
//data
std::list<KevVtkPointData*> m_pointList;//点数据
std::list<KevVtkCurveData*> m_curveList;//线数据
std::list<KevVtkCurveData*> m_closedFaultVtkCurveList;//双线断层曲线
std::list<KevVtkCurveData*> m_closedBoundaryVtkCurveList;//边界线曲线
std::list<KevVtkCurveData*> m_singleFaultVtkCurveList;//单线断层曲线
std::list<void*> m_closedFaultCCurveList;//闭合断层线pCurve指针列表
std::list<void*> m_closedBoundaryList;//闭合边界线pCurve指针列表
std::list<KevVtkMeshData*> m_meshList;//网格数据
std::list<KevVtkImageData*> m_imageList;//图像数据
std::list<KevVtkDataNode*> m_childList;//子数据节点列表
//actor
std::list<void*> m_meshActor;//网格
std::list<void*> m_linearExtrusionActorList;//裙边
std::list<void*> m_linearExtrusionPlaneActorList;//水平裙边
std::list<void*> m_AxesActorsList;//坐标框
std::list<void*> m_pointActorList;//井圈符号
std::list<void*> m_textActorList;//井名文字
std::list<void*> m_curveActorList;//曲线
std::list<void*> m_imageActorList;//图像
public:
KevVtkDataNode();
};
class VtkWellCurveVertex
{
public:
double m_x;
double m_y;
double m_z;
double m_depth;
int m_type;//井轨迹节点,测井曲线节点
int m_dataState;
std::string m_layerName;
std::map<std::string, double> m_loggingData;
};
//class VtkWellData
//{
//public:
// std::string wellId;
// std::string wellName;
// std::list<VtkWellCurveVertex*> vertexList;
// std::map<std::string, std::string> m_loggingName;
//};
#pragma endregion
#endif // !LIBRARY_KEVVTKDATA_H