diff --git a/src/libs/vlayout/vabstractdetail.cpp b/src/libs/vlayout/vabstractdetail.cpp index 5c8ab52e5..11845cf92 100644 --- a/src/libs/vlayout/vabstractdetail.cpp +++ b/src/libs/vlayout/vabstractdetail.cpp @@ -227,26 +227,27 @@ QVector VAbstractDetail::Equidistant(const QVector &points, co QVector VAbstractDetail::RemoveDublicates(const QVector &points) { QVector 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) - { - continue; - } - else - { - QPointF temp = p.at(j); - if (current == temp) - { - QVector::iterator iter = p.begin() + j; - p.erase(iter); - j--; - } - } + #if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) + p.remove(p.size() - 1); + #else + p.removeLast(); + #endif + } + } + + for (int i = 0; i < p.size()-1; ++i) + { + if (p.at(i) == p.at(i+1)) + { + p.erase(p.begin() + i + 1); + --i; + continue; } } diff --git a/src/libs/vlayout/vlayoutdetail.cpp b/src/libs/vlayout/vlayoutdetail.cpp index a94d48d5f..840828f22 100644 --- a/src/libs/vlayout/vlayoutdetail.cpp +++ b/src/libs/vlayout/vlayoutdetail.cpp @@ -69,14 +69,7 @@ QVector VLayoutDetail::GetContourPoints() const //--------------------------------------------------------------------------------------------------------------------- void VLayoutDetail::SetCountourPoints(const QVector &points) { - d->contour = points; - // Contour can't be closed - if (d->contour.first() == d->contour.last()) - { - d->contour.removeLast(); - } - - d->contour = RemoveDublicates(RoundPoints(d->contour)); + d->contour = RemoveDublicates(RoundPoints(points)); } //--------------------------------------------------------------------------------------------------------------------- @@ -94,12 +87,6 @@ void VLayoutDetail::SetSeamAllowencePoints(const QVector &points, bool d->seamAllowence = points; 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)); } else