Fix for method UniteWithContour.
--HG-- branch : feature
This commit is contained in:
parent
2355e435a5
commit
7970678575
|
@ -65,10 +65,13 @@ public:
|
|||
void setWidth(const qreal &value);
|
||||
|
||||
static QVector<QPointF> Equidistant(const QVector<QPointF> &points, const EquidistantType &eqv, qreal width);
|
||||
|
||||
protected:
|
||||
static QVector<QPointF> RemoveDublicates(const QVector<QPointF> &points);
|
||||
|
||||
private:
|
||||
QSharedDataPointer<VAbstractDetailData> d;
|
||||
|
||||
static QVector<QPointF> RemoveDublicates(const QVector<QPointF> &points);
|
||||
static QVector<QPointF> CorrectEquidistantPoints(const QVector<QPointF> &points);
|
||||
static QVector<QPointF> CheckLoops(const QVector<QPointF> &points);
|
||||
static QVector<QPointF> EkvPoint(const QLineF &line1, const QLineF &line2, const qreal &width);
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ void VLayoutDetail::SetCountourPoints(const QVector<QPointF> &points)
|
|||
d->contour.removeLast();
|
||||
}
|
||||
|
||||
d->contour = RoundPoints(d->contour);
|
||||
d->contour = RemoveDublicates(RoundPoints(d->contour));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -94,7 +94,7 @@ void VLayoutDetail::SetSeamAllowencePoints(const QVector<QPointF> &points)
|
|||
d->seamAllowence.removeLast();
|
||||
}
|
||||
|
||||
d->seamAllowence = RoundPoints(d->seamAllowence);
|
||||
d->seamAllowence = RemoveDublicates(RoundPoints(d->seamAllowence));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -245,7 +245,8 @@ QRectF VLayoutDetail::BoundingRect() const
|
|||
{
|
||||
QVector<QPointF> points = GetLayoutAllowencePoints();
|
||||
points.append(points.first());
|
||||
return QPolygonF(points).boundingRect();
|
||||
QRectF rec = QPolygonF(points).boundingRect();
|
||||
return rec;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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<qint64>(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<qint64>(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<QPointF> newGContour = UniteWithContour(workDetail, j, dEdge);
|
||||
newGContour.append(newGContour.first());
|
||||
const QRectF rec = QPolygonF(newGContour).boundingRect();
|
||||
bestResult.NewResult(static_cast<qint64>(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<QPointF> 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));
|
||||
|
|
Loading…
Reference in New Issue
Block a user