From 8424222e7c7d03000a9aab1ec4c26af7b6f84301 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 11 Feb 2019 15:00:32 +0200 Subject: [PATCH] Introducing method UniteMainPathPoints. This method will be usefull if need return "invisible" path after including custom seam allowance as main path. --HG-- branch : develop --- src/libs/vpatterndb/vpiece.cpp | 8 +++ src/libs/vpatterndb/vpiece.h | 5 +- src/libs/vpatterndb/vpiecepath.cpp | 78 +++++++++++++++++------------- src/libs/vpatterndb/vpiecepath.h | 2 + 4 files changed, 57 insertions(+), 36 deletions(-) diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index bd5369667..fa8be8a85 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -424,6 +424,14 @@ QVector VPiece::MainPathPoints(const VContainer *data) const return points; } +//--------------------------------------------------------------------------------------------------------------------- +QVector VPiece::UniteMainPathPoints(const VContainer *data) const +{ + QVector points = VPiecePath::NodesToPoints(data, GetUnitedPath(data)); + points = CheckLoops(CorrectEquidistantPoints(points));//A path can contains loops + return points; +} + //--------------------------------------------------------------------------------------------------------------------- QVector VPiece::MainPathNodePoints(const VContainer *data, bool showExcluded) const { diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h index 6d0dbc6b7..a6ba94e7c 100644 --- a/src/libs/vpatterndb/vpiece.h +++ b/src/libs/vpatterndb/vpiece.h @@ -95,6 +95,7 @@ public: void SetPath(const VPiecePath &path); QVector MainPathPoints(const VContainer *data) const; + QVector UniteMainPathPoints(const VContainer *data) const; QVector MainPathNodePoints(const VContainer *data, bool showExcluded = false) const; QVector SeamAllowancePoints(const VContainer *data) const; QVector CuttingPathPoints(const VContainer *data) const; @@ -155,14 +156,14 @@ public: VGrainlineData& GetGrainlineGeometry(); const VGrainlineData& GetGrainlineGeometry() const; + QVector GetUnitedPath(const VContainer *data) const; + static QVector SAPassmark(const VPiecePassmarkData &passmarkData, const QVector &seamAllowance); protected: QVector SeamAllowancePointsWithRotation(const VContainer *data, int makeFirst) const; private: QSharedDataPointer d; - QVector GetUnitedPath(const VContainer *data) const; - QVector GetValidRecords() const; QVector FilterRecords(QVector records) const; diff --git a/src/libs/vpatterndb/vpiecepath.cpp b/src/libs/vpatterndb/vpiecepath.cpp index 436363526..e54a3d580 100644 --- a/src/libs/vpatterndb/vpiecepath.cpp +++ b/src/libs/vpatterndb/vpiecepath.cpp @@ -351,40 +351,7 @@ bool VPiecePath::IsLastToCuttingCountour() const //--------------------------------------------------------------------------------------------------------------------- QVector VPiecePath::PathPoints(const VContainer *data, const QVector &cuttingPath) const { - QVector points; - for (int i = 0; i < CountNodes(); ++i) - { - if (at(i).IsExcluded()) - { - continue;// skip excluded node - } - - switch (at(i).GetTypeTool()) - { - case (Tool::NodePoint): - { - const QSharedPointer point = data->GeometricObject(at(i).GetId()); - points.append(static_cast(*point)); - } - break; - case (Tool::NodeArc): - case (Tool::NodeElArc): - case (Tool::NodeSpline): - case (Tool::NodeSplinePath): - { - const QSharedPointer curve = data->GeometricObject(at(i).GetId()); - - const QPointF begin = StartSegment(data, i, at(i).GetReverse()); - const QPointF end = EndSegment(data, i, at(i).GetReverse()); - - points << curve->GetSegmentPoints(begin, end, at(i).GetReverse()); - } - break; - default: - qDebug()<<"Get wrong tool type. Ignore."<< static_cast(at(i).GetTypeTool()); - break; - } - } + QVector points = NodesToPoints(data, d->m_nodes); if (GetType() == PiecePathType::InternalPath && not cuttingPath.isEmpty() && points.size() > 1) { @@ -1205,3 +1172,46 @@ QString VPiecePath::NodeName(const QVector &nodes, int nodeIndex, co } return QString(); } + +//--------------------------------------------------------------------------------------------------------------------- +QVector VPiecePath::NodesToPoints(const VContainer *data, const QVector &nodes) +{ + QVector points; + for (int i = 0; i < nodes.size(); ++i) + { + const VPieceNode &node = nodes.at(i); + if (node.IsExcluded()) + { + continue;// skip excluded node + } + + switch (node.GetTypeTool()) + { + case (Tool::NodePoint): + { + const QSharedPointer point = data->GeometricObject(node.GetId()); + points.append(static_cast(*point)); + } + break; + case (Tool::NodeArc): + case (Tool::NodeElArc): + case (Tool::NodeSpline): + case (Tool::NodeSplinePath): + { + const QSharedPointer curve = data->GeometricObject(node.GetId()); + + + const QPointF begin = StartSegment(data, nodes, i, node.GetReverse()); + const QPointF end = EndSegment(data, nodes, i, node.GetReverse()); + + points << curve->GetSegmentPoints(begin, end, node.GetReverse()); + } + break; + default: + qDebug()<<"Get wrong tool type. Ignore."<< static_cast(node.GetTypeTool()); + break; + } + } + + return points; +} diff --git a/src/libs/vpatterndb/vpiecepath.h b/src/libs/vpatterndb/vpiecepath.h index efa8b3e80..ebd9cf212 100644 --- a/src/libs/vpatterndb/vpiecepath.h +++ b/src/libs/vpatterndb/vpiecepath.h @@ -139,6 +139,8 @@ public: static QString NodeName(const QVector &nodes, int nodeIndex, const VContainer *data); + static QVector NodesToPoints(const VContainer *data, const QVector &nodes); + private: QSharedDataPointer d; };