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>();
|
||||
}
|
||||
|
||||
int i2 = 0;
|
||||
if (globalI == d->globalContour.count())
|
||||
{
|
||||
i2 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
i2 = globalI;
|
||||
}
|
||||
const int i2 = globalI == d->globalContour.count() ? 0 : globalI;
|
||||
|
||||
int i=0;
|
||||
while (i < d->globalContour.count())
|
||||
|
@ -165,40 +157,11 @@ QVector<QPointF> VContour::UniteWithContour(const VLayoutPiece &detail, int glob
|
|||
}
|
||||
else
|
||||
{
|
||||
int processedEdges = 0;
|
||||
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);
|
||||
InsertDetail(newContour, detail, detJ);
|
||||
}
|
||||
}
|
||||
|
||||
if (not newContour.isEmpty())
|
||||
{
|
||||
if (newContour.last() != d->globalContour.at(i))
|
||||
{
|
||||
newContour.append(d->globalContour.at(i));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newContour.append(d->globalContour.at(i));
|
||||
}
|
||||
AppendToContour(newContour, d->globalContour.at(i));
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
@ -336,6 +299,22 @@ QPainterPath VContour::ContourPath() const
|
|||
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
|
||||
{
|
||||
|
@ -358,6 +337,31 @@ void VContour::AppendWhole(QVector<QPointF> &contour, const VLayoutPiece &detail
|
|||
}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
|
||||
{
|
||||
|
|
|
@ -94,7 +94,9 @@ public:
|
|||
private:
|
||||
QSharedDataPointer<VContourData> d;
|
||||
|
||||
void AppendToContour(QVector<QPointF> &contour, QPointF point) 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);
|
||||
|
|
|
@ -311,8 +311,8 @@ void VPosition::SaveCandidate(VBestSquare &bestResult, const VLayoutPiece &detai
|
|||
newGContour.append(newGContour.first());
|
||||
const QSizeF size = QPolygonF(newGContour).boundingRect().size();
|
||||
|
||||
const bool isPortrait = m_data.gContour.GetSize().height() >= m_data.gContour.GetSize().width();
|
||||
const qreal position = isPortrait ? detail.DetailBoundingRect().y() : detail.DetailBoundingRect().x();
|
||||
const qreal position = m_data.gContour.IsPortrait() ? detail.DetailBoundingRect().y() :
|
||||
detail.DetailBoundingRect().x();
|
||||
|
||||
bestResult.NewResult(size, globalI, detJ, detail.GetMatrix(), detail.IsMirror(), position, type);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user