Fixed issue #304. Layout appears different than my pattern.

--HG--
branch : release
This commit is contained in:
Roman Telezhynskyi 2015-05-17 18:43:57 +03:00
parent 2e56525f62
commit 796cd7079e
2 changed files with 20 additions and 32 deletions

View File

@ -227,26 +227,27 @@ QVector<QPointF> VAbstractDetail::Equidistant(const QVector<QPointF> &points, co
QVector<QPointF> VAbstractDetail::RemoveDublicates(const QVector<QPointF> &points) QVector<QPointF> VAbstractDetail::RemoveDublicates(const QVector<QPointF> &points)
{ {
QVector<QPointF> p = points; QVector<QPointF> p = points;
for (int i = 0; i < p.size(); i++)
{
QPointF current = p.at(i);
for (int j = i; j < p.size(); j++) if (not p.isEmpty() && p.size() > 1)
{
// Path can't be closed
if (p.first() == p.last())
{ {
if (j == i) #if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
{ p.remove(p.size() - 1);
continue; #else
} p.removeLast();
else #endif
{ }
QPointF temp = p.at(j); }
if (current == temp)
{ for (int i = 0; i < p.size()-1; ++i)
QVector<QPointF>::iterator iter = p.begin() + j; {
p.erase(iter); if (p.at(i) == p.at(i+1))
j--; {
} p.erase(p.begin() + i + 1);
} --i;
continue;
} }
} }

View File

@ -69,14 +69,7 @@ QVector<QPointF> VLayoutDetail::GetContourPoints() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutDetail::SetCountourPoints(const QVector<QPointF> &points) void VLayoutDetail::SetCountourPoints(const QVector<QPointF> &points)
{ {
d->contour = points; d->contour = RemoveDublicates(RoundPoints(points));
// Contour can't be closed
if (d->contour.first() == d->contour.last())
{
d->contour.removeLast();
}
d->contour = RemoveDublicates(RoundPoints(d->contour));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -94,12 +87,6 @@ void VLayoutDetail::SetSeamAllowencePoints(const QVector<QPointF> &points, bool
d->seamAllowence = points; d->seamAllowence = points;
if (not d->seamAllowence.isEmpty()) if (not d->seamAllowence.isEmpty())
{ {
// Seam allowence can't be closed
if (d->seamAllowence.first() == d->seamAllowence.last())
{
d->seamAllowence.removeLast();
}
d->seamAllowence = RemoveDublicates(RoundPoints(d->seamAllowence)); d->seamAllowence = RemoveDublicates(RoundPoints(d->seamAllowence));
} }
else else