Fixed issues with seam allowance.
(grafted from 79a6fe52de80fc8707e24574eff1ec75eb1cd424) --HG-- branch : develop
This commit is contained in:
parent
c47193540b
commit
81d2eb513a
|
@ -1,5 +1,6 @@
|
|||
# Version 0.6.1 (unreleased)
|
||||
- [#885] Regression. Broken support for multi size measurements.
|
||||
- Fixed issues with seam allowance.
|
||||
|
||||
# Version 0.6.0 October 1, 2018
|
||||
- [#682] New feature. Export increments to Excel .csv.
|
||||
|
|
|
@ -267,6 +267,8 @@ QVector<QPointF> AngleByLength(QVector<QPointF> points, QPointF p2, const QLineF
|
|||
points = RollbackSeamAllowance(points, bigLine2, &success);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p.GetAngleType() != PieceNodeAngle::ByLengthCurve)
|
||||
{
|
||||
// Need to create artificial loop
|
||||
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
|
||||
|
||||
loop1.setAngle(loop1.angle() + 180);
|
||||
loop1.setLength(localWidth * 3.);
|
||||
loop1.setLength(localWidth);
|
||||
points.append(loop1.p2());
|
||||
points.append(bigLine2.p1());
|
||||
}
|
||||
else
|
||||
{
|
||||
points.append(sp2);
|
||||
}
|
||||
}
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
@ -683,7 +690,7 @@ void DumpVector(const QVector<VSAPoint> &points)
|
|||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||
// 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.");
|
||||
|
||||
QString typeStr;
|
||||
|
@ -708,6 +715,9 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
case PieceNodeAngle::BySecondEdgeRightAngle:
|
||||
typeStr = "BySecondEdgeRightAngle";
|
||||
break;
|
||||
case PieceNodeAngle::ByLengthCurve:
|
||||
typeStr = "ByLengthCurve";
|
||||
break;
|
||||
}
|
||||
QT_WARNING_POP
|
||||
|
||||
|
@ -890,6 +900,7 @@ QVector<QPointF> VAbstractPiece::Equidistant(QVector<VSAPoint> points, qreal wid
|
|||
|
||||
const bool removeFirstAndLast = false;
|
||||
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
|
||||
return ekvPoints;
|
||||
}
|
||||
|
@ -1077,8 +1088,8 @@ QVector<QPointF> VAbstractPiece::CheckLoops(const QVector<QPointF> &points)
|
|||
* @param width global seam allowance width.
|
||||
* @return seam aloowance points.
|
||||
*/
|
||||
QVector<QPointF> VAbstractPiece::EkvPoint(QVector<QPointF> points, const VSAPoint &p1Line1, const VSAPoint &p2Line1,
|
||||
const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width)
|
||||
QVector<QPointF> VAbstractPiece::EkvPoint(QVector<QPointF> points, const VSAPoint &p1Line1, VSAPoint p2Line1,
|
||||
const VSAPoint &p1Line2, VSAPoint p2Line2, qreal width)
|
||||
{
|
||||
if (width < 0)
|
||||
{ // width can't be < 0
|
||||
|
@ -1091,6 +1102,19 @@ QVector<QPointF> VAbstractPiece::EkvPoint(QVector<QPointF> points, const VSAPoin
|
|||
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 bigLine2 = ParallelLine(p2Line2, p1Line2, width );
|
||||
QPointF crosPoint;
|
||||
|
@ -1105,7 +1129,8 @@ QVector<QPointF> VAbstractPiece::EkvPoint(QVector<QPointF> points, const VSAPoin
|
|||
{ // Most common case
|
||||
/* Case when a path has point on line (both segments lie on the same line) and seam allowance creates
|
||||
* 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(bigLine2.p1());
|
||||
|
@ -1128,7 +1153,7 @@ QVector<QPointF> VAbstractPiece::EkvPoint(QVector<QPointF> points, const VSAPoin
|
|||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||
// 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.");
|
||||
switch (p2Line1.GetAngleType())
|
||||
{
|
||||
|
@ -1136,6 +1161,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
Q_UNREACHABLE(); //-V501
|
||||
break;
|
||||
case PieceNodeAngle::ByLength:
|
||||
case PieceNodeAngle::ByLengthCurve:
|
||||
return AngleByLength(points, p2Line1, bigLine1, crosPoint, bigLine2, p2Line1, width);
|
||||
case PieceNodeAngle::ByPointsIntersection:
|
||||
return AngleByIntersection(points, p1Line1, p2Line1, p1Line2, bigLine1, crosPoint, bigLine2,
|
||||
|
|
|
@ -186,8 +186,8 @@ public:
|
|||
static QVector<QPointF> Equidistant(QVector<VSAPoint> points, qreal width);
|
||||
static qreal SumTrapezoids(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,
|
||||
const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width);
|
||||
static QVector<QPointF> EkvPoint(QVector<QPointF> points, const VSAPoint &p1Line1, VSAPoint p2Line1,
|
||||
const VSAPoint &p1Line2, VSAPoint p2Line2, qreal width);
|
||||
static QLineF ParallelLine(const VSAPoint &p1, const VSAPoint &p2, qreal width);
|
||||
|
||||
template <class T>
|
||||
|
|
|
@ -73,11 +73,12 @@ enum class Draw : char { Calculation, Modeling, Layout };
|
|||
enum class PieceNodeAngle : unsigned char
|
||||
{
|
||||
ByLength = 0,
|
||||
ByPointsIntersection,
|
||||
ByFirstEdgeSymmetry,
|
||||
BySecondEdgeSymmetry,
|
||||
ByFirstEdgeRightAngle,
|
||||
BySecondEdgeRightAngle,
|
||||
ByPointsIntersection = 1,
|
||||
ByFirstEdgeSymmetry = 2,
|
||||
BySecondEdgeSymmetry = 3,
|
||||
ByFirstEdgeRightAngle = 4,
|
||||
BySecondEdgeRightAngle = 5,
|
||||
ByLengthCurve = 6, // used only in runtime
|
||||
LAST_ONE_DO_NOT_USE
|
||||
};
|
||||
|
||||
|
|
|
@ -423,7 +423,7 @@ QVector<QPointF> VPiece::SeamAllowancePoints(const VContainer *data) const
|
|||
|
||||
for (int j = 0; j < r.size(); ++j)
|
||||
{
|
||||
r[j].SetAngleType(PieceNodeAngle::ByLength);
|
||||
r[j].SetAngleType(PieceNodeAngle::ByLengthCurve);
|
||||
r[j].SetSABefore(0);
|
||||
r[j].SetSAAfter(0);
|
||||
}
|
||||
|
|
|
@ -1120,6 +1120,7 @@ QVector<VSAPoint> VPiecePath::CurveSeamAllowanceSegment(const VContainer *data,
|
|||
for(int i = 0; i < points.size(); ++i)
|
||||
{
|
||||
VSAPoint p(points.at(i));
|
||||
p.SetAngleType(PieceNodeAngle::ByLengthCurve);
|
||||
if (i == 0)
|
||||
{ // first point
|
||||
p.SetSAAfter(begin.GetSAAfter());
|
||||
|
@ -1175,7 +1176,7 @@ QVector<VSAPoint> VPiecePath::CurveSeamAllowanceSegment(const VContainer *data,
|
|||
|
||||
p.SetSAAfter(localWidth);
|
||||
p.SetSABefore(localWidth);
|
||||
// curve points have angle type by default
|
||||
p.SetAngleType(PieceNodeAngle::ByLengthCurve);
|
||||
}
|
||||
|
||||
pointsEkv.append(p);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user