Fixed issue #469. Error - Layout has overlapping pieces in develop branch.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-06-21 16:04:15 +03:00
parent 2d25702c97
commit e3ee35bf50
4 changed files with 30 additions and 12 deletions

View File

@ -252,7 +252,24 @@ int VLayoutDetail::EdgeByPoint(const QPointF &p1) const
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VLayoutDetail::BoundingRect() const
QRectF VLayoutDetail::DetailBoundingRect() const
{
QVector<QPointF> points;
if (getSeamAllowance())
{
points = GetSeamAllowencePoints();
}
else
{
points = GetContourPoints();
}
points.append(points.first());
return QPolygonF(points).boundingRect();
}
//---------------------------------------------------------------------------------------------------------------------
QRectF VLayoutDetail::LayoutBoundingRect() const
{
QVector<QPointF> points = GetLayoutAllowencePoints();
points.append(points.first());
@ -262,7 +279,7 @@ QRectF VLayoutDetail::BoundingRect() const
//---------------------------------------------------------------------------------------------------------------------
qreal VLayoutDetail::Diagonal() const
{
const QRectF rec = BoundingRect();
const QRectF rec = LayoutBoundingRect();
return qSqrt(pow(rec.height(), 2) + pow(rec.width(), 2));
}

View File

@ -71,7 +71,8 @@ public:
QLineF Edge(int i) const;
int EdgeByPoint(const QPointF &p1) const;
QRectF BoundingRect() const;
QRectF DetailBoundingRect() const;
QRectF LayoutBoundingRect() const;
qreal Diagonal() const;
bool isNull() const;

View File

@ -335,7 +335,7 @@ QRectF VLayoutPaper::BoundingRect() const
QRectF rec;
for (int i=0; i < d->details.count(); ++i)
{
rec = rec.united(d->details.at(i).BoundingRect());
rec = rec.united(d->details.at(i).LayoutBoundingRect());
}
return rec;

View File

@ -264,7 +264,7 @@ bool VPosition::CheckCombineEdges(VLayoutDetail &detail, int j, int &dEdge)
#endif
CrossingType type = CrossingType::Intersection;
if (SheetContains(detail.BoundingRect()))
if (SheetContains(detail.LayoutBoundingRect()))
{
if (not gContour.GetContour().isEmpty())
{
@ -306,7 +306,7 @@ bool VPosition::CheckCombineEdges(VLayoutDetail &detail, int j, int &dEdge)
}
CrossingType type = CrossingType::Intersection;
if (SheetContains(detail.BoundingRect()))
if (SheetContains(detail.LayoutBoundingRect()))
{
type = Crossing(detail);
}
@ -343,7 +343,7 @@ bool VPosition::CheckRotationEdges(VLayoutDetail &detail, int j, int dEdge, int
#endif
CrossingType type = CrossingType::Intersection;
if (SheetContains(detail.BoundingRect()))
if (SheetContains(detail.LayoutBoundingRect()))
{
type = Crossing(detail);
}
@ -367,21 +367,21 @@ bool VPosition::CheckRotationEdges(VLayoutDetail &detail, int j, int dEdge, int
//---------------------------------------------------------------------------------------------------------------------
VPosition::CrossingType VPosition::Crossing(const VLayoutDetail &detail) const
{
const QRectF dRect = detail.BoundingRect();
const QRectF gRect = gContour.BoundingRect();
if (not gRect.intersects(dRect))
if (not gRect.intersects(detail.LayoutBoundingRect()) && not gRect.contains(detail.DetailBoundingRect()))
{
// This we can determine efficiently.
return CrossingType::NoIntersection;
}
if (gContour.ContourPath().intersects(detail.LayoutAllowencePath()))
const QPainterPath gPath = gContour.ContourPath();
if (not gPath.intersects(detail.LayoutAllowencePath()) && not gPath.contains(detail.ContourPath()))
{
return CrossingType::Intersection;
return CrossingType::NoIntersection;
}
else
{
return CrossingType::NoIntersection;
return CrossingType::Intersection;
}
}