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.
kev/Drawer/SSBase/VoronoiMap/InterfaceElements.h

88 lines
2.0 KiB
C++

#pragma once
#ifndef AFX_EXT_CLASS
#define AFX_EXT_CLASS Q_DECL_IMPORT
#endif
#include <vector>
using std::vector;
/*@file: InterfaceElements.h
* @desc: 用于外部调用的基本元素类型,包括点,井点,线
* @date: 2023.3.11
*/
//元素基类,
class AFX_EXT_CLASS CBaseElement
{
public:
CBaseElement(void):m_strName(_T("") ) {}
virtual ~CBaseElement(void) {}
//设置名称
inline void SetName( CString str) { m_strName = str; }
inline CString GetName (void) const { return m_strName; }
protected:
CString m_strName;
};
//xyz点
class AFX_EXT_CLASS CPointXYZ :public CBaseElement
{
public:
CPointXYZ(void):x0(0.0),y0(0.0),z0(0.0){}
CPointXYZ(double x, double y, double z) { x0 = x; y0 = y; z0 = z; }
virtual ~CPointXYZ() {}
double GetDist2(double x, double y) { return (x - x0)*(x - x0) + (y - y0)*(y - y0); }
double GetDist(double x, double y) { return sqrt(GetDist2(x, y)); }
double x0;
double y0;
double z0;
};
//井点
class AFX_EXT_CLASS CWellPoint :public CPointXYZ
{
public:
CWellPoint(void) :nWellType(0) {}
CWellPoint(double x, double y, double z, int type) { x0 = x; y0 = y; z0 = z; nWellType = type; }
virtual ~CWellPoint() {}
int nWellType; //井类型 缺省-1
};
//线
class AFX_EXT_CLASS CPolyline :public CBaseElement
{
public:
CPolyline(void) {}
virtual ~CPolyline() {}
inline void Clear(void) ;
inline int GetSize(void) const { return static_cast<int>(m_points.size()); }
inline void AddPoint(double x, double y, double z);
inline CPointXYZ& GetPoint(int idx);
std::vector<CPointXYZ>& GetPoints(void) { return m_points; }
bool isClosed(double dDistance = 1e-8); //判断是否闭合
void setClosed(); //设置为闭合
void WriteDfd(FILE* fw);
protected:
std::vector<CPointXYZ> m_points;
};
inline void CPolyline::Clear(void)
{
m_points.clear();
}
inline void CPolyline::AddPoint(double x, double y, double z)
{
m_points.push_back(CPointXYZ(x, y, z));
}
inline CPointXYZ& CPolyline::GetPoint(int idx)
{
ASSERT(idx > -1 && idx < m_points.size());
return m_points[idx];
}