New class VRawSAPoint.

Post processing a seam allowance.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-11-03 10:01:32 +02:00
parent 7f5ec1c9a1
commit c924a6f700
6 changed files with 244 additions and 64 deletions

View File

@ -36,6 +36,7 @@
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/calculator.h" #include "../vpatterndb/calculator.h"
#include "testpath.h" #include "testpath.h"
#include "vrawsapoint.h"
#include <QLineF> #include <QLineF>
#include <QSet> #include <QSet>
@ -81,9 +82,9 @@ Q_DECL_CONSTEXPR qreal PointPosition(const QPointF &p, const QLineF &line)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> AngleByLength(QVector<QPointF> points, QPointF p1, QPointF p2, QPointF p3, const QLineF &bigLine1, QVector<VRawSAPoint> AngleByLength(QVector<VRawSAPoint> points, QPointF p1, QPointF p2, QPointF p3,
QPointF sp2, const QLineF &bigLine2, const VSAPoint &p, qreal width, const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2, const VSAPoint &p,
bool *needRollback = nullptr) qreal width, bool *needRollback = nullptr)
{ {
if (needRollback != nullptr) if (needRollback != nullptr)
{ {
@ -151,7 +152,7 @@ QVector<QPointF> AngleByLength(QVector<QPointF> points, QPointF p1, QPointF p2,
if (p.GetAngleType() != PieceNodeAngle::ByLengthCurve) if (p.GetAngleType() != PieceNodeAngle::ByLengthCurve)
{ {
bool success = false; bool success = false;
QVector<QPointF> temp = points; QVector<VRawSAPoint> temp = points;
temp.append(bigLine1.p2()); temp.append(bigLine1.p2());
temp = VAbstractPiece::RollbackSeamAllowance(temp, bigLine2, &success); temp = VAbstractPiece::RollbackSeamAllowance(temp, bigLine2, &success);
@ -196,7 +197,7 @@ QVector<QPointF> AngleByLength(QVector<QPointF> points, QPointF p1, QPointF p2,
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> AngleByIntersection(const QVector<QPointF> &points, QPointF p1, QPointF p2, QPointF p3, QVector<VRawSAPoint> AngleByIntersection(const QVector<VRawSAPoint> &points, QPointF p1, QPointF p2, QPointF p3,
const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2, const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2,
const VSAPoint &p, qreal width, bool *needRollback = nullptr) const VSAPoint &p, qreal width, bool *needRollback = nullptr)
{ {
@ -217,7 +218,7 @@ QVector<QPointF> AngleByIntersection(const QVector<QPointF> &points, QPointF p1,
} }
const qreal localWidth = p.MaxLocalSA(width); const qreal localWidth = p.MaxLocalSA(width);
QVector<QPointF> pointsIntr = points; QVector<VRawSAPoint> pointsIntr = points;
// First point // First point
QLineF edge2(p2, p3); QLineF edge2(p2, p3);
@ -240,7 +241,7 @@ QVector<QPointF> AngleByIntersection(const QVector<QPointF> &points, QPointF p1,
else else
{// Because artificial loop can lead to wrong clipping we must rollback current seam allowance points {// Because artificial loop can lead to wrong clipping we must rollback current seam allowance points
bool success = false; bool success = false;
QVector<QPointF> temp = pointsIntr; QVector<VRawSAPoint> temp = pointsIntr;
temp.append(bigLine1.p2()); temp.append(bigLine1.p2());
temp = VAbstractPiece::RollbackSeamAllowance(temp, edge2, &success); temp = VAbstractPiece::RollbackSeamAllowance(temp, edge2, &success);
@ -282,7 +283,7 @@ QVector<QPointF> AngleByIntersection(const QVector<QPointF> &points, QPointF p1,
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> AngleByFirstSymmetry(const QVector<QPointF> &points, QPointF p1, QPointF p2, QPointF p3, QVector<VRawSAPoint> AngleByFirstSymmetry(const QVector<VRawSAPoint> &points, QPointF p1, QPointF p2, QPointF p3,
const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2, const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2,
const VSAPoint &p, qreal width, bool *needRollback = nullptr) const VSAPoint &p, qreal width, bool *needRollback = nullptr)
{ {
@ -320,7 +321,7 @@ QVector<QPointF> AngleByFirstSymmetry(const QVector<QPointF> &points, QPointF p1
return AngleByLength(points, p1, p2, p3, bigLine1, sp2, bigLine2, p, width, needRollback); return AngleByLength(points, p1, p2, p3, bigLine1, sp2, bigLine2, p, width, needRollback);
} }
QVector<QPointF> pointsIntr = points; QVector<VRawSAPoint> pointsIntr = points;
if (IsOutsidePoint(bigLine1.p1(), bigLine1.p2(), px1)) if (IsOutsidePoint(bigLine1.p1(), bigLine1.p2(), px1))
{ {
@ -329,7 +330,7 @@ QVector<QPointF> AngleByFirstSymmetry(const QVector<QPointF> &points, QPointF p1
else else
{// Because artificial loop can lead to wrong clipping we must rollback current seam allowance points {// Because artificial loop can lead to wrong clipping we must rollback current seam allowance points
bool success = false; bool success = false;
QVector<QPointF> temp = pointsIntr; QVector<VRawSAPoint> temp = pointsIntr;
temp.append(bigLine1.p2()); temp.append(bigLine1.p2());
temp = VAbstractPiece::RollbackSeamAllowance(temp, sEdge, &success); temp = VAbstractPiece::RollbackSeamAllowance(temp, sEdge, &success);
@ -361,7 +362,7 @@ QVector<QPointF> AngleByFirstSymmetry(const QVector<QPointF> &points, QPointF p1
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> AngleBySecondSymmetry(const QVector<QPointF> &points, QPointF p1, QPointF p2, QPointF p3, QVector<VRawSAPoint> AngleBySecondSymmetry(const QVector<VRawSAPoint> &points, QPointF p1, QPointF p2, QPointF p3,
const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2, const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2,
const VSAPoint &p, qreal width, bool *needRollback = nullptr) const VSAPoint &p, qreal width, bool *needRollback = nullptr)
{ {
@ -400,7 +401,7 @@ QVector<QPointF> AngleBySecondSymmetry(const QVector<QPointF> &points, QPointF p
} }
const qreal localWidth = p.MaxLocalSA(width); const qreal localWidth = p.MaxLocalSA(width);
QVector<QPointF> pointsIntr = points; QVector<VRawSAPoint> pointsIntr = points;
if (IsOutsidePoint(bigLine1.p1(), bigLine1.p2(), px1)) if (IsOutsidePoint(bigLine1.p1(), bigLine1.p2(), px1))
{ {
@ -409,7 +410,7 @@ QVector<QPointF> AngleBySecondSymmetry(const QVector<QPointF> &points, QPointF p
else else
{// Because artificial loop can lead to wrong clipping we must rollback current seam allowance points {// Because artificial loop can lead to wrong clipping we must rollback current seam allowance points
bool success = false; bool success = false;
QVector<QPointF> temp = pointsIntr; QVector<VRawSAPoint> temp = pointsIntr;
temp.append(bigLine1.p2()); temp.append(bigLine1.p2());
temp = VAbstractPiece::RollbackSeamAllowance(temp, sEdge, &success); temp = VAbstractPiece::RollbackSeamAllowance(temp, sEdge, &success);
@ -442,7 +443,7 @@ QVector<QPointF> AngleBySecondSymmetry(const QVector<QPointF> &points, QPointF p
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> AngleByFirstRightAngle(const QVector<QPointF> &points, QPointF p1, QPointF p2, QPointF p3, QVector<VRawSAPoint> AngleByFirstRightAngle(const QVector<VRawSAPoint> &points, QPointF p1, QPointF p2, QPointF p3,
const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2, const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2,
const VSAPoint &p, qreal width, bool *needRollback = nullptr) const VSAPoint &p, qreal width, bool *needRollback = nullptr)
{ {
@ -458,7 +459,7 @@ QVector<QPointF> AngleByFirstRightAngle(const QVector<QPointF> &points, QPointF
} }
const qreal localWidth = p.MaxLocalSA(width); const qreal localWidth = p.MaxLocalSA(width);
QVector<QPointF> pointsRA = points; QVector<VRawSAPoint> pointsRA = points;
QLineF edge(p1, p2); QLineF edge(p1, p2);
QPointF px; QPointF px;
@ -511,7 +512,7 @@ QVector<QPointF> AngleByFirstRightAngle(const QVector<QPointF> &points, QPointF
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> AngleBySecondRightAngle(QVector<QPointF> points, QPointF p1, QPointF p2, QPointF p3, QVector<VRawSAPoint> AngleBySecondRightAngle(QVector<VRawSAPoint> points, QPointF p1, QPointF p2, QPointF p3,
const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2, const QLineF &bigLine1, QPointF sp2, const QLineF &bigLine2,
const VSAPoint &p, qreal width, bool *needRollback = nullptr) const VSAPoint &p, qreal width, bool *needRollback = nullptr)
{ {
@ -574,7 +575,7 @@ QVector<QPointF> AngleBySecondRightAngle(QVector<QPointF> points, QPointF p1, QP
// Because artificial loop can lead to wrong clipping we must rollback current seam allowance points // Because artificial loop can lead to wrong clipping we must rollback current seam allowance points
bool success = false; bool success = false;
const int countBefore = points.size(); const int countBefore = points.size();
QVector<QPointF> temp = points; QVector<VRawSAPoint> temp = points;
temp.append(bigLine1.p2()); temp.append(bigLine1.p2());
temp = VAbstractPiece::RollbackSeamAllowance(temp, edge, &success); temp = VAbstractPiece::RollbackSeamAllowance(temp, edge, &success);
@ -708,7 +709,7 @@ QVector<T> CorrectPathDistortion(QVector<T> path)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool Rollback(QVector<QPointF> &points, const QLineF &edge) bool Rollback(QVector<VRawSAPoint> &points, const QLineF &edge)
{ {
bool success = false; bool success = false;
if (not points.isEmpty()) if (not points.isEmpty())
@ -728,11 +729,11 @@ bool Rollback(QVector<QPointF> &points, const QLineF &edge)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void RollbackByLength(QVector<QPointF> &ekvPoints, const QVector<VSAPoint> &points, qreal width) void RollbackByLength(QVector<VRawSAPoint> &ekvPoints, const QVector<VSAPoint> &points, qreal width)
{ {
const QLineF bigLine1 = VAbstractPiece::ParallelLine(points.at(points.size()-2), points.at(0), width); const QLineF bigLine1 = VAbstractPiece::ParallelLine(points.at(points.size()-2), points.at(0), width);
QVector<QPointF> temp = ekvPoints; QVector<VRawSAPoint> temp = ekvPoints;
temp.insert(ekvPoints.size()-1, bigLine1.p2()); temp.insert(ekvPoints.size()-1, bigLine1.p2());
bool success = Rollback(temp, VAbstractPiece::ParallelLine(points.at(0), points.at(1), width)); bool success = Rollback(temp, VAbstractPiece::ParallelLine(points.at(0), points.at(1), width));
@ -743,13 +744,13 @@ void RollbackByLength(QVector<QPointF> &ekvPoints, const QVector<VSAPoint> &poin
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void RollbackBySecondEdgeSymmetry(QVector<QPointF> &ekvPoints, const QVector<VSAPoint> &points, qreal width) void RollbackBySecondEdgeSymmetry(QVector<VRawSAPoint> &ekvPoints, const QVector<VSAPoint> &points, qreal width)
{ {
const QLineF axis = QLineF(points.at(points.size()-1), points.at(1)); const QLineF axis = QLineF(points.at(points.size()-1), points.at(1));
const QLineF bigLine1 = VAbstractPiece::ParallelLine(points.at(points.size()-2), points.at(0), width); const QLineF bigLine1 = VAbstractPiece::ParallelLine(points.at(points.size()-2), points.at(0), width);
QLineF sEdge(VPointF::FlipPF(axis, bigLine1.p1()), VPointF::FlipPF(axis, bigLine1.p2())); QLineF sEdge(VPointF::FlipPF(axis, bigLine1.p1()), VPointF::FlipPF(axis, bigLine1.p2()));
QVector<QPointF> temp = ekvPoints; QVector<VRawSAPoint> temp = ekvPoints;
temp.insert(ekvPoints.size()-1, bigLine1.p2()); temp.insert(ekvPoints.size()-1, bigLine1.p2());
bool success = Rollback(temp, sEdge); bool success = Rollback(temp, sEdge);
@ -760,14 +761,14 @@ void RollbackBySecondEdgeSymmetry(QVector<QPointF> &ekvPoints, const QVector<VSA
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void RollbackByFirstEdgeSymmetry(QVector<QPointF> &ekvPoints, const QVector<VSAPoint> &points, qreal width) void RollbackByFirstEdgeSymmetry(QVector<VRawSAPoint> &ekvPoints, const QVector<VSAPoint> &points, qreal width)
{ {
const QLineF axis = QLineF(points.at(points.size()-2), points.at(points.size()-1)); const QLineF axis = QLineF(points.at(points.size()-2), points.at(points.size()-1));
const QLineF bigLine2 = VAbstractPiece::ParallelLine(points.at(points.size()-1), points.at(1), width); const QLineF bigLine2 = VAbstractPiece::ParallelLine(points.at(points.size()-1), points.at(1), width);
QLineF sEdge(VPointF::FlipPF(axis, bigLine2.p1()), VPointF::FlipPF(axis, bigLine2.p2())); QLineF sEdge(VPointF::FlipPF(axis, bigLine2.p1()), VPointF::FlipPF(axis, bigLine2.p2()));
const QLineF bigLine1 = VAbstractPiece::ParallelLine(points.at(points.size()-2), points.at(0), width); const QLineF bigLine1 = VAbstractPiece::ParallelLine(points.at(points.size()-2), points.at(0), width);
QVector<QPointF> temp = ekvPoints; QVector<VRawSAPoint> temp = ekvPoints;
temp.insert(ekvPoints.size()-1, bigLine1.p2()); temp.insert(ekvPoints.size()-1, bigLine1.p2());
bool success = Rollback(temp, sEdge); bool success = Rollback(temp, sEdge);
@ -778,10 +779,10 @@ void RollbackByFirstEdgeSymmetry(QVector<QPointF> &ekvPoints, const QVector<VSAP
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void RollbackByPointsIntersection(QVector<QPointF> &ekvPoints, const QVector<VSAPoint> &points, qreal width) void RollbackByPointsIntersection(QVector<VRawSAPoint> &ekvPoints, const QVector<VSAPoint> &points, qreal width)
{ {
const QLineF bigLine1 = VAbstractPiece::ParallelLine(points.at(points.size()-2), points.at(0), width); const QLineF bigLine1 = VAbstractPiece::ParallelLine(points.at(points.size()-2), points.at(0), width);
QVector<QPointF> temp = ekvPoints; QVector<VRawSAPoint> temp = ekvPoints;
temp.insert(ekvPoints.size()-1, bigLine1.p2()); temp.insert(ekvPoints.size()-1, bigLine1.p2());
bool success = Rollback(temp, QLineF(points.last(), points.at(1))); bool success = Rollback(temp, QLineF(points.last(), points.at(1)));
@ -798,7 +799,7 @@ void RollbackByPointsIntersection(QVector<QPointF> &ekvPoints, const QVector<VSA
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void RollbackBySecondEdgeRightAngle(QVector<QPointF> &ekvPoints, const QVector<VSAPoint> &points, qreal width) void RollbackBySecondEdgeRightAngle(QVector<VRawSAPoint> &ekvPoints, const QVector<VSAPoint> &points, qreal width)
{ {
if (not ekvPoints.isEmpty()) if (not ekvPoints.isEmpty())
{ {
@ -831,7 +832,7 @@ void RollbackBySecondEdgeRightAngle(QVector<QPointF> &ekvPoints, const QVector<V
else else
{ {
bool success = false; bool success = false;
QVector<QPointF> temp = ekvPoints; QVector<VRawSAPoint> temp = ekvPoints;
temp.insert(ekvPoints.size()-1, bigLine1.p2()); temp.insert(ekvPoints.size()-1, bigLine1.p2());
temp = VAbstractPiece::RollbackSeamAllowance(temp, edge, &success); temp = VAbstractPiece::RollbackSeamAllowance(temp, edge, &success);
@ -861,6 +862,22 @@ void RollbackBySecondEdgeRightAngle(QVector<QPointF> &ekvPoints, const QVector<V
} }
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> CleanLoopArtifacts(const QVector<VRawSAPoint> &points)
{
QVector<QPointF> cleaned;
cleaned.reserve(points.size());
for (auto &point : points)
{
if (not point.LoopPoint())
{
cleaned.append(point);
}
}
return cleaned;
}
} }
// Friend functions // Friend functions
@ -1027,7 +1044,7 @@ QVector<QPointF> VAbstractPiece::Equidistant(QVector<VSAPoint> points, qreal wid
} }
bool needRollback = false; // no need for rollback bool needRollback = false; // no need for rollback
QVector<QPointF> ekvPoints; QVector<VRawSAPoint> ekvPoints;
for (qint32 i = 0; i < points.size(); ++i ) for (qint32 i = 0; i < points.size(); ++i )
{ {
if ( i == 0) if ( i == 0)
@ -1081,12 +1098,21 @@ QVector<QPointF> VAbstractPiece::Equidistant(QVector<VSAPoint> points, qreal wid
QT_WARNING_POP QT_WARNING_POP
} }
// Uncomment for debug
// QVector<QPointF> cleaned;
// cleaned.reserve(ekvPoints.size());
// for (auto &point : ekvPoints)
// {
// cleaned.append(point);
// }
const bool removeFirstAndLast = false; const bool removeFirstAndLast = false;
ekvPoints = CheckLoops(RemoveDublicates(ekvPoints, removeFirstAndLast));//Result path can contain loops ekvPoints = RemoveDublicates(ekvPoints, removeFirstAndLast);
ekvPoints = CorrectEquidistantPoints(ekvPoints, removeFirstAndLast); QVector<QPointF> cleaned = CheckLoops(ekvPoints);//Result path can contain loops
ekvPoints = CorrectPathDistortion(ekvPoints); cleaned = CorrectEquidistantPoints(cleaned, removeFirstAndLast);
// DumpVector(ekvPoints, QStringLiteral("output.json.XXXXXX")); // Uncomment for dumping test data cleaned = CorrectPathDistortion(cleaned);
return ekvPoints; // DumpVector(cleaned, QStringLiteral("output.json.XXXXXX")); // Uncomment for dumping test data
return cleaned;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -1125,13 +1151,26 @@ qreal VAbstractPiece::SumTrapezoids(const QVector<QPointF> &points)
return res; return res;
} }
//---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VAbstractPiece::CheckLoops(const QVector<QPointF> &points)
{
QVector<VRawSAPoint> rawPath;
rawPath.reserve(points.size());
for (auto &point : points)
{
rawPath.append(point);
}
return CheckLoops(rawPath);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief CheckLoops seek and delete loops in equidistant. * @brief CheckLoops seek and delete loops in equidistant.
* @param points vector of points of equidistant. * @param points vector of points of equidistant.
* @return vector of points of equidistant. * @return vector of points of equidistant.
*/ */
QVector<QPointF> VAbstractPiece::CheckLoops(const QVector<QPointF> &points) QVector<QPointF> VAbstractPiece::CheckLoops(const QVector<VRawSAPoint> &points)
{ {
// DumpVector(points); // Uncomment for dumping test data // DumpVector(points); // Uncomment for dumping test data
@ -1139,12 +1178,12 @@ QVector<QPointF> VAbstractPiece::CheckLoops(const QVector<QPointF> &points)
/*If we got less than 4 points no need seek loops.*/ /*If we got less than 4 points no need seek loops.*/
if (count < 4) if (count < 4)
{ {
return points; return CleanLoopArtifacts(points);
} }
const bool pathClosed = (points.first() == points.last()); const bool pathClosed = (points.first() == points.last());
QVector<QPointF> ekvPoints; QVector<VRawSAPoint> ekvPoints;
ekvPoints.reserve(points.size()); ekvPoints.reserve(points.size());
QVector<qint32> uniqueVertices; QVector<qint32> uniqueVertices;
@ -1238,8 +1277,9 @@ QVector<QPointF> VAbstractPiece::CheckLoops(const QVector<QPointF> &points)
break; break;
} }
} }
// DumpVector(ekvPoints); // Uncomment for dumping test data const QVector<QPointF> cleaned = CleanLoopArtifacts(ekvPoints);
return ekvPoints; // DumpVector(cleaned); // Uncomment for dumping test data
return cleaned;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -1249,13 +1289,13 @@ 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<VRawSAPoint> VAbstractPiece::EkvPoint(QVector<VRawSAPoint> points, const VSAPoint &p1Line1,
const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width, const VSAPoint &p2Line1, const VSAPoint &p1Line2, const VSAPoint &p2Line2,
bool *needRollback) qreal width, bool *needRollback)
{ {
if (width < 0) if (width < 0)
{ // width can't be < 0 { // width can't be < 0
return QVector<QPointF>(); return QVector<VRawSAPoint>();
} }
width = qMax(width, VSAPoint::minSAWidth); width = qMax(width, VSAPoint::minSAWidth);
@ -1263,7 +1303,7 @@ QVector<QPointF> VAbstractPiece::EkvPoint(QVector<QPointF> points, const VSAPoin
if (p2Line1 != p2Line2) if (p2Line1 != p2Line2)
{ {
qDebug()<<"Last points of two lines must be equal."; qDebug()<<"Last points of two lines must be equal.";
return QVector<QPointF>(); // Wrong edges return QVector<VRawSAPoint>(); // Wrong edges
} }
const QLineF bigLine1 = ParallelLine(p1Line1, p2Line1, width ); const QLineF bigLine1 = ParallelLine(p1Line1, p2Line1, width );
@ -1629,11 +1669,11 @@ QJsonObject VSAPoint::toJson() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
// Because artificial loop can lead to wrong clipping we must rollback current seam allowance points // Because artificial loop can lead to wrong clipping we must rollback current seam allowance points
QVector<QPointF> VAbstractPiece::RollbackSeamAllowance(QVector<QPointF> points, const QLineF &cuttingEdge, QVector<VRawSAPoint> VAbstractPiece::RollbackSeamAllowance(QVector<VRawSAPoint> points, const QLineF &cuttingEdge,
bool *success) bool *success)
{ {
*success = false; *success = false;
QVector<QPointF> clipped; QVector<VRawSAPoint> clipped;
clipped.reserve(points.count()+1); clipped.reserve(points.count()+1);
for (int i = points.count()-1; i > 0; --i) for (int i = points.count()-1; i > 0; --i)
{ {

View File

@ -45,6 +45,7 @@ class VAbstractPieceData;
class QPainterPath; class QPainterPath;
class VGrainlineData; class VGrainlineData;
class VContainer; class VContainer;
class VRawSAPoint;
class VAbstractPiece class VAbstractPiece
{ {
@ -95,7 +96,8 @@ public:
static QVector<QPointF> Equidistant(QVector<VSAPoint> points, qreal width, const QString &name); static QVector<QPointF> Equidistant(QVector<VSAPoint> points, qreal width, const QString &name);
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> CheckLoops(const QVector<VRawSAPoint> &points);
static QVector<VRawSAPoint> EkvPoint(QVector<VRawSAPoint> points, const VSAPoint &p1Line1, const VSAPoint &p2Line1,
const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width, const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width,
bool *needRollback = nullptr); bool *needRollback = nullptr);
static QLineF ParallelLine(const VSAPoint &p1, const VSAPoint &p2, qreal width); static QLineF ParallelLine(const VSAPoint &p1, const VSAPoint &p2, qreal width);
@ -104,7 +106,8 @@ public:
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);
static QVector<QPointF> RollbackSeamAllowance(QVector<QPointF> points, const QLineF &cuttingEdge, bool *success); static QVector<VRawSAPoint> RollbackSeamAllowance(QVector<VRawSAPoint> points, const QLineF &cuttingEdge,
bool *success);
static QVector<QPointF> GrainlinePoints(const VGrainlineData &geom, const VContainer *pattern, static QVector<QPointF> GrainlinePoints(const VGrainlineData &geom, const VContainer *pattern,
const QRectF &boundingRect, qreal &dAng); const QRectF &boundingRect, qreal &dAng);

View File

@ -23,7 +23,8 @@ HEADERS += \
$$PWD/vlayoutpiece_p.h \ $$PWD/vlayoutpiece_p.h \
$$PWD/vlayoutpiecepath.h \ $$PWD/vlayoutpiecepath.h \
$$PWD/vlayoutpiecepath_p.h \ $$PWD/vlayoutpiecepath_p.h \
$$PWD/vbestsquare_p.h $$PWD/vbestsquare_p.h \
$$PWD/vrawsapoint.h
SOURCES += \ SOURCES += \
$$PWD/testpath.cpp \ $$PWD/testpath.cpp \
@ -38,6 +39,7 @@ SOURCES += \
$$PWD/vgraphicsfillitem.cpp \ $$PWD/vgraphicsfillitem.cpp \
$$PWD/vabstractpiece.cpp \ $$PWD/vabstractpiece.cpp \
$$PWD/vlayoutpiece.cpp \ $$PWD/vlayoutpiece.cpp \
$$PWD/vlayoutpiecepath.cpp $$PWD/vlayoutpiecepath.cpp \
$$PWD/vrawsapoint.cpp
*msvc*:SOURCES += $$PWD/stable.cpp *msvc*:SOURCES += $$PWD/stable.cpp

View File

@ -0,0 +1,44 @@
/************************************************************************
**
** @file vrawsapoint.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 31 10, 2019
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2019 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vrawsapoint.h"
#include <QJsonObject>
//---------------------------------------------------------------------------------------------------------------------
QJsonObject VRawSAPoint::toJson() const
{
QJsonObject pointObject;
pointObject[QLatin1String("type")] = "VRawSAPoint";
pointObject[QLatin1String("x")] = x();
pointObject[QLatin1String("y")] = y();
pointObject[QLatin1String("loopPoint")] = m_loopPoint;
return pointObject;
}

View File

@ -0,0 +1,90 @@
/************************************************************************
**
** @file vrawsapoint.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 31 10, 2019
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2019 Valentina project
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VRAWSAPOINT_H
#define VRAWSAPOINT_H
#include <QPointF>
#include "../vmisc/diagnostic.h"
#include "../vmisc/def.h"
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Weffc++")
QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
class VRawSAPoint : public QPointF
{
public:
Q_DECL_CONSTEXPR VRawSAPoint();
Q_DECL_CONSTEXPR VRawSAPoint(qreal xpos, qreal ypos);
Q_DECL_CONSTEXPR VRawSAPoint(QPointF p);
Q_DECL_CONSTEXPR bool LoopPoint() const;
Q_DECL_CONSTEXPR void SetLoopPoint(bool loopPoint);
QJsonObject toJson() const;
private:
bool m_loopPoint{false};
};
Q_DECLARE_METATYPE(VRawSAPoint)
Q_DECLARE_TYPEINFO(VRawSAPoint, Q_MOVABLE_TYPE);
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VRawSAPoint::VRawSAPoint()
{}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VRawSAPoint::VRawSAPoint(qreal xpos, qreal ypos)
: QPointF(xpos, ypos)
{}
//---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress passedByValue
Q_DECL_CONSTEXPR inline VRawSAPoint::VRawSAPoint(QPointF p)
: QPointF(p)
{
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline bool VRawSAPoint::LoopPoint() const
{
return m_loopPoint;
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline void VRawSAPoint::SetLoopPoint(bool loopPoint)
{
m_loopPoint = loopPoint;
}
QT_WARNING_POP
#endif // VRAWSAPOINT_H

View File

@ -32,6 +32,7 @@
#include "../vgeometry/vabstractcurve.h" #include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/varc.h" #include "../vgeometry/varc.h"
#include "testpassmark.h" #include "testpassmark.h"
#include "../vlayout/vrawsapoint.h"
const qreal VPassmark::passmarkRadiusFactor = 0.45; const qreal VPassmark::passmarkRadiusFactor = 0.45;
@ -42,7 +43,7 @@ PassmarkStatus GetSeamPassmarkSAPoint(const VPiecePassmarkData &passmarkData, co
QPointF &point) QPointF &point)
{ {
bool needRollback = false; // no need for rollback bool needRollback = false; // no need for rollback
QVector<QPointF> ekvPoints; QVector<VRawSAPoint> ekvPoints;
ekvPoints = VAbstractPiece::EkvPoint(ekvPoints, passmarkData.previousSAPoint, passmarkData.passmarkSAPoint, ekvPoints = VAbstractPiece::EkvPoint(ekvPoints, passmarkData.previousSAPoint, passmarkData.passmarkSAPoint,
passmarkData.nextSAPoint, passmarkData.passmarkSAPoint, passmarkData.saWidth, passmarkData.nextSAPoint, passmarkData.passmarkSAPoint, passmarkData.saWidth,
&needRollback); &needRollback);