Alwayse first check if workpiece inside of paper sheet rect.

--HG--
branch : feature
This commit is contained in:
dismine 2015-01-19 12:36:27 +02:00
parent dc2620e0df
commit 3c76f32bed
2 changed files with 33 additions and 22 deletions

View File

@ -40,7 +40,7 @@ enum class LayoutErrors : char
EmptyPaperError EmptyPaperError
}; };
#define LAYOUT_DEBUG // Enable debug mode //#define LAYOUT_DEBUG // Enable debug mode
#ifdef LAYOUT_DEBUG #ifdef LAYOUT_DEBUG
# define SHOW_VERTICES // Show contour vertices # define SHOW_VERTICES // Show contour vertices

View File

@ -261,12 +261,9 @@ bool VLayoutPaper::AddToBlankSheet(const VLayoutDetail &detail, bool &stop)
if (CheckCombineEdges(workDetail, j, dEdge)) if (CheckCombineEdges(workDetail, j, dEdge))
{ {
const QRectF rec = workDetail.BoundingRect(); const QRectF rec = workDetail.BoundingRect();
if (SheetContains(rec))
{
bestResult.NewResult(static_cast<qint64>(rec.width()*rec.height()), j, dEdge, bestResult.NewResult(static_cast<qint64>(rec.width()*rec.height()), j, dEdge,
workDetail.GetMatrix(), workDetail.IsMirror()); workDetail.GetMatrix(), workDetail.IsMirror());
} }
}
d->frame = d->frame + 2; d->frame = d->frame + 2;
for (int angle = 0; angle <= 360; angle = angle+20) for (int angle = 0; angle <= 360; angle = angle+20)
@ -284,12 +281,9 @@ bool VLayoutPaper::AddToBlankSheet(const VLayoutDetail &detail, bool &stop)
if (CheckRotationEdges(workDetail, j, i, angle)) if (CheckRotationEdges(workDetail, j, i, angle))
{ {
const QRectF rec = workDetail.BoundingRect(); const QRectF rec = workDetail.BoundingRect();
if (SheetContains(rec))
{
bestResult.NewResult(static_cast<qint64>(rec.width()*rec.height()), j, i, bestResult.NewResult(static_cast<qint64>(rec.width()*rec.height()), j, i,
workDetail.GetMatrix(), workDetail.IsMirror()); workDetail.GetMatrix(), workDetail.IsMirror());
} }
}
++d->frame; ++d->frame;
} }
} }
@ -319,8 +313,6 @@ bool VLayoutPaper::AddToSheet(const VLayoutDetail &detail, bool &stop)
int dEdge = i;// For mirror detail edge will be different int dEdge = i;// For mirror detail edge will be different
if (CheckCombineEdges(workDetail, j, dEdge)) if (CheckCombineEdges(workDetail, j, dEdge))
{
if (SheetContains(workDetail.BoundingRect()))
{ {
QVector<QPointF> newGContour = UniteWithContour(workDetail, j, dEdge); QVector<QPointF> newGContour = UniteWithContour(workDetail, j, dEdge);
newGContour.append(newGContour.first()); newGContour.append(newGContour.first());
@ -328,7 +320,6 @@ bool VLayoutPaper::AddToSheet(const VLayoutDetail &detail, bool &stop)
bestResult.NewResult(static_cast<qint64>(rec.width()*rec.height()), j, dEdge, bestResult.NewResult(static_cast<qint64>(rec.width()*rec.height()), j, dEdge,
workDetail.GetMatrix(), workDetail.IsMirror()); workDetail.GetMatrix(), workDetail.IsMirror());
} }
}
d->frame = d->frame + 2; d->frame = d->frame + 2;
} }
} }
@ -351,7 +342,13 @@ bool VLayoutPaper::CheckCombineEdges(VLayoutDetail &detail, int j, int &dEdge) c
# endif # endif
#endif #endif
switch (Crossing(detail, j, dEdge)) CrossingType type = CrossingType::Intersection;
if (SheetContains(detail.BoundingRect()))
{
type = Crossing(detail, j, dEdge);
}
switch (type)
{ {
case CrossingType::EdgeError: case CrossingType::EdgeError:
return false; return false;
@ -394,7 +391,13 @@ bool VLayoutPaper::CheckCombineEdges(VLayoutDetail &detail, int j, int &dEdge) c
return false; return false;
} }
switch (Crossing(detail, j, dEdge)) CrossingType type = CrossingType::Intersection;
if (SheetContains(detail.BoundingRect()))
{
type = Crossing(detail, j, dEdge);
}
switch (type)
{ {
case CrossingType::EdgeError: case CrossingType::EdgeError:
return false; return false;
@ -438,7 +441,13 @@ bool VLayoutPaper::CheckRotationEdges(VLayoutDetail &detail, int j, int dEdge, i
#endif #endif
#endif #endif
switch (Crossing(detail, j, dEdge)) CrossingType type = CrossingType::Intersection;
if (SheetContains(detail.BoundingRect()))
{
type = Crossing(detail, j, dEdge);
}
switch (type)
{ {
case CrossingType::EdgeError: case CrossingType::EdgeError:
return false; return false;
@ -935,6 +944,8 @@ void VLayoutPaper::DrawDebug(const VLayoutDetail &detail, int frame) const
p = DrawDetails(); p = DrawDetails();
p.translate(d->paperWidth/2, d->paperHeight/2); p.translate(d->paperWidth/2, d->paperHeight/2);
paint.drawPath(p); paint.drawPath(p);
#else
Q_UNUSED(detail)
#endif #endif
paint.end(); paint.end();