61 lines
1.6 KiB
C++
61 lines
1.6 KiB
C++
#pragma once
|
||
#include "CubicBezier.h"
|
||
#include "StraightLine.h"
|
||
#include "BvhTree.h"
|
||
#include <queue>
|
||
#include <set>
|
||
|
||
using std::queue;
|
||
using std::map;
|
||
using std::for_each;
|
||
using std::set;
|
||
|
||
struct ShortCutNode {
|
||
typedef vector<Point> vectorPoint;
|
||
int windingIncrement, eastGroup;
|
||
bool divided;
|
||
/* type 代表进入广度优先搜索队列的节点种类:
|
||
0:不需要拆开的节点
|
||
1:需要拆分*/
|
||
QVector4D bound;
|
||
vector<int> lineSet;
|
||
ShortCutNode() {
|
||
divided = true;
|
||
windingIncrement = 0;
|
||
eastGroup = 0;
|
||
lineSet.clear();
|
||
bound = { 0, 0, 0, 0 };
|
||
}
|
||
~ShortCutNode() {}
|
||
};
|
||
class ShortCutTree
|
||
{
|
||
typedef vector<Point> PointVector;
|
||
typedef vector<int> PointIndexVector;
|
||
private:
|
||
vector<ShortCutNode> restOfTreeNodes;
|
||
vector<LinePtr> allLine;
|
||
int RequiredLineMin, numPoint, numLine;
|
||
map<Point, int> pointMap;
|
||
vector<int> lineIndexs;
|
||
|
||
int getPointIndex(Point nowPoint);
|
||
void generateShortCutsegmentement(ShortCutNode& nowTreeNode);
|
||
bool handleShortCutNode(ShortCutNode& fa, ShortCutNode& nowTreeNode, double yValue, vector<ShortCutNode>& v, int& sumIncrement);
|
||
void spliteToShortCutTree();
|
||
static void monotonization(vector<PointVector>& inL, vector<LinePtr> &outL);
|
||
bool isLineEqual(PointIndexVector& a, PointIndexVector& b) const;
|
||
void simplifyLineVector();
|
||
public:
|
||
void init();
|
||
//lineMin最小线数目,即划分终止条件
|
||
ShortCutTree(int lineMin = 3)
|
||
:RequiredLineMin(lineMin), numPoint(0), numLine(0) {}
|
||
// 传入一个vector<vector<Point> > 作为所有输入的线
|
||
void buildShortCutTree(vector<PointVector>& lineSet);
|
||
// 获得点集合和线集合 返回输入BvhTree的数据集合
|
||
vector<BvhTreeData> getPointLineAndBvhTree(vector<float> &pointSet, vector<GLuint> &lineSet);
|
||
~ShortCutTree() {}
|
||
};
|
||
|