|
|
|
@ -46,10 +46,11 @@ void ShortCutTree::monotonization(vector<PointVector>& inL, vector<LinePtr>& out
|
|
|
|
|
|
|
|
|
|
void ShortCutTree::generateShortCutsegmentement(ShortCutNode& nowTreeNode) {
|
|
|
|
|
Point p = {0, 0};
|
|
|
|
|
set<pair<int, int> > pointSet;
|
|
|
|
|
vector<int> v;
|
|
|
|
|
for (int & lineIndex : nowTreeNode.lineSet) {
|
|
|
|
|
int type = allLine[lineIndex]->judgeBoundIntersection(nowTreeNode.bound.z(), nowTreeNode.bound.y(), nowTreeNode.bound.w(), false), lineIndexBegin, lineIndexEnd;
|
|
|
|
|
if (type >= 2) {
|
|
|
|
|
v.push_back(numLine);
|
|
|
|
|
if (type == 2) {
|
|
|
|
|
p = allLine[lineIndex]->getEnd();
|
|
|
|
|
}
|
|
|
|
@ -58,34 +59,26 @@ void ShortCutTree::generateShortCutsegmentement(ShortCutNode& nowTreeNode) {
|
|
|
|
|
}
|
|
|
|
|
lineIndexBegin = getPointIndex({ p.x, nowTreeNode.bound.w() });
|
|
|
|
|
lineIndexEnd = getPointIndex(p);
|
|
|
|
|
auto iter = pointSet.find({ lineIndexBegin, lineIndexEnd });
|
|
|
|
|
if (iter != pointSet.end()) {
|
|
|
|
|
pointSet.erase(iter);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
pointSet.insert({ lineIndexBegin, lineIndexEnd });
|
|
|
|
|
}
|
|
|
|
|
lineIndexs.push_back(lineIndexBegin);
|
|
|
|
|
lineIndexs.push_back(lineIndexBegin);
|
|
|
|
|
lineIndexs.push_back(lineIndexEnd);
|
|
|
|
|
lineIndexs.push_back(lineIndexEnd);
|
|
|
|
|
numLine++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (nowTreeNode.windingIncrement != 0) {
|
|
|
|
|
v.push_back(numLine);
|
|
|
|
|
int lineIndexBegin = getPointIndex({ nowTreeNode.bound.z(), nowTreeNode.bound.y()});
|
|
|
|
|
int lineIndexEnd = getPointIndex({ nowTreeNode.bound.z(), nowTreeNode.bound.w() });
|
|
|
|
|
auto iter = pointSet.find({ lineIndexBegin, lineIndexEnd });
|
|
|
|
|
if (iter != pointSet.end()) {
|
|
|
|
|
pointSet.erase(iter);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
pointSet.insert({ lineIndexBegin, lineIndexEnd });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (auto& iter : pointSet) {
|
|
|
|
|
nowTreeNode.lineSet.push_back(numLine);
|
|
|
|
|
lineIndexs.push_back(iter.first);
|
|
|
|
|
lineIndexs.push_back(iter.first);
|
|
|
|
|
lineIndexs.push_back(iter.second);
|
|
|
|
|
lineIndexs.push_back(iter.second);
|
|
|
|
|
lineIndexs.push_back(lineIndexBegin);
|
|
|
|
|
lineIndexs.push_back(lineIndexBegin);
|
|
|
|
|
lineIndexs.push_back(lineIndexEnd);
|
|
|
|
|
lineIndexs.push_back(lineIndexEnd);
|
|
|
|
|
numLine++;
|
|
|
|
|
}
|
|
|
|
|
for (int& lineIndex : v) {
|
|
|
|
|
nowTreeNode.lineSet.push_back(lineIndex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ShortCutTree::handleShortCutNode(ShortCutNode& fa, ShortCutNode& nowTreeNode, double yValue, vector<ShortCutNode>& v, int& sumIncrement) {
|
|
|
|
|