Refactring. MaxLocalSA can be part of VSAPoint class.
--HG-- branch : release
This commit is contained in:
parent
f57c98b7c3
commit
49506c0bf2
|
@ -212,7 +212,7 @@ QVector<QPointF> AngleByLength(QVector<QPointF> points, QPointF p2, const QLineF
|
||||||
{
|
{
|
||||||
const QPointF sp1 = bigLine1.p1();
|
const QPointF sp1 = bigLine1.p1();
|
||||||
const QPointF sp3 = bigLine2.p2();
|
const QPointF sp3 = bigLine2.p2();
|
||||||
const qreal localWidth = VAbstractPiece::MaxLocalSA(p, width);
|
const qreal localWidth = p.MaxLocalSA(width);
|
||||||
|
|
||||||
if (IsOutsidePoint(bigLine1.p1(), bigLine1.p2(), sp2) && IsOutsidePoint(bigLine2.p2(), bigLine2.p1(), sp2) )
|
if (IsOutsidePoint(bigLine1.p1(), bigLine1.p2(), sp2) && IsOutsidePoint(bigLine2.p2(), bigLine2.p1(), sp2) )
|
||||||
{
|
{
|
||||||
|
@ -282,7 +282,7 @@ QVector<QPointF> AngleByIntersection(const QVector<QPointF> &points, QPointF p1,
|
||||||
const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2,
|
const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2,
|
||||||
const VSAPoint &p, qreal width)
|
const VSAPoint &p, qreal width)
|
||||||
{
|
{
|
||||||
const qreal localWidth = VAbstractPiece::MaxLocalSA(p, width);
|
const qreal localWidth = p.MaxLocalSA(width);
|
||||||
QVector<QPointF> pointsIntr = points;
|
QVector<QPointF> pointsIntr = points;
|
||||||
|
|
||||||
// First point
|
// First point
|
||||||
|
@ -345,7 +345,7 @@ QVector<QPointF> AngleByFirstSymmetry(const QVector<QPointF> &points, QPointF p1
|
||||||
const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2,
|
const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2,
|
||||||
const VSAPoint &p, qreal width)
|
const VSAPoint &p, qreal width)
|
||||||
{
|
{
|
||||||
const qreal localWidth = VAbstractPiece::MaxLocalSA(p, width);
|
const qreal localWidth = p.MaxLocalSA(width);
|
||||||
QVector<QPointF> pointsIntr = points;
|
QVector<QPointF> pointsIntr = points;
|
||||||
|
|
||||||
QLineF sEdge(VPointF::FlipPF(bigLine2, p1), VPointF::FlipPF(bigLine2, p2));
|
QLineF sEdge(VPointF::FlipPF(bigLine2, p1), VPointF::FlipPF(bigLine2, p2));
|
||||||
|
@ -407,7 +407,7 @@ QVector<QPointF> AngleBySecondSymmetry(const QVector<QPointF> &points, QPointF p
|
||||||
const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2,
|
const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2,
|
||||||
const VSAPoint &p, qreal width)
|
const VSAPoint &p, qreal width)
|
||||||
{
|
{
|
||||||
const qreal localWidth = VAbstractPiece::MaxLocalSA(p, width);
|
const qreal localWidth = p.MaxLocalSA(width);
|
||||||
QVector<QPointF> pointsIntr = points;
|
QVector<QPointF> pointsIntr = points;
|
||||||
|
|
||||||
QLineF sEdge(VPointF::FlipPF(bigLine1, p2), VPointF::FlipPF(bigLine1, p3));
|
QLineF sEdge(VPointF::FlipPF(bigLine1, p2), VPointF::FlipPF(bigLine1, p3));
|
||||||
|
@ -471,7 +471,7 @@ QVector<QPointF> AngleByFirstRightAngle(const QVector<QPointF> &points, QPointF
|
||||||
const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2,
|
const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2,
|
||||||
const VSAPoint &p, qreal width)
|
const VSAPoint &p, qreal width)
|
||||||
{
|
{
|
||||||
const qreal localWidth = VAbstractPiece::MaxLocalSA(p, width);
|
const qreal localWidth = p.MaxLocalSA(width);
|
||||||
QVector<QPointF> pointsRA = points;
|
QVector<QPointF> pointsRA = points;
|
||||||
QLineF edge(p1, p2);
|
QLineF edge(p1, p2);
|
||||||
|
|
||||||
|
@ -517,7 +517,7 @@ QVector<QPointF> AngleBySecondRightAngle(QVector<QPointF> points, QPointF p2, QP
|
||||||
const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2,
|
const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2,
|
||||||
const VSAPoint &p, qreal width)
|
const VSAPoint &p, qreal width)
|
||||||
{
|
{
|
||||||
const qreal localWidth = VAbstractPiece::MaxLocalSA(p, width);
|
const qreal localWidth = p.MaxLocalSA(width);
|
||||||
QLineF edge(p2, p3);
|
QLineF edge(p2, p3);
|
||||||
|
|
||||||
QPointF px;
|
QPointF px;
|
||||||
|
@ -974,24 +974,6 @@ QVector<QPointF> VAbstractPiece::CheckLoops(const QVector<QPointF> &points)
|
||||||
return ekvPoints;
|
return ekvPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
qreal VAbstractPiece::MaxLocalSA(const VSAPoint &p, qreal width)
|
|
||||||
{
|
|
||||||
qreal w1 = p.GetSAAfter();
|
|
||||||
if (w1 < 0)
|
|
||||||
{
|
|
||||||
w1 = width;
|
|
||||||
}
|
|
||||||
|
|
||||||
qreal w2 = p.GetSABefore();
|
|
||||||
if (w2 < 0)
|
|
||||||
{
|
|
||||||
w2 = width;
|
|
||||||
}
|
|
||||||
|
|
||||||
return qMax(w1, w2);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief EkvPoint return seam aloowance points in place of intersection two edges. Last points of two edges should be
|
* @brief EkvPoint return seam aloowance points in place of intersection two edges. Last points of two edges should be
|
||||||
|
@ -1034,7 +1016,7 @@ QVector<QPointF> VAbstractPiece::EkvPoint(QVector<QPointF> points, const VSAPoin
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
const qreal localWidth = MaxLocalSA(p2Line1, width);
|
const qreal localWidth = p2Line1.MaxLocalSA(width);
|
||||||
QLineF line( p2Line1, crosPoint );
|
QLineF line( p2Line1, crosPoint );
|
||||||
|
|
||||||
// Checking two subcases
|
// Checking two subcases
|
||||||
|
@ -1234,3 +1216,21 @@ qreal VSAPoint::GetSAAfter(qreal width) const
|
||||||
}
|
}
|
||||||
return m_after;
|
return m_after;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
qreal VSAPoint::MaxLocalSA(qreal width) const
|
||||||
|
{
|
||||||
|
qreal w1 = GetSAAfter();
|
||||||
|
if (w1 < 0)
|
||||||
|
{
|
||||||
|
w1 = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal w2 = GetSABefore();
|
||||||
|
if (w2 < 0)
|
||||||
|
{
|
||||||
|
w2 = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
return qMax(w1, w2);
|
||||||
|
}
|
||||||
|
|
|
@ -68,6 +68,8 @@ public:
|
||||||
Q_DECL_CONSTEXPR PieceNodeAngle GetAngleType() const;
|
Q_DECL_CONSTEXPR PieceNodeAngle GetAngleType() const;
|
||||||
void SetAngleType(PieceNodeAngle value);
|
void SetAngleType(PieceNodeAngle value);
|
||||||
|
|
||||||
|
qreal MaxLocalSA(qreal width) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal m_before;
|
qreal m_before;
|
||||||
qreal m_after;
|
qreal m_after;
|
||||||
|
@ -187,7 +189,6 @@ public:
|
||||||
static QVector<QPointF> EkvPoint(QVector<QPointF> points, const VSAPoint &p1Line1, const VSAPoint &p2Line1,
|
static QVector<QPointF> EkvPoint(QVector<QPointF> points, const VSAPoint &p1Line1, const VSAPoint &p2Line1,
|
||||||
const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width);
|
const VSAPoint &p1Line2, const 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);
|
||||||
static qreal MaxLocalSA(const VSAPoint &p, qreal width);
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
static QVector<T> CorrectEquidistantPoints(const QVector<T> &points, bool removeFirstAndLast = true);
|
static QVector<T> CorrectEquidistantPoints(const QVector<T> &points, bool removeFirstAndLast = true);
|
||||||
|
|
|
@ -1112,7 +1112,7 @@ bool VPiece::GetSeamPassmarkSAPoint(const VSAPoint &previousSAPoint, const VSAPo
|
||||||
{
|
{
|
||||||
QLineF line (passmarkSAPoint, nextSAPoint);
|
QLineF line (passmarkSAPoint, nextSAPoint);
|
||||||
line.setAngle(line.angle() + 90);
|
line.setAngle(line.angle() + 90);
|
||||||
line.setLength(VAbstractPiece::MaxLocalSA(passmarkSAPoint, width));
|
line.setLength(passmarkSAPoint.MaxLocalSA(width));
|
||||||
ekvPoints.append(line.p2());
|
ekvPoints.append(line.p2());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1249,7 +1249,7 @@ QVector<QLineF> VPiece::SAPassmark(const QVector<VPieceNode> &path, VSAPoint &pr
|
||||||
|
|
||||||
QVector<QLineF> passmarksLines;
|
QVector<QLineF> passmarksLines;
|
||||||
|
|
||||||
qreal passmarkLength = VAbstractPiece::MaxLocalSA(passmarkSAPoint, width) * passmarkFactor;
|
qreal passmarkLength = passmarkSAPoint.MaxLocalSA(width) * passmarkFactor;
|
||||||
passmarkLength = qMin(passmarkLength, maxPassmarkLength);
|
passmarkLength = qMin(passmarkLength, maxPassmarkLength);
|
||||||
const VPieceNode &node = path.at(passmarkIndex);
|
const VPieceNode &node = path.at(passmarkIndex);
|
||||||
|
|
||||||
|
@ -1347,7 +1347,7 @@ QVector<QLineF> VPiece::BuiltInSAPassmark(const QVector<VPieceNode> &path, const
|
||||||
QVector<QLineF> passmarksLines;
|
QVector<QLineF> passmarksLines;
|
||||||
|
|
||||||
const qreal width = ToPixel(GetSAWidth(), *data->GetPatternUnit());
|
const qreal width = ToPixel(GetSAWidth(), *data->GetPatternUnit());
|
||||||
qreal passmarkLength = VAbstractPiece::MaxLocalSA(passmarkSAPoint, width) * passmarkFactor;
|
qreal passmarkLength = passmarkSAPoint.MaxLocalSA(width) * passmarkFactor;
|
||||||
passmarkLength = qMin(passmarkLength, maxPassmarkLength);
|
passmarkLength = qMin(passmarkLength, maxPassmarkLength);
|
||||||
|
|
||||||
QLineF edge1 = QLineF(passmarkSAPoint, previousSAPoint);
|
QLineF edge1 = QLineF(passmarkSAPoint, previousSAPoint);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user