Merge pull request #3074 from shun-iwasawa/fix_vector_tape_tool_bug

Fix Vector Tape Tool on Joining Points at the Same Position
This commit is contained in:
Rodney 2020-01-30 20:03:23 -07:00 committed by GitHub
commit df1a12caba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2149,22 +2149,32 @@ VIStroke *TVectorImage::Imp::joinStroke(int index1, int index2, int cpIndex1,
int cpCount2 = stroke2->getControlPointCount();
int styleId = stroke1->getStyle();
int count = 0;
std::vector<TThickPoint> points(cpCount1 +
((index1 != index2) ? cpCount2 : 1) + 1);
// check if the both ends are at the same postion
bool isSamePos = isAlmostZero(tdistance2(stroke1->getControlPoint(cpIndex1),
stroke2->getControlPoint(cpIndex2)));
// connecting the ends in the same shape at the same postion
// means just making the shape self-looped
if (isSamePos && index1 == index2) {
stroke1->setSelfLoop();
return m_strokes[index1];
}
std::vector<TThickPoint> points;
int i, incr = (cpIndex1 == 0) ? -1 : 1;
for (i = ((cpIndex1 == 0) ? cpCount1 - 1 : 0); i != cpIndex1 + incr;
i += incr)
points[count++] = stroke1->getControlPoint(i);
points[count++] = 0.5 * (stroke1->getControlPoint(cpIndex1) +
stroke2->getControlPoint(cpIndex2));
int start = ((cpIndex1 == 0) ? cpCount1 - 1 : 0);
int end = (isSamePos) ? cpIndex1 : cpIndex1 + incr;
for (i = start; i != end; i += incr)
points.push_back(stroke1->getControlPoint(i));
points.push_back(0.5 * (stroke1->getControlPoint(cpIndex1) +
stroke2->getControlPoint(cpIndex2)));
if (index1 != index2) {
incr = (cpIndex2 == 0) ? 1 : -1;
for (i = cpIndex2; i != ((cpIndex2 == 0) ? cpCount2 - 1 : 0) + incr;
i += incr)
points[count++] = stroke2->getControlPoint(i);
start = (isSamePos) ? cpIndex2 + incr : cpIndex2;
end = ((cpIndex2 == 0) ? cpCount2 - 1 : 0) + incr;
for (i = start; i != end; i += incr)
points.push_back(stroke2->getControlPoint(i));
} else
points[count++] = stroke2->getControlPoint(cpIndex2);
points.push_back(stroke2->getControlPoint(cpIndex2));
TStroke *newStroke = new TStroke(points);
newStroke->setStyle(styleId);
@ -2948,7 +2958,7 @@ bool containsNoSubregion(const TRegion *r, const TPointD &p) {
} else
return false;
}
};
}; // namespace
//------------------------------------------------------