Refactoring. Move code in functions.
--HG-- branch : develop
This commit is contained in:
parent
1f462586cd
commit
e7bd65bde9
|
@ -144,15 +144,7 @@ QVector<QPointF> VContour::UniteWithContour(const VLayoutPiece &detail, int glob
|
||||||
return QVector<QPointF>();
|
return QVector<QPointF>();
|
||||||
}
|
}
|
||||||
|
|
||||||
int i2 = 0;
|
const int i2 = globalI == d->globalContour.count() ? 0 : globalI;
|
||||||
if (globalI == d->globalContour.count())
|
|
||||||
{
|
|
||||||
i2 = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
i2 = globalI;
|
|
||||||
}
|
|
||||||
|
|
||||||
int i=0;
|
int i=0;
|
||||||
while (i < d->globalContour.count())
|
while (i < d->globalContour.count())
|
||||||
|
@ -165,40 +157,11 @@ QVector<QPointF> VContour::UniteWithContour(const VLayoutPiece &detail, int glob
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int processedEdges = 0;
|
InsertDetail(newContour, detail, detJ);
|
||||||
const int nD = detail.LayoutEdgesCount();
|
|
||||||
int j = detJ+1;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (j > nD)
|
|
||||||
{
|
|
||||||
j=1;
|
|
||||||
}
|
|
||||||
if (j != detJ)
|
|
||||||
{
|
|
||||||
const QVector<QPointF> points = CutEdge(detail.LayoutEdge(j));
|
|
||||||
for (int i = 0; i < points.size()-1; ++i)
|
|
||||||
{
|
|
||||||
newContour.append(points.at(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
++processedEdges;
|
|
||||||
++j;
|
|
||||||
}while (processedEdges < nD);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not newContour.isEmpty())
|
AppendToContour(newContour, d->globalContour.at(i));
|
||||||
{
|
|
||||||
if (newContour.last() != d->globalContour.at(i))
|
|
||||||
{
|
|
||||||
newContour.append(d->globalContour.at(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
newContour.append(d->globalContour.at(i));
|
|
||||||
}
|
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,6 +299,22 @@ QPainterPath VContour::ContourPath() const
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VContour::AppendToContour(QVector<QPointF> &contour, QPointF point) const
|
||||||
|
{
|
||||||
|
if (not contour.isEmpty())
|
||||||
|
{
|
||||||
|
if (not VFuzzyComparePoints(contour.last(), point))
|
||||||
|
{
|
||||||
|
contour.append(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
contour.append(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VContour::AppendWhole(QVector<QPointF> &contour, const VLayoutPiece &detail, int detJ) const
|
void VContour::AppendWhole(QVector<QPointF> &contour, const VLayoutPiece &detail, int detJ) const
|
||||||
{
|
{
|
||||||
|
@ -358,6 +337,31 @@ void VContour::AppendWhole(QVector<QPointF> &contour, const VLayoutPiece &detail
|
||||||
}while (processedEdges < nD);
|
}while (processedEdges < nD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VContour::InsertDetail(QVector<QPointF> &contour, const VLayoutPiece &detail, int detJ) const
|
||||||
|
{
|
||||||
|
int processedEdges = 0;
|
||||||
|
const int nD = detail.LayoutEdgesCount();
|
||||||
|
int j = detJ+1;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (j > nD)
|
||||||
|
{
|
||||||
|
j=1;
|
||||||
|
}
|
||||||
|
if (j != detJ)
|
||||||
|
{
|
||||||
|
for(auto &point : CutEdge(detail.LayoutEdge(j)))
|
||||||
|
{
|
||||||
|
AppendToContour(contour, point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++processedEdges;
|
||||||
|
++j;
|
||||||
|
}
|
||||||
|
while (processedEdges < nD);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
bool VContour::IsPortrait() const
|
bool VContour::IsPortrait() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -94,7 +94,9 @@ public:
|
||||||
private:
|
private:
|
||||||
QSharedDataPointer<VContourData> d;
|
QSharedDataPointer<VContourData> d;
|
||||||
|
|
||||||
|
void AppendToContour(QVector<QPointF> &contour, QPointF point) const;
|
||||||
void AppendWhole(QVector<QPointF> &contour, const VLayoutPiece &detail, int detJ) const;
|
void AppendWhole(QVector<QPointF> &contour, const VLayoutPiece &detail, int detJ) const;
|
||||||
|
void InsertDetail(QVector<QPointF> &contour, const VLayoutPiece &detail, int detJ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_TYPEINFO(VContour, Q_MOVABLE_TYPE);
|
Q_DECLARE_TYPEINFO(VContour, Q_MOVABLE_TYPE);
|
||||||
|
|
|
@ -311,8 +311,8 @@ void VPosition::SaveCandidate(VBestSquare &bestResult, const VLayoutPiece &detai
|
||||||
newGContour.append(newGContour.first());
|
newGContour.append(newGContour.first());
|
||||||
const QSizeF size = QPolygonF(newGContour).boundingRect().size();
|
const QSizeF size = QPolygonF(newGContour).boundingRect().size();
|
||||||
|
|
||||||
const bool isPortrait = m_data.gContour.GetSize().height() >= m_data.gContour.GetSize().width();
|
const qreal position = m_data.gContour.IsPortrait() ? detail.DetailBoundingRect().y() :
|
||||||
const qreal position = isPortrait ? detail.DetailBoundingRect().y() : detail.DetailBoundingRect().x();
|
detail.DetailBoundingRect().x();
|
||||||
|
|
||||||
bestResult.NewResult(size, globalI, detJ, detail.GetMatrix(), detail.IsMirror(), position, type);
|
bestResult.NewResult(size, globalI, detJ, detail.GetMatrix(), detail.IsMirror(), position, type);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user