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

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-05-17 18:31:17 +03:00
parent 0fe066925a
commit 7392e8e914
7 changed files with 272 additions and 46 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

@ -74,21 +74,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));
if (not d->contour.isEmpty())
{
// Contour can't be closed
if (d->contour.first() == d->contour.last())
{
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
d->contour.remove(d->layoutAllowence.size() - 1);
#else
d->contour.removeLast();
#endif
}
}
d->contour = RemoveDublicates(RoundPoints(d->contour));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -107,16 +93,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())
{
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
d->seamAllowence.remove(d->layoutAllowence.size() - 1);
#else
d->seamAllowence.removeLast();
#endif
}
d->seamAllowence = RemoveDublicates(RoundPoints(d->seamAllowence)); d->seamAllowence = RemoveDublicates(RoundPoints(d->seamAllowence));
} }
else else

View File

@ -39,14 +39,16 @@ SOURCES += \
tst_vabstractdetail.cpp \ tst_vabstractdetail.cpp \
tst_vspline.cpp \ tst_vspline.cpp \
abstracttest.cpp \ abstracttest.cpp \
tst_nameregexp.cpp tst_nameregexp.cpp \
tst_vlayoutdetail.cpp
HEADERS += \ HEADERS += \
tst_vposter.h \ tst_vposter.h \
tst_vabstractdetail.h \ tst_vabstractdetail.h \
tst_vspline.h \ tst_vspline.h \
abstracttest.h \ abstracttest.h \
tst_nameregexp.h tst_nameregexp.h \
tst_vlayoutdetail.h
CONFIG(debug, debug|release){ CONFIG(debug, debug|release){
# Debug mode # Debug mode

View File

@ -32,6 +32,7 @@
#include "tst_vabstractdetail.h" #include "tst_vabstractdetail.h"
#include "tst_vspline.h" #include "tst_vspline.h"
#include "tst_nameregexp.h" #include "tst_nameregexp.h"
#include "tst_vlayoutdetail.h"
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
@ -48,6 +49,7 @@ int main(int argc, char** argv)
ASSERT_TEST(new TST_VAbstractDetail()); ASSERT_TEST(new TST_VAbstractDetail());
ASSERT_TEST(new TST_VSpline()); ASSERT_TEST(new TST_VSpline());
ASSERT_TEST(new TST_NameRegExp()); ASSERT_TEST(new TST_NameRegExp());
ASSERT_TEST(new TST_VLayoutDetail());
return status; return status;
} }

View File

@ -42,7 +42,9 @@ TST_VAbstractDetail::TST_VAbstractDetail(QObject *parent)
void TST_VAbstractDetail::EquidistantRemoveLoop() const void TST_VAbstractDetail::EquidistantRemoveLoop() const
{ {
// These are two real cases where equdistant has loop. // These are two real cases where equdistant has loop.
// Code should clean loops. // See issue #298. Segmented Curve isn't selected in Seam Allowance tool.
// https://bitbucket.org/dismine/valentina/issue/298/segmented-curve-isnt-selected-in-seam
// Code should clean loops in path.
Case1(); Case1();
Case2(); Case2();
} }

View File

