Little optimization for the layout generator.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-03-28 11:22:15 +03:00
parent 09d2b96e73
commit dd586bf01e
3 changed files with 21 additions and 2 deletions

View File

@ -302,6 +302,14 @@ const QPointF &VContour::at(int i) const
return d->globalContour.at(i); return d->globalContour.at(i);
} }
//---------------------------------------------------------------------------------------------------------------------
QRectF VContour::BoundingRect() const
{
QVector<QPointF> points = GetContour();
points.append(points.first());
return QPolygonF(points).boundingRect();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VContour::AppendWhole(QVector<QPointF> &contour, const VLayoutDetail &detail, int detJ) const void VContour::AppendWhole(QVector<QPointF> &contour, const VLayoutDetail &detail, int detJ) const
{ {

View File

@ -39,6 +39,7 @@ class VContourData;
class QPointF; class QPointF;
class VLayoutDetail; class VLayoutDetail;
class QLineF; class QLineF;
class QRectF;
class VContour class VContour
{ {
@ -73,6 +74,8 @@ public:
const QPointF & at(int i) const; const QPointF & at(int i) const;
QRectF BoundingRect() const;
private: private:
QSharedDataPointer<VContourData> d; QSharedDataPointer<VContourData> d;

View File

@ -410,6 +410,14 @@ bool VPosition::CheckRotationEdges(VLayoutDetail &detail, int j, int dEdge, int
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPosition::CrossingType VPosition::Crossing(const VLayoutDetail &detail, const int &globalI, const int &detailI) const VPosition::CrossingType VPosition::Crossing(const VLayoutDetail &detail, const int &globalI, const int &detailI) const
{ {
const QRectF dRect = detail.BoundingRect();
const QRectF gRect = gContour.BoundingRect();
if (not gRect.intersects(dRect))
{
// This we can determine efficiently.
return CrossingType::NoIntersection;
}
int globalEdgesCount = gContour.GlobalEdgesCount(); int globalEdgesCount = gContour.GlobalEdgesCount();
if (globalEdgesCount == 0) if (globalEdgesCount == 0)
{ {