Fixed issues with seam allowance.

(grafted from 79a6fe52de80fc8707e24574eff1ec75eb1cd424)

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-10-17 18:12:39 +03:00
parent c47193540b
commit 81d2eb513a
7 changed files with 962 additions and 964 deletions

View File

@ -1,5 +1,6 @@
# Version 0.6.1 (unreleased) # Version 0.6.1 (unreleased)
- [#885] Regression. Broken support for multi size measurements. - [#885] Regression. Broken support for multi size measurements.
- Fixed issues with seam allowance.
# Version 0.6.0 October 1, 2018 # Version 0.6.0 October 1, 2018
- [#682] New feature. Export increments to Excel .csv. - [#682] New feature. Export increments to Excel .csv.

View File

@ -267,6 +267,8 @@ QVector<QPointF> AngleByLength(QVector<QPointF> points, QPointF p2, const QLineF
points = RollbackSeamAllowance(points, bigLine2, &success); points = RollbackSeamAllowance(points, bigLine2, &success);
} }
else else
{
if (p.GetAngleType() != PieceNodeAngle::ByLengthCurve)
{ {
// Need to create artificial loop // Need to create artificial loop
QLineF loop1(sp2, sp1); QLineF loop1(sp2, sp1);
@ -275,10 +277,15 @@ QVector<QPointF> AngleByLength(QVector<QPointF> points, QPointF p2, const QLineF
points.append(loop1.p2()); // Nedd for the main path rule points.append(loop1.p2()); // Nedd for the main path rule
loop1.setAngle(loop1.angle() + 180); loop1.setAngle(loop1.angle() + 180);
loop1.setLength(localWidth * 3.); loop1.setLength(localWidth);
points.append(loop1.p2()); points.append(loop1.p2());
points.append(bigLine2.p1()); points.append(bigLine2.p1());
} }
else
{
points.append(sp2);
}
}
} }
return points; return points;
} }
@ -683,7 +690,7 @@ void DumpVector(const QVector<VSAPoint> &points)
QT_WARNING_PUSH QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default") QT_WARNING_DISABLE_GCC("-Wswitch-default")
// This check helps to find missed angle types in the switch // This check helps to find missed angle types in the switch
Q_STATIC_ASSERT_X(static_cast<int>(PieceNodeAngle::LAST_ONE_DO_NOT_USE) == 6, Q_STATIC_ASSERT_X(static_cast<int>(PieceNodeAngle::LAST_ONE_DO_NOT_USE) == 7,
"Not all types were handled."); "Not all types were handled.");
QString typeStr; QString typeStr;
@ -708,6 +715,9 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
case PieceNodeAngle::BySecondEdgeRightAngle: case PieceNodeAngle::BySecondEdgeRightAngle:
typeStr = "BySecondEdgeRightAngle"; typeStr = "BySecondEdgeRightAngle";
break; break;
case PieceNodeAngle::ByLengthCurve:
typeStr = "ByLengthCurve";
break;
} }
QT_WARNING_POP QT_WARNING_POP
@ -890,6 +900,7 @@ QVector<QPointF> VAbstractPiece::Equidistant(QVector<VSAPoint> points, qreal wid
const bool removeFirstAndLast = false; const bool removeFirstAndLast = false;
ekvPoints = CheckLoops(CorrectEquidistantPoints(ekvPoints, removeFirstAndLast));//Result path can contain loops ekvPoints = CheckLoops(CorrectEquidistantPoints(ekvPoints, removeFirstAndLast));//Result path can contain loops
ekvPoints = CheckLoops(CorrectEquidistantPoints(ekvPoints, removeFirstAndLast));//Result path can contain loops
// DumpVector(ekvPoints); // Uncomment for dumping test data // DumpVector(ekvPoints); // Uncomment for dumping test data
return ekvPoints; return ekvPoints;
} }
@ -1077,8 +1088,8 @@ QVector<QPointF> VAbstractPiece::CheckLoops(const QVector<QPointF> &points)
* @param width global seam allowance width. * @param width global seam allowance width.
* @return seam aloowance points. * @return seam aloowance points.
*/ */
QVector<QPointF> VAbstractPiece::EkvPoint(QVector<QPointF> points, const VSAPoint &p1Line1, const VSAPoint &p2Line1, QVector<QPointF> VAbstractPiece::EkvPoint(QVector<QPointF> points, const VSAPoint &p1Line1, VSAPoint p2Line1,
const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width) const VSAPoint &p1Line2, VSAPoint p2Line2, qreal width)
{ {
if (width < 0) if (width < 0)
{ // width can't be < 0 { // width can't be < 0
@ -1091,6 +1102,19 @@ QVector<QPointF> VAbstractPiece::EkvPoint(QVector<QPointF> points, const VSAPoin
return QVector<QPointF>(); // Wrong edges return QVector<QPointF>(); // Wrong edges
} }
// Correct distorsion
if (VGObject::IsPointOnLineSegment(p2Line1, p1Line1, p1Line2))
{
QLineF line = QLineF(p1Line1, p1Line2);
line.setLength(QLineF(p1Line1, p2Line1).length());
p2Line1.setX(line.p2().x());
p2Line1.setY(line.p2().y());
p2Line2.setX(line.p2().x());
p2Line2.setY(line.p2().y());
}
const QLineF bigLine1 = ParallelLine(p1Line1, p2Line1, width ); const QLineF bigLine1 = ParallelLine(p1Line1, p2Line1, width );
const QLineF bigLine2 = ParallelLine(p2Line2, p1Line2, width ); const QLineF bigLine2 = ParallelLine(p2Line2, p1Line2, width );
QPointF crosPoint; QPointF crosPoint;
@ -1105,7 +1129,8 @@ QVector<QPointF> VAbstractPiece::EkvPoint(QVector<QPointF> points, const VSAPoin
{ // Most common case { // Most common case
/* Case when a path has point on line (both segments lie on the same line) and seam allowance creates /* Case when a path has point on line (both segments lie on the same line) and seam allowance creates
* prong. */ * prong. */
if (VGObject::IsPointOnLineSegment(p2Line1, p1Line1, p1Line2)) if (VGObject::IsPointOnLineSegment(p2Line1, p1Line1, p1Line2)
&& qAbs(QLineF(p2Line1, bigLine1.p2()).angle() - QLineF(p2Line1, bigLine2.p1()).angle()) < 0.001)
{ {
points.append(bigLine1.p2()); points.append(bigLine1.p2());
points.append(bigLine2.p1()); points.append(bigLine2.p1());
@ -1128,7 +1153,7 @@ QVector<QPointF> VAbstractPiece::EkvPoint(QVector<QPointF> points, const VSAPoin
QT_WARNING_PUSH QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default") QT_WARNING_DISABLE_GCC("-Wswitch-default")
// This check helps to find missed angle types in the switch // This check helps to find missed angle types in the switch
Q_STATIC_ASSERT_X(static_cast<int>(PieceNodeAngle::LAST_ONE_DO_NOT_USE) == 6, Q_STATIC_ASSERT_X(static_cast<int>(PieceNodeAngle::LAST_ONE_DO_NOT_USE) == 7,
"Not all types were handled."); "Not all types were handled.");
switch (p2Line1.GetAngleType()) switch (p2Line1.GetAngleType())
{ {
@ -1136,6 +1161,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
Q_UNREACHABLE(); //-V501 Q_UNREACHABLE(); //-V501
break; break;
case PieceNodeAngle::ByLength: case PieceNodeAngle::ByLength:
case PieceNodeAngle::ByLengthCurve:
return AngleByLength(points, p2Line1, bigLine1, crosPoint, bigLine2, p2Line1, width); return AngleByLength(points, p2Line1, bigLine1, crosPoint, bigLine2, p2Line1, width);
case PieceNodeAngle::ByPointsIntersection: case PieceNodeAngle::ByPointsIntersection:
return AngleByIntersection(points, p1Line1, p2Line1, p1Line2, bigLine1, crosPoint, bigLine2, return AngleByIntersection(points, p1Line1, p2Line1, p1Line2, bigLine1, crosPoint, bigLine2,

View File

@ -186,8 +186,8 @@ public:
static QVector<QPointF> Equidistant(QVector<VSAPoint> points, qreal width); static QVector<QPointF> Equidistant(QVector<VSAPoint> points, qreal width);
static qreal SumTrapezoids(const QVector<QPointF> &points); static qreal SumTrapezoids(const QVector<QPointF> &points);
static QVector<QPointF> CheckLoops(const QVector<QPointF> &points); static QVector<QPointF> CheckLoops(const QVector<QPointF> &points);
static QVector<QPointF> EkvPoint(QVector<QPointF> points, const VSAPoint &p1Line1, const VSAPoint &p2Line1, static QVector<QPointF> EkvPoint(QVector<QPointF> points, const VSAPoint &p1Line1, VSAPoint p2Line1,
const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width); const VSAPoint &p1Line2, VSAPoint p2Line2, qreal width);
static QLineF ParallelLine(const VSAPoint &p1, const VSAPoint &p2, qreal width); static QLineF ParallelLine(const VSAPoint &p1, const VSAPoint &p2, qreal width);
template <class T> template <class T>

View File

@ -73,11 +73,12 @@ enum class Draw : char { Calculation, Modeling, Layout };
enum class PieceNodeAngle : unsigned char enum class PieceNodeAngle : unsigned char
{ {
ByLength = 0, ByLength = 0,
ByPointsIntersection, ByPointsIntersection = 1,
ByFirstEdgeSymmetry, ByFirstEdgeSymmetry = 2,
BySecondEdgeSymmetry, BySecondEdgeSymmetry = 3,
ByFirstEdgeRightAngle, ByFirstEdgeRightAngle = 4,
BySecondEdgeRightAngle, BySecondEdgeRightAngle = 5,
ByLengthCurve = 6, // used only in runtime
LAST_ONE_DO_NOT_USE LAST_ONE_DO_NOT_USE
}; };

View File

@ -423,7 +423,7 @@ QVector<QPointF> VPiece::SeamAllowancePoints(const VContainer *data) const
for (int j = 0; j < r.size(); ++j) for (int j = 0; j < r.size(); ++j)
{ {
r[j].SetAngleType(PieceNodeAngle::ByLength); r[j].SetAngleType(PieceNodeAngle::ByLengthCurve);
r[j].SetSABefore(0); r[j].SetSABefore(0);
r[j].SetSAAfter(0); r[j].SetSAAfter(0);
} }

View File

@ -1120,6 +1120,7 @@ QVector<VSAPoint> VPiecePath::CurveSeamAllowanceSegment(const VContainer *data,
for(int i = 0; i < points.size(); ++i) for(int i = 0; i < points.size(); ++i)
{ {
VSAPoint p(points.at(i)); VSAPoint p(points.at(i));
p.SetAngleType(PieceNodeAngle::ByLengthCurve);
if (i == 0) if (i == 0)
{ // first point { // first point
p.SetSAAfter(begin.GetSAAfter()); p.SetSAAfter(begin.GetSAAfter());
@ -1175,7 +1176,7 @@ QVector<VSAPoint> VPiecePath::CurveSeamAllowanceSegment(const VContainer *data,
p.SetSAAfter(localWidth); p.SetSAAfter(localWidth);
p.SetSABefore(localWidth); p.SetSABefore(localWidth);
// curve points have angle type by default p.SetAngleType(PieceNodeAngle::ByLengthCurve);
} }
pointsEkv.append(p); pointsEkv.append(p);

File diff suppressed because it is too large Load Diff