@ -0,0 +1,186 @@
/************************************************************************
**
** @file tst_vlayoutdetail.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 17 5, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "tst_vlayoutdetail.h"
#include "../../libs/vlayout/vlayoutdetail.h"
#include <QtDebug>
//---------------------------------------------------------------------------------------------------------------------
TST_VLayoutDetail::TST_VLayoutDetail(QObject *parent)
{
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VLayoutDetail::RemoveDublicates() const
{
qDebug()<<"Case 1.";
Case1();
qDebug()<<"Case 2.";
Case2();
qDebug()<<"Case 3.";
Case3();
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VLayoutDetail::Case1() const
{
// See issue #304. Layout appears different than my pattern.
// https://bitbucket.org/dismine/valentina/issue/304/layout-appears-different-than-my-pattern
VLayoutDetail det = VLayoutDetail();
det.SetCountourPoints(InputPointsCase1());
// Begin comparison
Comparison(det.GetContourPoints(), OutputPointsCase1());
}
//---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> TST_VLayoutDetail::InputPointsCase1() const
{
QVector<QPointF> points;
points += QPointF(557.0, -94.0);
points += QPointF(760.0, -53.0);
points += QPointF(661.0, 411.0);
points += QPointF(708.0, 467.0);
points += QPointF(366.0, 845.0);
points += QPointF(750.0, 509.0);
points += QPointF(957.0, 556.0);
points += QPointF(933.0, 787.0);
points += QPointF(366.0, 845.0);
points += QPointF(921.0, 901.0);
points += QPointF(883.0, 1158.0);
points += QPointF(866.0, 1446.0);
points += QPointF(396.0, 1446.0);
points += QPointF(400.0, 1093.0);
points += QPointF(366.0, 917.0);
points += QPointF(366.0, 845.0);
points += QPointF(466.0, 411.0);
return points;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> TST_VLayoutDetail::OutputPointsCase1() const
{
QVector<QPointF> points;
points += QPointF(557.0, -94.0);
points += QPointF(760.0, -53.0);
points += QPointF(661.0, 411.0);
points += QPointF(708.0, 467.0);
points += QPointF(366.0, 845.0);
points += QPointF(750.0, 509.0);
points += QPointF(957.0, 556.0);
points += QPointF(933.0, 787.0);
points += QPointF(366.0, 845.0);
points += QPointF(921.0, 901.0);
points += QPointF(883.0, 1158.0);
points += QPointF(866.0, 1446.0);
points += QPointF(396.0, 1446.0);
points += QPointF(400.0, 1093.0);
points += QPointF(366.0, 917.0);
points += QPointF(366.0, 845.0);
points += QPointF(466.0, 411.0);
return points;
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VLayoutDetail::Case2() const
{
VLayoutDetail det = VLayoutDetail();
det.SetCountourPoints(InputPointsCase2());
// Begin comparison
Comparison(det.GetContourPoints(), OutputPointsCase2());
}
//---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> TST_VLayoutDetail::InputPointsCase2() const
{
QVector<QPointF> points;
points += QPointF(557.0, -94.0);
points += QPointF(760.0, -53.0);
points += QPointF(760.0, -53.0);// Need delete this part
points += QPointF(760.0, -53.0);// Need delete this part
points += QPointF(760.0, -53.0);// Need delete this part
points += QPointF(661.0, 411.0);
points += QPointF(708.0, 467.0);
points += QPointF(366.0, 845.0);
return points;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> TST_VLayoutDetail::OutputPointsCase2() const
{
QVector<QPointF> points;
points += QPointF(557.0, -94.0);
points += QPointF(760.0, -53.0);
points += QPointF(661.0, 411.0);
points += QPointF(708.0, 467.0);
points += QPointF(366.0, 845.0);
return points;
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VLayoutDetail::Case3() const
{
VLayoutDetail det = VLayoutDetail();
det.SetCountourPoints(InputPointsCase3());
// Begin comparison
Comparison(det.GetContourPoints(), OutputPointsCase3());
}
//---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> TST_VLayoutDetail::InputPointsCase3() const
{
QVector<QPointF> points;
points += QPointF(557.0, -94.0);// Only one point
return points;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> TST_VLayoutDetail::OutputPointsCase3() const
{
QVector<QPointF> points;
points += QPointF(557.0, -94.0);// Only one point
return points;
}

View File

@ -0,0 +1,57 @@
/************************************************************************
**
** @file tst_vlayoutdetail.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 17 5, 2015
**
** @brief
** @copyright
** This source code is part of the Valentine project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2015 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef TST_VLAYOUTDETAIL_H
#define TST_VLAYOUTDETAIL_H
#include "abstracttest.h"
class TST_VLayoutDetail : public AbstractTest
{
Q_OBJECT
public:
TST_VLayoutDetail(QObject *parent = 0);
private slots:
void RemoveDublicates() const;
private:
void Case1() const;
QVector<QPointF> InputPointsCase1() const;
QVector<QPointF> OutputPointsCase1() const;
void Case2() const;
QVector<QPointF> InputPointsCase2() const;
QVector<QPointF> OutputPointsCase2() const;
void Case3() const;
QVector<QPointF> InputPointsCase3() const;
QVector<QPointF> OutputPointsCase3() const;
};
#endif // TST_VLAYOUTDETAIL_H