13,824
社区成员
发帖
与我相关
我的任务
分享
#include <math.h>
#include <fstream.h>
//本类用于绘制等值线
const MaxVertices = 500000;
const MaxTriangles = 1000000;
const ExPtTolerance = 0.000001; //小于这个被认为是同一点
typedef int TCastArray[3][3][3];
typedef double TVectorL3D[3];
typedef int TVectorL3I[3];
typedef struct TPointPair
{
double x1,y1, x2,y2;
}PointPair ;
typedef PointPair *PPointPair;
struct TLever //单条等值线
{
double FZ;
TList *Points;
};
struct dVertex //Points (Vertices)
{
double X,Y,Z;
};
struct dTriangle //Created Triangles, vv# are the vertex pointers(点的索引)
{
long vv0,vv1,vv2;
int PreCalc;
double xc,yc,r; //三角形外接圆圆心坐标和半径
};
//################################################################################
//三角形网类定义
class TDelaunay
{
private:
double FzLow,FzHigh;
dVertex *FVertexs ;
dTriangle *FTriangles ;
int FTriangleCount;
int FPointCount; //Variable for total number of points (vertices)
void QuickSort(dVertex *aVertexs,int Low,int High);
int GetPointCount();
bool InCircle(double xp,double yp,double x1,double y1,double x2,double y2,double x3,double y3,double &xc,double &yc,double &r,int j);
int Triangulate(int nVert);
void DoQuickSort(dVertex *aVertexs,int iLo,int iHi); //增加排序函数
double Sec(double a,double b,double c,double d);//增加插值函数
public:
TLever *FLevers;//等值线
TCanvas *canvas;
TDelaunay();
~TDelaunay();
void Mesh();
void DrawTriangles(double lon0,double lat0,float lon1,float lon2,float lat1,float lat2,double zoom);//(lon0,lat0)左上角经、纬度,(lon1,lat1)、(lon2,lat2)画图区域,zoom-放大倍数
void DrawContour(double lon0,double lat0,float lon1,float lon2,float lat1,float lat2,double low,double high,double step,double zoom); //(lon0,lat0)左上角经、纬度,(lon2,lat2)画图区域,low-最低值线,high-最高值线,step-线条间隔,zoom-放大倍数
void ScatterContour(int ZCount,float *Z);
void AddPoint(float x,float y,float z);
void LoadFromMicapsFile4(String file);//file-micaps第4类文件
void LoadFromMicapsFile3(String file);//file-micaps第3类文件
__property double zLow={read=FzLow,write=FzLow};
__property double zHigh={read=FzHigh,write=FzHigh};
__property dVertex *Vertexs={read=FVertexs};
__property dTriangle *Triangles={read=FTriangles};
__property int TriangleCount={read=FTriangleCount};
__property int PointCount={read=GetPointCount};
};
///################################################################################
//================================================================================