113 lines
3.8 KiB
C
113 lines
3.8 KiB
C
|
#pragma once
|
|||
|
#include "ClosedFinder_Data.h"
|
|||
|
|
|||
|
struct ltstr
|
|||
|
{
|
|||
|
bool operator()(const char* s1, const char* s2) const
|
|||
|
{
|
|||
|
return strcmp(s1, s2) < 0;
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
class ClosedFinder
|
|||
|
{
|
|||
|
public:
|
|||
|
ClosedFinder(void);
|
|||
|
virtual ~ClosedFinder(void);
|
|||
|
|
|||
|
public: // tool
|
|||
|
//获取边的端点
|
|||
|
static bool getArcHalfEdgeBeginEnd(const std::list<sArcHalfEdge>& lstEdge, const sPoint* & ptFist, const sPoint* & ptEnd);
|
|||
|
|
|||
|
public: //set data
|
|||
|
bool addPoint(Point_Key key, sPoint* pPoint, bool bCheck = true); //输入点
|
|||
|
bool addArc (Arc_Key key , sArc* pArc , bool bCheck = true); //输入弧线
|
|||
|
|
|||
|
public: //get data
|
|||
|
//
|
|||
|
const std::map<Point_Key, sPoint*>& getPoints()const {return mPointsSrc;}
|
|||
|
const std::map<Arc_Key , sArc* >& getArcs ()const {return mArcsSrc;}
|
|||
|
//
|
|||
|
std::map<Point_Key, sPoint*>& getPoints(){return mPointsSrc;}
|
|||
|
std::map<Arc_Key , sArc* >& getArcs () {return mArcsSrc;}
|
|||
|
|
|||
|
public: //result
|
|||
|
const std::map<Polygon_Key, sPolygon >& getPolygons ()const {return mPolygons;}
|
|||
|
const std::map<Polygon_Key, std::list<std::pair<Arc_Key/*原始的线*/, std::list<sArcHalfEdge> > > >& getPolygonsCombin ()const {return mPolygonsCombin;}
|
|||
|
|
|||
|
public: //interface
|
|||
|
//生成多边形,返回值为多边形的个数
|
|||
|
int GeneralPolygon(void);
|
|||
|
|
|||
|
private:
|
|||
|
//搜索多边形,找到返回true
|
|||
|
bool __GeneralPolygon(sPolygon polygon, std::map<Arc_Key, sArcHalfEdge>& linkDatas );
|
|||
|
//搜索多边形, 返回多边形边数,没有 返回-1
|
|||
|
int SearchGeneralPolygon(sPolygon polygon, std::map<Arc_Key, sArcHalfEdge>& linkDatas );
|
|||
|
//获取多边形的最大边数
|
|||
|
int GetMaxEdgeSet();
|
|||
|
|
|||
|
private:
|
|||
|
//多边形整合
|
|||
|
bool __CombinPolygon();
|
|||
|
//删除外边框的多边形
|
|||
|
bool ClearMaxEdgePolygon();
|
|||
|
//判断多边形是否包含
|
|||
|
bool IsIncludeClosedPolygon(vector<Point_Key>& keySet1, vector<Point_Key> keySet2);
|
|||
|
|
|||
|
//添加一条边
|
|||
|
void AddEdge( sPolygon &polygonCur, const sArcHalfEdge& halEdgeT );
|
|||
|
//
|
|||
|
//添加找到的多边形
|
|||
|
bool _AddPolygon(sPolygon &polygonCur) ;
|
|||
|
//缓存所有两变形面
|
|||
|
void _PostPolygon2edge(const sPolygon &polygonCur );
|
|||
|
|
|||
|
//
|
|||
|
//判断是否为孤岛
|
|||
|
void PostIsland( sPolygon &polygonCur, sArcHalfEdge& halfEdge ) ;
|
|||
|
//
|
|||
|
//得到一个多边形的最大查询次数
|
|||
|
TimeofSearch _GetMaxTimeOfSearch( sPolygon &polygonCur) ;
|
|||
|
|
|||
|
private:
|
|||
|
//多边形是否已经存在
|
|||
|
bool ExistPolygon(const sPolygon &polygonCur);
|
|||
|
|
|||
|
private:
|
|||
|
//添加一个半边数据
|
|||
|
void AddHaldEdge(const sArcHalfEdge &halfEdge ) ;
|
|||
|
|
|||
|
//对连接到一点的所有线段按照已经被搜索的次数排序
|
|||
|
//结果存储在tmapHalfEdgebyTime中
|
|||
|
std::multimap<TimeofSearch, sArcHalfEdge*> SortPointLinkEdge( std::map<Arc_Key, sArcHalfEdge> &linkDatas);
|
|||
|
|
|||
|
private: //in
|
|||
|
std::map<Point_Key, sPoint*> mPointsSrc ; //原始的点数据
|
|||
|
std::map<Arc_Key , sArc* > mArcsSrc ; //原始的点数据
|
|||
|
|
|||
|
std::map<Point_Key, std::map<Arc_Key, sArcHalfEdge> > mPointLinkData; //过点的所有弧线段
|
|||
|
|
|||
|
private: //out
|
|||
|
//
|
|||
|
Polygon_Key mCurPolygon_Key;//当前多边形的id
|
|||
|
std::map<Polygon_Key, sPolygon > mPolygons; //输出的多边形
|
|||
|
private:
|
|||
|
std::map<Polygon_Key, std::list<std::pair<Arc_Key, std::list<sArcHalfEdge> > > > mPolygonsCombin;//合并的多边形
|
|||
|
|
|||
|
private:
|
|||
|
//tmapHalfEdgebyTime; //按照已经被引用过的次数排序
|
|||
|
int tCurMaxSize; //当前搜索多边形的边数
|
|||
|
std::map<Point_Key, Point_Key> tmapGen; //已经被生成过的点,
|
|||
|
//
|
|||
|
std::map<T_MARK_TYPE, Polygon_Key> tmapExistPolygon; //已经被生成过的多边形,
|
|||
|
|
|||
|
private: //2边形的特殊处理
|
|||
|
std::map<Arc_Key, std::map<Arc_Key, sArcHalfEdge> > mmapLinkArcs; //弧段所属的等同段
|
|||
|
//
|
|||
|
std::map<CompositeKey, std::map<Point_Key, std::map<Arc_Key, sArcHalfEdge> > > mmapLinkArcs2; //弧段所属的等同段
|
|||
|
|
|||
|
public:
|
|||
|
std::vector<int> border; // 边界 多边形的边不能都在该边界中
|
|||
|
};
|