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.

142 lines
4.1 KiB
C++

#pragma once
#include "CommonDefines.h"
#ifdef SINGLE
#define REAL float
#else /* not SINGLE */
#define REAL double
#endif /* not SINGLE */
struct TRIANIO
{
REAL *pointlist; /* In / out */
REAL *pointattributelist; /* In / out */
int *pointmarkerlist; /* In / out */
int numberofpoints; /* In / out */
int numberofpointattributes; /* In / out */
int *trianglelist; /* In / out */
REAL *triangleattributelist; /* In / out */
REAL *trianglearealist; /* In only */
int *neighborlist; /* Out only */
int numberoftriangles; /* In / out */
int numberofcorners; /* In / out */
int numberoftriangleattributes; /* In / out */
int *segmentlist; /* In / out */
int *segmentmarkerlist; /* In / out */
int numberofsegments; /* In / out */
REAL *holelist; /* In / pointer to array copied out */
int numberofholes; /* In / copied out */
REAL *regionlist; /* In / pointer to array copied out */
int numberofregions; /* In / copied out */
int *edgelist; /* Out only */
int *edgemarkerlist; /* Not used with Voronoi diagram; out only */
REAL *normlist; /* Used only with Voronoi diagram; out only */
int numberofedges; /* Out only */
};
#include <afxtempl.h>
struct REAL_POINT
{
int Marker;
REAL rX;
REAL rY;
};
struct AREA_CONTROL
{
REAL Area;
REAL rX;
REAL rY;
};
struct GRID_SEGMENT
{
int iPt0;
int iPt1;
int Marker;
};
struct TRI_RELATION
{
int corner[3];
int neighbor[3];
};
typedef CArray<REAL_POINT, REAL_POINT> REAL_POINT_ARR;
typedef CArray<TRI_RELATION, TRI_RELATION> TRI_RELATIONS;
typedef CArray<GRID_SEGMENT, GRID_SEGMENT> GRID_SEGMENTS;
typedef CArray<AREA_CONTROL, AREA_CONTROL> AREA_CONTROLS;
class CTriAdapter
{
public:
CTriAdapter(void);
virtual ~CTriAdapter(void);
typedef CArray<CPoint, CPoint> CPointArray;
typedef CArray<CPoint2D, CPoint2D> COnePolygon;
typedef CArray<COnePolygon*, COnePolygon*> CPolygons;
public:
void SetGeneralPoints(REAL_POINT_ARR &pts);
int AddOuterPolygon(REAL_POINT_ARR &pts);
BOOL CreateTriangle(LPCTSTR strPara = _T("pzn"));
REAL_POINT_ARR * GetTrianglePoints();
TRI_RELATIONS * GetTriangleRelation();
void ReCalcTriBounderMarker(int iException = INT_MAX);
void Clear();
protected:
void InitOut(TRIANIO *pOut);
BOOL ConvertOutToMyConstruct(TRIANIO *pOut, CPolygons *plGs);
void InitIn(TRIANIO *pIn);
int VerifyOneBounder(int iTri, int iBounder, int iException);
protected:
void Triangulate(char *triswitches, struct TRIANIO *in, struct TRIANIO *out, struct TRIANIO *vorout);
private:
void ClearInnerLineArr();
void ClearInnerPolygonArr();
void ClearOuterPolygonArr();
int GetAllPointCount();
void SetInPoints(TRIANIO *pIn);
int GetAllSegmentCount();
void SetInSegments(TRIANIO *pIn);
void GetCenterPoint(CPoint2D &ptCenter, REAL_POINT pt[3]);
BOOL PtInPolygon(CPoint2D pt, CPolygons *plGs);
int IsPointOccurred(REAL_POINT &pt);
int AddOnePoint(REAL_POINT &pt);
private:
REAL_POINT_ARR m_outPoints;
TRI_RELATIONS m_outTriRelations;
GRID_SEGMENTS m_outSegments;
private:
REAL_POINT_ARR m_WholePoints;
AREA_CONTROLS m_areaCtrls;
int m_iCurMarker;
CPointArray m_genePointArr;
CArray<CPointArray*, CPointArray*> m_InnerLineArrs;
CArray<CPointArray*, CPointArray*> m_InnerPolygonArrs;
CArray<CPointArray*, CPointArray*> m_OuterPolygonArrs;
};