From f1b2f6e03b63d26d2b3663739805be085cdc921e Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 30 Jul 2024 19:21:07 +0300 Subject: [PATCH] Fix export of turn points. --- ChangeLog.txt | 1 + src/libs/vlayout/vabstractpiece.cpp | 2 + src/libs/vlayout/vabstractpiece.h | 13 +- src/libs/vmisc/testpath.h | 18 + src/libs/vpatterndb/vpiece.cpp | 2 + .../shirtv2_seam_allowance_line/input.json | 783 ++++++++++++++++++ .../shirtv2_seam_allowance_line/output.json | 80 ++ .../share/shirtv2_seam_line/input.json | 240 ++++++ .../share/shirtv2_seam_line/output.json | 80 ++ src/test/ValentinaTest/share/test_data.qrc | 4 + src/test/ValentinaTest/tst_vabstractpiece.cpp | 44 + src/test/ValentinaTest/tst_vabstractpiece.h | 2 + src/test/ValentinaTest/tst_vpiece.cpp | 51 +- src/test/ValentinaTest/tst_vpiece.h | 1 + 14 files changed, 1298 insertions(+), 23 deletions(-) create mode 100644 src/test/ValentinaTest/share/shirtv2_seam_allowance_line/input.json create mode 100644 src/test/ValentinaTest/share/shirtv2_seam_allowance_line/output.json create mode 100644 src/test/ValentinaTest/share/shirtv2_seam_line/input.json create mode 100644 src/test/ValentinaTest/share/shirtv2_seam_line/output.json diff --git a/ChangeLog.txt b/ChangeLog.txt index 7c2043f4d..c53f41e2a 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -9,6 +9,7 @@ - Add "Twin Sans" single stroke font. - Fixed generation of mirror side of piece based on fold line. - Puzzle app. Piece rotation with step 15 degrees by holding Ctrl key. +- Fix export of turn points. # Valentina 0.7.53 June 25, 2024 - Fix layout sheet export with empty name. diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index 1ca30b280..fcfaa7b06 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -1153,6 +1153,8 @@ auto VAbstractPiece::Equidistant(QVector points, qreal width, const QS cleaned = CorrectEquidistantPoints(cleaned, removeFirstAndLast); cleaned = CorrectPathDistortion(cleaned); + // DumpVector(TurnPointList(cleaned), QStringLiteral("output.json.XXXXXX")); // Uncomment for dumping test data + // QVector dump; // CastTo(cleaned, dump); // DumpVector(dump, QStringLiteral("output.json.XXXXXX")); // Uncomment for dumping test data diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h index 864a3549d..c32dd728f 100644 --- a/src/libs/vlayout/vabstractpiece.h +++ b/src/libs/vlayout/vabstractpiece.h @@ -234,23 +234,14 @@ template inline auto VAbstractPiece::CheckPointOnLine(QVector &points, const T &iPoint, const T &prevPoint, const T &nextPoint) -> bool { - if (!VGObject::IsPointOnLineSegment(iPoint, prevPoint, nextPoint) || + if (iPoint.TurnPoint() || (iPoint.CurvePoint() && !prevPoint.CurvePoint()) || + !VGObject::IsPointOnLineSegment(iPoint, prevPoint, nextPoint) || !IsEkvPointOnLine(iPoint, prevPoint, nextPoint)) { points.append(iPoint); return false; } - if (!points.isEmpty() && iPoint.TurnPoint()) - { - points.last().SetTurnPoint(true); - } - - if (!points.isEmpty() && iPoint.CurvePoint()) - { - points.last().SetCurvePoint(true); - } - return true; } diff --git a/src/libs/vmisc/testpath.h b/src/libs/vmisc/testpath.h index cf48a6c30..9e7e87c74 100644 --- a/src/libs/vmisc/testpath.h +++ b/src/libs/vmisc/testpath.h @@ -89,4 +89,22 @@ template void VectorToJson(const QVector &points, QJsonObject &json json[QLatin1String("vector")] = pointsArray; } #endif // !defined(V_NO_ASSERT) + +//--------------------------------------------------------------------------------------------------------------------- +template auto TurnPointList(const QVector &points) -> QVector +{ + QVector list; + list.reserve(points.size()); + + for (const auto &p : qAsConst(points)) + { + if (p.TurnPoint()) + { + list.append(p); + } + } + + return list; +} + #endif // TESTPATH_H diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 2587d1a65..ab40e8903 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -186,6 +186,8 @@ auto VPiece::MainPathPoints(const VContainer *data) const -> QVector points = mainPath.PathPoints(data); points = CheckLoops(CorrectEquidistantPoints(points)); // A path can contains loops + // DumpVector(TurnPointList(points), QStringLiteral("output.json.XXXXXX")); // Uncomment for dumping test data + // DumpVector(points, QStringLiteral("output.json.XXXXXX")); // Uncomment for dumping test data return points; } diff --git a/src/test/ValentinaTest/share/shirtv2_seam_allowance_line/input.json b/src/test/ValentinaTest/share/shirtv2_seam_allowance_line/input.json new file mode 100644 index 000000000..172bd87ad --- /dev/null +++ b/src/test/ValentinaTest/share/shirtv2_seam_allowance_line/input.json @@ -0,0 +1,783 @@ +{ + "vector": [ + { + "passmarkClockwiseOpening": false, + "saAfter": 56.69291338582678, + "saBefore": 26.45669291338583, + "turnPoint": true, + "type": "VSAPoint", + "x": -1695.8740157480315, + "y": -1001.9900661931171 + }, + { + "passmarkClockwiseOpening": false, + "saAfter": 56.69291338582678, + "saBefore": 56.69291338582678, + "turnPoint": true, + "type": "VSAPoint", + "x": -1223.4330708661416, + "y": -1001.9900661931171 + }, + { + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 56.69291338582678, + "turnPoint": true, + "type": "VSAPoint", + "x": -750.9921259842519, + "y": -1001.9900661931171 + }, + { + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "turnPoint": true, + "type": "VSAPoint", + "x": -750.9921259842519, + "y": -888.6042394214635 + }, + { + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "turnPoint": true, + "type": "VSAPoint", + "x": -750.9921259842519, + "y": -850.8089638309123 + }, + { + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "turnPoint": true, + "type": "VSAPoint", + "x": -750.9921259842519, + "y": -850.8089638309123 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -751.0105230352001, + "y": -848.6904032907711 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -751.192819858519, + "y": -844.5288493300338 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -751.5472676602066, + "y": -840.4604282000892 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -752.0711416765532, + "y": -836.4878646646468 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -752.7617171438496, + "y": -832.6138834874159 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -753.6162692983859, + "y": -828.8412094321063 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -754.6320733764528, + "y": -825.1725672624273 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -755.8064046143406, + "y": -821.6106817420884 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -757.1365382483402, + "y": -818.1582776347991 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -758.6197495147417, + "y": -814.8180797042692 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -760.2533136498355, + "y": -811.5928127142079 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -762.0345058899125, + "y": -808.485201428325 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -763.9606014712626, + "y": -805.4979706103297 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -766.028875630177, + "y": -802.633845023932 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -768.2366036029457, + "y": -799.8955494328409 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -770.5810606258592, + "y": -797.2858086007661 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -773.0595219352081, + "y": -794.8073472914173 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -775.6692627672828, + "y": -792.4628902685038 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -778.407558358374, + "y": -790.2551622957351 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -781.2716839447717, + "y": -788.1868881368207 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -784.258914762767, + "y": -786.2607925554705 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -787.3665260486498, + "y": -784.4796003153936 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -790.5917930387111, + "y": -782.8460361802997 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -793.931990969241, + "y": -781.3628249138983 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -797.3843950765304, + "y": -780.0326912798987 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -800.9462805968692, + "y": -778.8583600420109 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -804.6149227665483, + "y": -777.8425559639439 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -808.3875968218579, + "y": -776.9880038094077 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -812.2615779990888, + "y": -776.2974283421113 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -816.2341415345311, + "y": -775.7735543257646 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -820.3025626644758, + "y": -775.419106524077 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -824.464116625213, + "y": -775.2368097007582 + }, + { + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "turnPoint": true, + "type": "VSAPoint", + "x": -826.5826771653542, + "y": -775.2184126498099 + }, + { + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "turnPoint": true, + "type": "VSAPoint", + "x": -826.5826771653542, + "y": -775.2184126498099 + }, + { + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "turnPoint": true, + "type": "VSAPoint", + "x": -845.4803149606298, + "y": -775.2184126498099 + }, + { + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "turnPoint": true, + "type": "VSAPoint", + "x": -1601.3858267716535, + "y": -775.2184126498099 + }, + { + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "turnPoint": true, + "type": "VSAPoint", + "x": -1620.283464566929, + "y": -775.2184126498099 + }, + { + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "turnPoint": true, + "type": "VSAPoint", + "x": -1620.283464566929, + "y": -775.2184126498099 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1622.4020251070701, + "y": -775.2368097007582 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1626.5635790678075, + "y": -775.419106524077 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1630.632000197752, + "y": -775.7735543257646 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1634.6045637331945, + "y": -776.2974283421113 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1638.4785449104254, + "y": -776.9880038094077 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1642.251218965735, + "y": -777.8425559639439 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1645.9198611354138, + "y": -778.8583600420109 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1649.4817466557527, + "y": -780.0326912798987 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1652.9341507630422, + "y": -781.3628249138983 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1656.2743486935722, + "y": -782.8460361802997 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1659.4996156836335, + "y": -784.4796003153936 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1662.6072269695164, + "y": -786.2607925554705 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1665.5944577875116, + "y": -788.1868881368207 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1668.4585833739093, + "y": -790.2551622957351 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1671.1968789650005, + "y": -792.4628902685038 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1673.8066197970752, + "y": -794.8073472914173 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1676.2850811064245, + "y": -797.2858086007661 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1678.6295381293378, + "y": -799.8955494328409 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1680.8372661021065, + "y": -802.633845023932 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1682.9055402610206, + "y": -805.4979706103297 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1684.8316358423713, + "y": -808.485201428325 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1686.612828082448, + "y": -811.5928127142079 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1688.2463922175418, + "y": -814.8180797042692 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1689.7296034839433, + "y": -818.1582776347993 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1691.0597371179429, + "y": -821.6106817420884 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1692.234068355831, + "y": -825.1725672624273 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1693.2498724338975, + "y": -828.8412094321063 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1694.1044245884339, + "y": -832.6138834874159 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1694.79500005573, + "y": -836.4878646646468 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1695.318874072077, + "y": -840.4604282000892 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1695.6733218737645, + "y": -844.5288493300338 + }, + { + "angle": 6, + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "type": "VSAPoint", + "x": -1695.8556186970836, + "y": -848.6904032907711 + }, + { + "curvePoint": true, + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "turnPoint": true, + "type": "VSAPoint", + "x": -1695.8740157480315, + "y": -850.8089638309123 + }, + { + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "turnPoint": true, + "type": "VSAPoint", + "x": -1695.8740157480315, + "y": -850.8089638309123 + }, + { + "passmarkClockwiseOpening": false, + "saAfter": 26.45669291338583, + "saBefore": 26.45669291338583, + "turnPoint": true, + "type": "VSAPoint", + "x": -1695.8740157480315, + "y": -888.6042394214635 + } + ] +} diff --git a/src/test/ValentinaTest/share/shirtv2_seam_allowance_line/output.json b/src/test/ValentinaTest/share/shirtv2_seam_allowance_line/output.json new file mode 100644 index 000000000..cd6e18c41 --- /dev/null +++ b/src/test/ValentinaTest/share/shirtv2_seam_allowance_line/output.json @@ -0,0 +1,80 @@ +{ + "vector": [ + { + "turnPoint": true, + "type": "VLayoutPoint", + "x": -1722.3307086614172, + "y": -1058.6829795789438 + }, + { + "turnPoint": true, + "type": "VLayoutPoint", + "x": -1223.4330708661416, + "y": -1058.6829795789438 + }, + { + "turnPoint": true, + "type": "VLayoutPoint", + "x": -724.5354330708659, + "y": -1058.6829795789438 + }, + { + "turnPoint": true, + "type": "VLayoutPoint", + "x": -724.535433070866, + "y": -888.6042394214635 + }, + { + "curvePoint": true, + "turnPoint": true, + "type": "VLayoutPoint", + "x": -724.535433070866, + "y": -850.8089638309123 + }, + { + "curvePoint": true, + "turnPoint": true, + "type": "VLayoutPoint", + "x": -826.3529425092527, + "y": -748.7627171968269 + }, + { + "turnPoint": true, + "type": "VLayoutPoint", + "x": -845.4803149606298, + "y": -748.7617197364241 + }, + { + "turnPoint": true, + "type": "VLayoutPoint", + "x": -1601.3858267716535, + "y": -748.7617197364241 + }, + { + "curvePoint": true, + "turnPoint": true, + "type": "VLayoutPoint", + "x": -1620.283464566929, + "y": -748.7617197364241 + }, + { + "curvePoint": true, + "turnPoint": true, + "type": "VLayoutPoint", + "x": -1722.3297112010146, + "y": -850.5792291748149 + }, + { + "turnPoint": true, + "type": "VLayoutPoint", + "x": -1722.3307086614172, + "y": -888.6042394214635 + }, + { + "turnPoint": true, + "type": "VLayoutPoint", + "x": -1722.3307086614172, + "y": -1058.6829795789438 + } + ] +} diff --git a/src/test/ValentinaTest/share/shirtv2_seam_line/input.json b/src/test/ValentinaTest/share/shirtv2_seam_line/input.json new file mode 100644 index 000000000..190762942 --- /dev/null +++ b/src/test/ValentinaTest/share/shirtv2_seam_line/input.json @@ -0,0 +1,240 @@ +{ + "testCase": { + "bd": { + "items": [ + { + "id": 1045, + "mx": 9.999987401574804, + "my": 15, + "name": "A215", + "type": 0, + "x": -1695.8740157480315, + "y": -1001.9900661931171 + }, + { + "id": 1046, + "mx": 9.999987401574804, + "my": 15, + "name": "A213", + "type": 0, + "x": -1223.4330708661416, + "y": -1001.9900661931171 + }, + { + "id": 1047, + "mx": 9.999987401574804, + "my": 15, + "name": "A214", + "type": 0, + "x": -750.9921259842519, + "y": -1001.9900661931171 + }, + { + "id": 1568, + "mx": 9.999987401574804, + "my": 15, + "name": "A223", + "type": 0, + "x": -750.9921259842519, + "y": -888.6042394214635 + }, + { + "id": 1048, + "mx": 9.999987401574804, + "my": 15, + "name": "A218", + "type": 0, + "x": -750.9921259842519, + "y": -850.8089638309123 + }, + { + "aScale": 5, + "angle1": 269.9, + "angle1Formula": "269.9", + "angle2": 0.1, + "angle2Formula": "0.1", + "c1Length": 45.35433070866141, + "c1LengthFormula": "Line_A217_A218*0.6", + "c2Length": 45.35433070866141, + "c2LengthFormula": "Line_A217_A218*0.6", + "id": 1049, + "p1": { + "id": 975, + "mx": 9.999987401574804, + "my": 15, + "name": "A218", + "type": 0, + "x": -750.9921259842519, + "y": -850.8089638309123 + }, + "p4": { + "id": 977, + "mx": 9.999987401574804, + "my": 15, + "name": "A220", + "type": 0, + "x": -826.5826771653542, + "y": -775.2184126498099 + }, + "type": 3 + }, + { + "id": 1050, + "mx": 9.999987401574804, + "my": 15, + "name": "A220", + "type": 0, + "x": -826.5826771653542, + "y": -775.2184126498099 + }, + { + "id": 1569, + "mx": 9.999987401574804, + "my": 15, + "name": "A276", + "type": 0, + "x": -845.4803149606298, + "y": -775.2184126498099 + }, + { + "id": 1570, + "mx": 9.999987401574804, + "my": 15, + "name": "A277", + "type": 0, + "x": -1601.3858267716535, + "y": -775.2184126498099 + }, + { + "id": 1051, + "mx": 9.999987401574804, + "my": 15, + "name": "A221", + "type": 0, + "x": -1620.283464566929, + "y": -775.2184126498099 + }, + { + "aScale": 5, + "angle1": 179.9, + "angle1Formula": "179.9", + "angle2": 270.1, + "angle2Formula": "270.1", + "c1Length": 45.35433070866141, + "c1LengthFormula": "Line_A216_A219*0.6", + "c2Length": 45.35433070866141, + "c2LengthFormula": "Line_A216_A219*0.6", + "id": 1052, + "p1": { + "id": 983, + "mx": 9.999987401574804, + "my": 15, + "name": "A221", + "type": 0, + "x": -1620.283464566929, + "y": -775.2184126498099 + }, + "p4": { + "id": 976, + "mx": 9.999987401574804, + "my": 15, + "name": "A219", + "type": 0, + "x": -1695.8740157480315, + "y": -850.8089638309123 + }, + "type": 3 + }, + { + "id": 1053, + "mx": 9.999987401574804, + "my": 15, + "name": "A219", + "type": 0, + "x": -1695.8740157480315, + "y": -850.8089638309123 + }, + { + "id": 1571, + "mx": 9.999987401574804, + "my": 15, + "name": "A222", + "type": 0, + "x": -1695.8740157480315, + "y": -888.6042394214635 + } + ] + }, + "piece": { + "nodes": [ + { + "id": 1045, + "reverse": false, + "type": 26 + }, + { + "id": 1046, + "reverse": false, + "type": 26 + }, + { + "id": 1047, + "reverse": false, + "type": 26 + }, + { + "id": 1568, + "reverse": false, + "type": 26 + }, + { + "id": 1048, + "reverse": false, + "type": 26 + }, + { + "id": 1049, + "reverse": false, + "type": 29 + }, + { + "id": 1050, + "reverse": false, + "type": 26 + }, + { + "id": 1569, + "reverse": false, + "type": 26 + }, + { + "id": 1570, + "reverse": false, + "type": 26 + }, + { + "id": 1051, + "reverse": false, + "type": 26 + }, + { + "id": 1052, + "reverse": false, + "type": 29 + }, + { + "id": 1053, + "reverse": false, + "type": 26 + }, + { + "id": 1571, + "reverse": false, + "type": 26 + } + ], + "saWidth": 1, + "seamAllowance": true + } + } +} diff --git a/src/test/ValentinaTest/share/shirtv2_seam_line/output.json b/src/test/ValentinaTest/share/shirtv2_seam_line/output.json new file mode 100644 index 000000000..221a8d3cd --- /dev/null +++ b/src/test/ValentinaTest/share/shirtv2_seam_line/output.json @@ -0,0 +1,80 @@ +{ + "vector": [ + { + "turnPoint": true, + "type": "VLayoutPoint", + "x": -1695.8740157480315, + "y": -1001.9900661931171 + }, + { + "turnPoint": true, + "type": "VLayoutPoint", + "x": -1223.4330708661416, + "y": -1001.9900661931171 + }, + { + "turnPoint": true, + "type": "VLayoutPoint", + "x": -750.9921259842519, + "y": -1001.9900661931171 + }, + { + "turnPoint": true, + "type": "VLayoutPoint", + "x": -750.9921259842519, + "y": -888.6042394214635 + }, + { + "curvePoint": true, + "turnPoint": true, + "type": "VLayoutPoint", + "x": -750.9921259842519, + "y": -850.8089638309123 + }, + { + "curvePoint": true, + "turnPoint": true, + "type": "VLayoutPoint", + "x": -826.5826771653542, + "y": -775.2184126498099 + }, + { + "turnPoint": true, + "type": "VLayoutPoint", + "x": -845.4803149606298, + "y": -775.2184126498099 + }, + { + "turnPoint": true, + "type": "VLayoutPoint", + "x": -1601.3858267716535, + "y": -775.2184126498099 + }, + { + "curvePoint": true, + "turnPoint": true, + "type": "VLayoutPoint", + "x": -1620.283464566929, + "y": -775.2184126498099 + }, + { + "curvePoint": true, + "turnPoint": true, + "type": "VLayoutPoint", + "x": -1695.8740157480315, + "y": -850.8089638309123 + }, + { + "turnPoint": true, + "type": "VLayoutPoint", + "x": -1695.8740157480315, + "y": -888.6042394214635 + }, + { + "turnPoint": true, + "type": "VLayoutPoint", + "x": -1695.8740157480315, + "y": -1001.9900661931171 + } + ] +} diff --git a/src/test/ValentinaTest/share/test_data.qrc b/src/test/ValentinaTest/share/test_data.qrc index 7214f8118..cb9270ce5 100644 --- a/src/test/ValentinaTest/share/test_data.qrc +++ b/src/test/ValentinaTest/share/test_data.qrc @@ -212,5 +212,9 @@ full_seam_allowance_path_blazer_for_women_with_one_button_case_3/output.json full_seam_allowance_path_blazer_for_women_with_one_button_case_4/input.json full_seam_allowance_path_blazer_for_women_with_one_button_case_4/output.json + shirtv2_seam_line/input.json + shirtv2_seam_line/output.json + shirtv2_seam_allowance_line/input.json + shirtv2_seam_allowance_line/output.json diff --git a/src/test/ValentinaTest/tst_vabstractpiece.cpp b/src/test/ValentinaTest/tst_vabstractpiece.cpp index 57d394b18..2cf355972 100644 --- a/src/test/ValentinaTest/tst_vabstractpiece.cpp +++ b/src/test/ValentinaTest/tst_vabstractpiece.cpp @@ -1433,6 +1433,50 @@ void TST_VAbstractPiece::TestFullSeamAllowancePath() const ComparePaths(res, expected); } +//--------------------------------------------------------------------------------------------------------------------- +void TST_VAbstractPiece::TestSeamLineTurnPoints_data() const +{ + QTest::addColumn>("points"); + QTest::addColumn("width"); + QTest::addColumn>("turnPoints"); + + auto ASSERT_TEST_CASE = [](const char *title, const QString &input, const QString &output, qreal width) + { + try + { + QVector const inputPoints = AbstractTest::VectorFromJson(input); + QVector const turnPoints = AbstractTest::VectorFromJson(output); + QVector outputPoints; + CastTo(turnPoints, outputPoints); + QTest::newRow(title) << inputPoints << width << outputPoints; + } + catch (const VException &e) + { + QFAIL(qUtf8Printable(e.ErrorMessage())); + } + }; + + // See file valentina_private_collection/bugs/shirtv2/shirtv2.val + ASSERT_TEST_CASE("fabric_cuff_L", QStringLiteral("://shirtv2_seam_allowance_line/input.json"), + QStringLiteral("://shirtv2_seam_allowance_line/output.json"), + 37.795275590551185 /*seam allowance width*/); +} + +//--------------------------------------------------------------------------------------------------------------------- +void TST_VAbstractPiece::TestSeamLineTurnPoints() const +{ + QFETCH(QVector, points); + QFETCH(qreal, width); + QFETCH(QVector, turnPoints); + + QVector const ekv = VAbstractPiece::Equidistant(points, width, QString()); + QVector tPoints; + CastTo(TurnPointList(ekv), tPoints); // Take result + + // Begin comparison + ComparePaths(tPoints, turnPoints); +} + //--------------------------------------------------------------------------------------------------------------------- void TST_VAbstractPiece::Case3() const { diff --git a/src/test/ValentinaTest/tst_vabstractpiece.h b/src/test/ValentinaTest/tst_vabstractpiece.h index 8f6a75756..40c0d1d86 100644 --- a/src/test/ValentinaTest/tst_vabstractpiece.h +++ b/src/test/ValentinaTest/tst_vabstractpiece.h @@ -70,6 +70,8 @@ private slots: void TestFullSeamPath() const; void TestFullSeamAllowancePath_data() const; void TestFullSeamAllowancePath() const; + void TestSeamLineTurnPoints_data() const; + void TestSeamLineTurnPoints() const; private: auto InputPointsCase3() const -> QVector; diff --git a/src/test/ValentinaTest/tst_vpiece.cpp b/src/test/ValentinaTest/tst_vpiece.cpp index 964c93609..ff5b9bb75 100644 --- a/src/test/ValentinaTest/tst_vpiece.cpp +++ b/src/test/ValentinaTest/tst_vpiece.cpp @@ -27,17 +27,17 @@ *************************************************************************/ #include "tst_vpiece.h" -#include "../vpatterndb/vcontainer.h" -#include "../vpatterndb/vpiece.h" -#include "../vpatterndb/vpassmark.h" #include "../vmisc/vabstractvalapplication.h" - -#include +#include "../vpatterndb/vcontainer.h" +#include "../vpatterndb/vpassmark.h" #include "../vpatterndb/vpiece.h" +#include "../vpatterndb/vpiece.h" +#include + //--------------------------------------------------------------------------------------------------------------------- TST_VPiece::TST_VPiece(QObject *parent) - :AbstractTest(parent) + : AbstractTest(parent) { } @@ -99,22 +99,19 @@ void TST_VPiece::TestSAPassmark_data() }; // See file src/app/share/collection/bugs/Issue_#924.val - ASSERT_TEST_CASE("Test 1.", - QStringLiteral("://Issue_924_Test_1/passmarkData.json"), + ASSERT_TEST_CASE("Test 1.", QStringLiteral("://Issue_924_Test_1/passmarkData.json"), QStringLiteral("://Issue_924_Test_1/seamAllowance.json"), QStringLiteral("://Issue_924_Test_1/rotatedSeamAllowance.json"), QStringLiteral("://Issue_924_Test_1/passmarkShape.json")); // See file src/app/share/collection/bugs/Issue_#924.val - ASSERT_TEST_CASE("Test 2.", - QStringLiteral("://Issue_924_Test_2/passmarkData.json"), + ASSERT_TEST_CASE("Test 2.", QStringLiteral("://Issue_924_Test_2/passmarkData.json"), QStringLiteral("://Issue_924_Test_2/seamAllowance.json"), QStringLiteral("://Issue_924_Test_2/rotatedSeamAllowance.json"), QStringLiteral("://Issue_924_Test_2/passmarkShape.json")); // See file src/app/share/collection/bugs/incorrect_notch.val - ASSERT_TEST_CASE("Piece.", - QStringLiteral("://incorrect_notch/passmarkData.json"), + ASSERT_TEST_CASE("Piece.", QStringLiteral("://incorrect_notch/passmarkData.json"), QStringLiteral("://incorrect_notch/seamAllowance.json"), QStringLiteral("://incorrect_notch/rotatedSeamAllowance.json"), QStringLiteral("://incorrect_notch/passmarkShape.json")); @@ -132,3 +129,33 @@ void TST_VPiece::TestSAPassmark() CompareLinesDistance(passmark.SAPassmark(seamAllowance, rotatedSeamAllowance, PassmarkSide::All), expectedResult); } + +//--------------------------------------------------------------------------------------------------------------------- +void TST_VPiece::TestSeamLineTurnPoints() +{ + try + { + // See file valentina_private_collection/bugs/shirtv2.val + const Unit unit = Unit::Cm; + QSharedPointer data(new VContainer(nullptr, &unit, VContainer::UniqueNamespace())); + VAbstractValApplication::VApp()->SetPatternUnits(unit); + + VPiece detail; + AbstractTest::PieceFromJson(QStringLiteral("://shirtv2_seam_line/input.json"), detail, data); + + QVector const seamLine = detail.MainPathPoints(data.data()); + QVector pointsEkv; + CastTo(TurnPointList(seamLine), pointsEkv); + QVector const turnPoints = + AbstractTest::VectorFromJson(QStringLiteral("://shirtv2_seam_line/output.json")); + QVector origPoints; + CastTo(turnPoints, origPoints); + + // Begin comparison + ComparePaths(pointsEkv, origPoints); + } + catch (const VException &e) + { + QFAIL(qUtf8Printable(e.ErrorMessage())); + } +} diff --git a/src/test/ValentinaTest/tst_vpiece.h b/src/test/ValentinaTest/tst_vpiece.h index e6c1d439d..ba1f7fd22 100644 --- a/src/test/ValentinaTest/tst_vpiece.h +++ b/src/test/ValentinaTest/tst_vpiece.h @@ -42,6 +42,7 @@ private slots: void Issue620(); void TestSAPassmark_data(); void TestSAPassmark(); + void TestSeamLineTurnPoints(); private: Q_DISABLE_COPY_MOVE(TST_VPiece) // NOLINT