Fix incorrect seam allowance. #181

Case #1.
This commit is contained in:
Roman Telezhynskyi 2022-10-29 15:19:21 +03:00
parent 60b4851753
commit ab43b83ab2
11 changed files with 1679 additions and 3 deletions

View File

@ -6,6 +6,7 @@
- Fix export measurement separator to CSV. - Fix export measurement separator to CSV.
- Fix option Hide labels. - Fix option Hide labels.
- Improve segmenting a curve for calculating a piece path. - Improve segmenting a curve for calculating a piece path.
- [smart-pattern/valentina#184] Fix incorrect seam allowance.
# Valentina 0.7.52 September 12, 2022 # Valentina 0.7.52 September 12, 2022
- Fix crash when default locale is ru. - Fix crash when default locale is ru.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<vit>
<!--Measurements created with Valentina v0.7.50.0 (https://smart-pattern.com.ua/).-->
<version>0.5.1</version>
<read-only>false</read-only>
<notes>Nach Messung wegen Büste am 16.03.2021
Brustumfang : 88 -&gt; 86
Taille: 79 -&gt; 76
Hüfte: 92 -&gt; 94
Halsumfang: 39.5 -&gt; 37</notes>
<unit>cm</unit>
<pm_system>998</pm_system>
<personal>
<customer>Ronan</customer>
<birth-date>1987-04-03</birth-date>
<gender>male</gender>
<email/>
</personal>
<body-measurements>
<m name="waist_natural_circ" value="82"/>
<m name="waist_to_hip_b" value="21"/>
<m name="neck_back_to_waist_b" value="43"/>
<m name="across_chest_f" value="35"/>
<m name="across_back_b" value="35"/>
<m name="neck_back_to_bust_b" value="22.5"/>
<m name="hip_circ" value="94"/>
<m name="hand_circ" value="22"/>
<m name="leg_waist_side_to_floor" value="98.5"/>
<m name="leg_crotch_to_floor" value="77.5"/>
<m name="height_knee" value="48"/>
<m name="height_calf" value="30"/>
<m name="leg_thigh_upper_circ" value="50"/>
<m name="leg_knee_circ" value="35.5"/>
<m name="leg_calf_circ" value="34.5"/>
<m name="leg_knee_circ_bent" value="38.5"/>
<m name="leg_ankle_circ" value="25.5"/>
<m name="leg_ankle_diag_circ" value="32"/>
<m name="height" value="172"/>
<m name="neck_circ" value="37"/>
<m name="bust_circ" value="86"/>
<m name="waist_circ" value="76&#10;"/>
<m name="arm_shoulder_tip_to_wrist" value="58"/>
<m name="arm_wrist_circ" value="16"/>
<m name="head_circ" value="55"/>
<m name="arm_lower_circ" value="26"/>
</body-measurements>
</vit>

View File

@ -113,7 +113,9 @@ auto AngleByLength(QVector<VRawSAPoint> points, QPointF p1, QPointF p2, QPointF
{ {
qDebug()<<"Couldn't find intersection with cut line."; qDebug()<<"Couldn't find intersection with cut line.";
} }
points.append(VRawSAPoint(px, p.CurvePoint(), p.TurnPoint())); VRawSAPoint sp(px, p.CurvePoint(), p.TurnPoint());
sp.SetPrimary(true);
points.append(sp);
cutLine.setAngle(cutLine.angle()-180); cutLine.setAngle(cutLine.angle()-180);
type = Intersects(QLineF(sp2, sp3), cutLine, &px); type = Intersects(QLineF(sp2, sp3), cutLine, &px);
@ -122,7 +124,9 @@ auto AngleByLength(QVector<VRawSAPoint> points, QPointF p1, QPointF p2, QPointF
{ {
qDebug()<<"Couldn't find intersection with cut line."; qDebug()<<"Couldn't find intersection with cut line.";
} }
points.append(VRawSAPoint(px, p.CurvePoint(), p.TurnPoint())); sp = VRawSAPoint(px, p.CurvePoint(), p.TurnPoint());
sp.SetPrimary(true);
points.append(sp);
} }
else else
{// The point just fine {// The point just fine
@ -1129,9 +1133,9 @@ auto VAbstractPiece::Equidistant(QVector<VSAPoint> points, qreal width, const QS
const bool removeFirstAndLast = false; const bool removeFirstAndLast = false;
ekvPoints = RemoveDublicates(ekvPoints, removeFirstAndLast); ekvPoints = RemoveDublicates(ekvPoints, removeFirstAndLast);
ekvPoints = CheckLoops(ekvPoints); ekvPoints = CheckLoops(ekvPoints);
CastTo(ekvPoints, cleaned);//Result path can contain loops
cleaned = CorrectEquidistantPoints(cleaned, removeFirstAndLast); cleaned = CorrectEquidistantPoints(cleaned, removeFirstAndLast);
cleaned = CorrectPathDistortion(cleaned); cleaned = CorrectPathDistortion(cleaned);
CastTo(ekvPoints, cleaned);//Result path can contain loops
// QVector<QPointF> dump; // QVector<QPointF> dump;
// CastTo(cleaned, dump); // CastTo(cleaned, dump);

View File

@ -38,6 +38,7 @@
#include "../vmisc/compatibility.h" #include "../vmisc/compatibility.h"
#include "../vgeometry/vgobject.h" #include "../vgeometry/vgobject.h"
#include "vsapoint.h" #include "vsapoint.h"
#include "vrawsapoint.h"
#include "testpath.h" #include "testpath.h"
class VAbstractPieceData; class VAbstractPieceData;
@ -351,6 +352,36 @@ inline auto VAbstractPiece::ComparePoints(QVector<T> &points, const T &p1, const
return true; return true;
} }
//---------------------------------------------------------------------------------------------------------------------
template <>
inline auto VAbstractPiece::ComparePoints(QVector<VRawSAPoint> &points, const VRawSAPoint &p1, const VRawSAPoint &p2,
qreal accuracy) -> bool
{
qreal testAccuracy = accuracy;
if (p1.Primary() && p2.Primary())
{
testAccuracy = accuracyPointOnLine;
}
if (not VFuzzyComparePoints(p1, p2, testAccuracy))
{
points.append(p2);
return false;
}
if (not points.isEmpty() && p2.TurnPoint())
{
points.last().SetTurnPoint(true);
}
if (not points.isEmpty() && p2.CurvePoint())
{
points.last().SetCurvePoint(true);
}
return true;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <> template <>
inline auto VAbstractPiece::ComparePoints<QPointF>(QVector<QPointF> &points, const QPointF &p1, const QPointF &p2, inline auto VAbstractPiece::ComparePoints<QPointF>(QVector<QPointF> &points, const QPointF &p1, const QPointF &p2,
@ -386,6 +417,35 @@ inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector<T> &points, qreal
} }
} }
//---------------------------------------------------------------------------------------------------------------------
template <>
inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector<VRawSAPoint> &points, qreal accuracy) -> void
{
const VRawSAPoint& first = ConstFirst(points);
const VRawSAPoint& last = ConstLast(points);
qreal testAccuracy = accuracy;
if (first.Primary() && last.Primary())
{
testAccuracy = accuracyPointOnLine;
}
if (VFuzzyComparePoints(first, last, testAccuracy))
{
points.removeLast();
if (not points.isEmpty() && last.TurnPoint())
{
points.last().SetTurnPoint(true);
}
if (not points.isEmpty() && last.CurvePoint())
{
points.last().SetCurvePoint(true);
}
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <> template <>
inline auto VAbstractPiece::CompareFirstAndLastPoints<QPointF>(QVector<QPointF> &points, qreal accuracy) -> void inline auto VAbstractPiece::CompareFirstAndLastPoints<QPointF>(QVector<QPointF> &points, qreal accuracy) -> void

View File

@ -37,6 +37,7 @@ auto VRawSAPoint::toJson() const -> QJsonObject
pointObject[QLatin1String("type")] = "VRawSAPoint"; pointObject[QLatin1String("type")] = "VRawSAPoint";
pointObject[QLatin1String("loopPoint")] = m_loopPoint; pointObject[QLatin1String("loopPoint")] = m_loopPoint;
pointObject[QLatin1String("primary")] = m_primary;
return pointObject; return pointObject;
} }

View File

@ -53,10 +53,14 @@ public:
Q_DECL_CONSTEXPR auto LoopPoint() const -> bool; Q_DECL_CONSTEXPR auto LoopPoint() const -> bool;
Q_DECL_RELAXED_CONSTEXPR void SetLoopPoint(bool loopPoint); Q_DECL_RELAXED_CONSTEXPR void SetLoopPoint(bool loopPoint);
Q_DECL_CONSTEXPR auto Primary() const -> bool;
Q_DECL_RELAXED_CONSTEXPR void SetPrimary(bool primary);
auto toJson() const -> QJsonObject override; auto toJson() const -> QJsonObject override;
private: private:
bool m_loopPoint{false}; bool m_loopPoint{false};
bool m_primary{false};
}; };
Q_DECLARE_METATYPE(VRawSAPoint) // NOLINT Q_DECLARE_METATYPE(VRawSAPoint) // NOLINT
@ -106,6 +110,18 @@ Q_DECL_RELAXED_CONSTEXPR inline void VRawSAPoint::SetLoopPoint(bool loopPoint)
m_loopPoint = loopPoint; m_loopPoint = loopPoint;
} }
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline auto VRawSAPoint::Primary() const -> bool
{
return m_primary;
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_RELAXED_CONSTEXPR inline void VRawSAPoint::SetPrimary(bool primary)
{
m_primary = primary;
}
QT_WARNING_POP QT_WARNING_POP
#endif // VRAWSAPOINT_H #endif // VRAWSAPOINT_H

View File

@ -0,0 +1,78 @@
{
"vector": [
{
"turnPoint": true,
"type": "VSAPoint",
"x": 589.0064206717155,
"y": 782.4496746376101
},
{
"turnPoint": true,
"type": "VSAPoint",
"x": 597.0841810534489,
"y": 666.714504931189
},
{
"turnPoint": true,
"type": "VSAPoint",
"x": 658.8439751213995,
"y": 829.6285575700094
},
{
"turnPoint": true,
"type": "VSAPoint",
"x": 668.7920249877046,
"y": 713.62278781496
},
{
"turnPoint": true,
"type": "VSAPoint",
"x": 681.6851838985511,
"y": 749.9461773118659
},
{
"saAfter": 37.795275590551185,
"turnPoint": true,
"type": "VSAPoint",
"x": 878.9287903098608,
"y": 721.4082798757745
},
{
"saAfter": 37.795275590551185,
"saBefore": 37.795275590551185,
"turnPoint": true,
"type": "VSAPoint",
"x": 892.8692692510483,
"y": 929.4298158977432
},
{
"saAfter": 37.795275590551185,
"saBefore": 37.795275590551185,
"turnPoint": true,
"type": "VSAPoint",
"x": 669.9070856247861,
"y": 1038.0664013590958
},
{
"saAfter": 37.795275590551185,
"saBefore": 37.795275590551185,
"turnPoint": true,
"type": "VSAPoint",
"x": 425.2968981082859,
"y": 997.079828054777
},
{
"saBefore": 37.795275590551185,
"turnPoint": true,
"type": "VSAPoint",
"x": 379.70536635128207,
"y": 793.6376774711312
},
{
"turnPoint": true,
"type": "VSAPoint",
"x": 580.6895517317213,
"y": 764.5585799377853
}
]
}

View File

@ -0,0 +1,74 @@
{
"vector": [
{
"type": "QPointF",
"x": 588.3649734856448,
"y": 778.9784872844474
},
{
"type": "QPointF",
"x": 596.2541170835045,
"y": 665.9457492496151
},
{
"type": "QPointF",
"x": 597.6571516077917,
"y": 665.7389557340655
},
{
"type": "QPointF",
"x": 658.2963192477988,
"y": 825.696946170516
},
{
"type": "QPointF",
"x": 667.9744279101468,
"y": 712.8390031327132
},
{
"type": "QPointF",
"x": 669.3849599515413,
"y": 712.6577947901065
},
{
"type": "QPointF",
"x": 682.2742197194734,
"y": 748.9701993850377
},
{
"type": "QPointF",
"x": 916.3859644867284,
"y": 715.0980902591248
},
{
"type": "QPointF",
"x": 932.2799599616667,
"y": 952.2702395211089
},
{
"type": "QPointF",
"x": 675.5894289258003,
"y": 1077.340699266617
},
{
"type": "QPointF",
"x": 393.97611715611157,
"y": 1030.1539293143521
},
{
"type": "QPointF",
"x": 341.99572232904575,
"y": 798.2028869986758
},
{
"type": "QPointF",
"x": 581.2124761447806,
"y": 763.5921672415425
},
{
"type": "QPointF",
"x": 588.3649734856448,
"y": 778.9784872844474
}
]
}

View File

@ -155,5 +155,7 @@
<file>hood_1/output.json</file> <file>hood_1/output.json</file>
<file>hood_2/input.json</file> <file>hood_2/input.json</file>
<file>hood_2/output.json</file> <file>hood_2/output.json</file>
<file>smart_pattern_#184_case1/input.json</file>
<file>smart_pattern_#184_case1/output.json</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -956,6 +956,12 @@ void TST_VAbstractPiece::BrokenDetailEquidistant_data()
QStringLiteral("://hood_2/input.json"), QStringLiteral("://hood_2/input.json"),
QStringLiteral("://hood_2/output.json"), QStringLiteral("://hood_2/output.json"),
37.795275590551185 /*seam allowance width*/); 37.795275590551185 /*seam allowance width*/);
// See the file "collection/bugs/smart_pattern_#184_case1.val"
ASSERT_TEST_CASE("Issue #184 case 1",
QStringLiteral("://smart_pattern_#184_case1/input.json"),
QStringLiteral("://smart_pattern_#184_case1/output.json"),
37.795275590551185 /*seam allowance width*/);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------