|
|
#pragma once
|
|
|
/*@class: CSimpleGrid
|
|
|
* @desc: 数据网格类,每个网格单元中存有数据
|
|
|
*/
|
|
|
#include <vector>
|
|
|
#include <list>
|
|
|
#include <afxext.h>
|
|
|
#include "VoronoiMap/InterfaceElements.h"
|
|
|
|
|
|
using std::vector;
|
|
|
class CSimpleGrid
|
|
|
{
|
|
|
public:
|
|
|
CSimpleGrid(void);
|
|
|
virtual ~CSimpleGrid(void);
|
|
|
void Clear(void);
|
|
|
void Create(double x0, double y0, double dx, double dy, int xnum, int ynum);
|
|
|
int xnum(void) { return m_numx; }
|
|
|
int ynum(void) { return m_numy; }
|
|
|
double X(int i);
|
|
|
double Y(int j);
|
|
|
|
|
|
//写出网格线
|
|
|
void WriteGridLines(CString strout);
|
|
|
|
|
|
void ReadPoints(const vector< CPointXYZ>& pts);
|
|
|
//抽稀所有格子相关点,每个格子最多保留1-2个点(点之间距离不小于网格步长),
|
|
|
void SimplifyNodePointsArray();
|
|
|
//抽稀种子格子(保留距左下角最近的点p1, 和距离P1距离大于步长的点P2(如果有)
|
|
|
void SimplifySeedGrid(int ix, int iy);
|
|
|
//抽稀种子格子相邻的格子(ix,iy)为目标格子序号
|
|
|
void SimplifyNeighborGrid(int seedX, int seedY, int ix, int iy);
|
|
|
void GetAllNodePointIndexes(std::list<int>& ptIndexes); // 获取所有相关点序号
|
|
|
protected:
|
|
|
int GetNodeIndex(int ix, int iy); //获取ix,iy对应的数据序号
|
|
|
vector<int>& GetNodePointsVec(int ix, int iy); // ix, iy对应的相关点集
|
|
|
//查找距离(x0,y0)最近的点,返回序号,距离distance
|
|
|
int GetNearestPoint(double x0, double y0, vector<int>& pts, double* distance = nullptr);
|
|
|
//查找距离(x0,y0)最远的点,返回序号,和距离distance
|
|
|
int GetFarthestPoint(double x0, double y0, vector<int>& pts, double* distance = nullptr);
|
|
|
|
|
|
int m_numx; //列数
|
|
|
int m_numy; //行数
|
|
|
double m_x0; //起点x0
|
|
|
double m_y0; //起点y0
|
|
|
double m_dx; //x步长
|
|
|
double m_dy; //y步长
|
|
|
double m_deltS;
|
|
|
vector<CPointXYZ> m_points;
|
|
|
vector<int>* m_nodePointsArray; //隶属于各个节点的散点 m_nodePoints[0]= 第一个格子里的散点序号
|
|
|
|
|
|
};
|
|
|
|