mirror of
https://gitlab.com/smart-pattern/valentina.git
synced 2024-10-02 13:21:33 +02:00
Replaced hand-crafted reverse algorithm with std::reverse
This commit is contained in:
parent
ed970fe6f6
commit
1a2c5de357
|
@ -508,20 +508,11 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, vidtype id, const VContai
|
|||
template <class T>
|
||||
QVector<T> VLayoutPiece::Map(QVector<T> points) const
|
||||
{
|
||||
for (int i = 0; i < points.size(); ++i)
|
||||
{
|
||||
points[i] = d->matrix.map(points.at(i));
|
||||
}
|
||||
|
||||
std::transform(points.begin(), points.end(), points.begin(),
|
||||
[this](const auto &point) { return d->matrix.map(point); });
|
||||
if (d->mirror)
|
||||
{
|
||||
QList<T> list = ConvertToList(points);
|
||||
|
||||
for (int k=0, s=list.size(), max=(s/2); k<max; k++)
|
||||
{
|
||||
SwapItemsAt(list, k, s-(1+k));
|
||||
}
|
||||
points = ConvertToVector(list);
|
||||
std::reverse(points.begin(), points.end());
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
|
|
@ -148,15 +148,16 @@ inline QVector<T> ConvertToVector(const QSet<T> &container)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
inline void SwapItemsAt(T &container, int i, int j)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
|
||||
container.swapItemsAt(i, j);
|
||||
#else
|
||||
container.swap(i, j);
|
||||
#endif
|
||||
}
|
||||
// NOTE: Delete if not necessary anymore
|
||||
//template <typename T>
|
||||
//inline void SwapItemsAt(T &container, int i, int j)
|
||||
//{
|
||||
//#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
|
||||
// container.swapItemsAt(i, j);
|
||||
//#else
|
||||
// container.swap(i, j);
|
||||
//#endif
|
||||
//}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
|
|
Loading…
Reference in a new issue