修复宽度变化的bug (待测试)
parent
ae77ffdbdb
commit
f9e316c547
|
@ -8,6 +8,7 @@ using std::set;
|
|||
using std::pair;
|
||||
using std::vector;
|
||||
using std::queue;
|
||||
using std::make_shared;
|
||||
|
||||
void LineTree::init() {
|
||||
restOfTreeNodes.clear();
|
||||
|
@ -71,18 +72,38 @@ bool LineTree::isLineEqual(PointIndexVector& a, PointIndexVector& b) const {
|
|||
|
||||
void LineTree::monotonization(vector<PointVector>& inLines, vector<std::shared_ptr<Line>>& outLines) {
|
||||
bool isOffset = false;
|
||||
for (PointVector& l : inLines) {
|
||||
vector<std::shared_ptr<Line> > tmpLines;
|
||||
tmpLines.clear();
|
||||
for (int i = 0; i < inLines.size(); i++) {
|
||||
int endIndex = i;
|
||||
double totalLength = 0;
|
||||
while (endIndex < inLines.size() && *inLines[endIndex].rbegin() == *inLines[endIndex + 1].begin()) {
|
||||
endIndex++;
|
||||
}
|
||||
// 셕炬悧낀똑
|
||||
for (int j = i; j <= endIndex; j++) {
|
||||
PointVector& l = inLines[j];
|
||||
std::shared_ptr<Line> nowLine;
|
||||
switch (l.size()) {
|
||||
case 2: {
|
||||
nowLine.reset(new StraightLine(l));
|
||||
nowLine = make_shared<StraightLine>(l);
|
||||
break;
|
||||
}
|
||||
case 3: case 4: nowLine.reset(new CubicBezier(l)); break;
|
||||
case 4: nowLine = make_shared<CubicBezier>(l); break;
|
||||
default: break;
|
||||
}
|
||||
totalLength += nowLine->getIntegralByT(1);
|
||||
tmpLines.push_back(nowLine);
|
||||
}
|
||||
|
||||
//데딧뺏깻헹궐절
|
||||
double prefixLength = 0;
|
||||
for (auto nowLine : tmpLines) {
|
||||
// 防止在同一直线与 X 轴平行上
|
||||
double nowLineLength = nowLine->getIntegralByT(1);
|
||||
nowLine->setRate({ prefixLength / totalLength, (prefixLength + nowLineLength) / totalLength });
|
||||
prefixLength += nowLineLength;
|
||||
|
||||
if (isOffset) {
|
||||
nowLine->upwardOffsetForY(true, 1e-5);
|
||||
}
|
||||
|
@ -94,6 +115,9 @@ void LineTree::monotonization(vector<PointVector>& inLines, vector<std::shared_p
|
|||
nowLine->monotonization(outLines);
|
||||
outLines.push_back(nowLine);
|
||||
}
|
||||
tmpLines.clear();
|
||||
i = endIndex;
|
||||
}
|
||||
// 防止在首尾直线在与 X 轴平行上
|
||||
int siz = outLines.size();
|
||||
if (!(outLines[0]->getBegin() == outLines[siz - 1]->getEnd()))
|
||||
|
|
Loading…
Reference in New Issue