diff --git a/src/libs/vlayout/vabstractdetail.h b/src/libs/vlayout/vabstractdetail.h index f5c08f256..e6958c121 100644 --- a/src/libs/vlayout/vabstractdetail.h +++ b/src/libs/vlayout/vabstractdetail.h @@ -65,10 +65,13 @@ public: void setWidth(const qreal &value); static QVector Equidistant(const QVector &points, const EquidistantType &eqv, qreal width); + +protected: + static QVector RemoveDublicates(const QVector &points); + private: QSharedDataPointer d; - static QVector RemoveDublicates(const QVector &points); static QVector CorrectEquidistantPoints(const QVector &points); static QVector CheckLoops(const QVector &points); static QVector EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width); diff --git a/src/libs/vlayout/vlayoutdef.h b/src/libs/vlayout/vlayoutdef.h index e3307584e..a69675862 100644 --- a/src/libs/vlayout/vlayoutdef.h +++ b/src/libs/vlayout/vlayoutdef.h @@ -50,6 +50,7 @@ enum class LayoutErrors : char //# define SHOW_ROTATION //# define SHOW_COMBINE //# define SHOW_MIRROR +//# define SHOW_CANDIDATE_BEST # define SHOW_BEST #endif//LAYOUT_DEBUG diff --git a/src/libs/vlayout/vlayoutdetail.cpp b/src/libs/vlayout/vlayoutdetail.cpp index 965f6ade4..d440ba452 100644 --- a/src/libs/vlayout/vlayoutdetail.cpp +++ b/src/libs/vlayout/vlayoutdetail.cpp @@ -75,7 +75,7 @@ void VLayoutDetail::SetCountourPoints(const QVector &points) d->contour.removeLast(); } - d->contour = RoundPoints(d->contour); + d->contour = RemoveDublicates(RoundPoints(d->contour)); } //--------------------------------------------------------------------------------------------------------------------- @@ -94,7 +94,7 @@ void VLayoutDetail::SetSeamAllowencePoints(const QVector &points) d->seamAllowence.removeLast(); } - d->seamAllowence = RoundPoints(d->seamAllowence); + d->seamAllowence = RemoveDublicates(RoundPoints(d->seamAllowence)); } //--------------------------------------------------------------------------------------------------------------------- @@ -245,7 +245,8 @@ QRectF VLayoutDetail::BoundingRect() const { QVector points = GetLayoutAllowencePoints(); points.append(points.first()); - return QPolygonF(points).boundingRect(); + QRectF rec = QPolygonF(points).boundingRect(); + return rec; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vlayout/vlayoutpaper.cpp b/src/libs/vlayout/vlayoutpaper.cpp index c79bf7939..fc3936517 100644 --- a/src/libs/vlayout/vlayoutpaper.cpp +++ b/src/libs/vlayout/vlayoutpaper.cpp @@ -260,11 +260,18 @@ bool VLayoutPaper::AddToBlankSheet(const VLayoutDetail &detail, bool &stop) int dEdge = i;// For mirrored detail edge will be different if (CheckCombineEdges(workDetail, j, dEdge)) { + #ifdef LAYOUT_DEBUG + # ifdef SHOW_CANDIDATE_BEST + DrawDebug(workDetail, d->frame+2); + + # endif + #endif + const QRectF rec = workDetail.BoundingRect(); bestResult.NewResult(static_cast(rec.width()*rec.height()), j, dEdge, workDetail.GetMatrix(), workDetail.IsMirror()); } - d->frame = d->frame + 2; + d->frame = d->frame + 3; for (int angle = 0; angle <= 360; angle = angle+20) { @@ -280,6 +287,13 @@ bool VLayoutPaper::AddToBlankSheet(const VLayoutDetail &detail, bool &stop) if (CheckRotationEdges(workDetail, j, i, angle)) { + #ifdef LAYOUT_DEBUG + # ifdef SHOW_CANDIDATE_BEST + ++d->frame; + DrawDebug(workDetail, d->frame); + # endif + #endif + const QRectF rec = workDetail.BoundingRect(); bestResult.NewResult(static_cast(rec.width()*rec.height()), j, i, workDetail.GetMatrix(), workDetail.IsMirror()); @@ -314,13 +328,19 @@ bool VLayoutPaper::AddToSheet(const VLayoutDetail &detail, bool &stop) int dEdge = i;// For mirror detail edge will be different if (CheckCombineEdges(workDetail, j, dEdge)) { + #ifdef LAYOUT_DEBUG + # ifdef SHOW_CANDIDATE_BEST + DrawDebug(workDetail, d->frame+2); + # endif + #endif + QVector newGContour = UniteWithContour(workDetail, j, dEdge); newGContour.append(newGContour.first()); const QRectF rec = QPolygonF(newGContour).boundingRect(); bestResult.NewResult(static_cast(rec.width()*rec.height()), j, dEdge, workDetail.GetMatrix(), workDetail.IsMirror()); } - d->frame = d->frame + 2; + d->frame = d->frame + 3; } } @@ -695,7 +715,7 @@ QVector VLayoutPaper::UniteWithContour(const VLayoutDetail &detail, int } ++processedEdges; ++j; - }while (processedEdges <= nD); + }while (processedEdges < nD); } else { @@ -911,7 +931,7 @@ void VLayoutPaper::DrawDebug(const VLayoutDetail &detail, int frame) const QPainter paint; paint.begin(&frameImage); - paint.setPen(QPen(Qt::darkRed, 3, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); + paint.setPen(QPen(Qt::darkRed, 10, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); paint.drawRect(QRectF(d->paperWidth/2, d->paperHeight/2, d->paperWidth, d->paperHeight)); paint.setPen(QPen(Qt::black, 3, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));