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/PolygonTreeInterface.h

69 lines
1.5 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma once
#ifndef AFX_EXT_CLASS
#define AFX_EXT_CLASS Q_DECL_IMPORT
#endif
#include <vector>
#include <set>
#include "InterfaceElements.h"
#include "GObjects/mycurve.h"
#include "GObjects/Con2Pgn.h"
using std::vector;
using std::set;
//using namespace GObjects;
/*@file: PolygonTree.h
* @desc: 用于生成多边形之间包含关系树状图,此接口用于opencv逐步追踪过的轮廓线
* @date: 2023.3.11
*/
//多边形层级关系表 vector<int>中有四个元素 表示 0、下一个条1、前一条2、孩子 3、父亲
using MyHierarchy = vector< vector<int> >;
//class GObjects::CMyCurve;
//class GObjects::CPolygonTree;
class AFX_EXT_CLASS CPolygonTreeInterface
{
public:
CPolygonTreeInterface(void);
~CPolygonTreeInterface(void);
//vector<CPolyline*>& GetPolygons(void);
//MyHierarchy& GetHierarchy(void);
void Create(float filterArea = -1);
void AddPolygon(CPolyline* pc);
void SetPolygons(vector<CPolyline*>& pgns);
//设置层级关系
void SetHierarchy(MyHierarchy& hier);
//清空 m_polygons 和m_hierarchy
void Clear(void);
vector<CPolyline*>& GetResultPolygons(void);
//将所有结果曲线合并成一条
CPolyline* CombineResultContoursToOne(void);
protected:
//由层级关系生成,返回个数
int CreateWithHierarchy(float filterArea);
//m_pgnTree中所有结果轮廓线合成一条
CMyCurve* m_virtualRoot; //虚拟根节点
vector<CMyCurve*> m_srcPolygons; //多边形曲线
MyHierarchy m_hierarchy; //层级关系
//CPolyline m_combinedPolygon; //结果多边形合并后的一条曲线
vector<CPolyline*> m_rstPolygons; //生成的结果多边形
private:
CPolygonTree* m_pgnTree;
};