Need additional point on each edge for check if workpiece inside of global
contour. --HG-- branch : feature
This commit is contained in:
parent
2937a9e594
commit
dc2620e0df
|
@ -575,15 +575,23 @@ VLayoutPaper::InsideType VLayoutPaper::InsideContour(const VLayoutDetail &detail
|
||||||
j=i;
|
j=i;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int k = 0; k < lPoints.count(); k++)
|
for(int m = 1; m <= detail.EdgesCount(); ++m)
|
||||||
{
|
{
|
||||||
const QPointF p = lPoints.at(k);
|
if (m == detailI)
|
||||||
if (p.isNull())
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QLineF detailEdge = detail.Edge(m);
|
||||||
|
if (detailEdge.isNull()) // Got null edge
|
||||||
{
|
{
|
||||||
return InsideType::EdgeError;
|
return InsideType::EdgeError;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p != detailEdge.p1() && p != detailEdge.p2())
|
const QVector<QPointF> p = Triplet(detailEdge);
|
||||||
|
for (int n=0; n<p.size(); ++n )
|
||||||
|
{
|
||||||
|
if (p.at(n) != detailEdge.p1() && p.at(n) != detailEdge.p2())
|
||||||
{
|
{
|
||||||
int j = polyCorners-1;
|
int j = polyCorners-1;
|
||||||
bool oddNodes = false;
|
bool oddNodes = false;
|
||||||
|
@ -593,9 +601,9 @@ VLayoutPaper::InsideType VLayoutPaper::InsideContour(const VLayoutDetail &detail
|
||||||
const qreal yi = d->globalContour.at(i).y();
|
const qreal yi = d->globalContour.at(i).y();
|
||||||
const qreal yj = d->globalContour.at(j).y();
|
const qreal yj = d->globalContour.at(j).y();
|
||||||
|
|
||||||
if (((yi < p.y() && yj >= p.y()) || (yj < p.y() && yi >= p.y())))
|
if (((yi < p.at(n).y() && yj >= p.at(n).y()) || (yj < p.at(n).y() && yi >= p.at(n).y())))
|
||||||
{
|
{
|
||||||
oddNodes ^= (p.y() * multiple.at(i) + constant.at(i) < p.x());
|
oddNodes ^= (p.at(n).y() * multiple.at(i) + constant.at(i) < p.at(n).x());
|
||||||
}
|
}
|
||||||
|
|
||||||
j=i;
|
j=i;
|
||||||
|
@ -608,6 +616,7 @@ VLayoutPaper::InsideType VLayoutPaper::InsideContour(const VLayoutDetail &detail
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return InsideType::Outside;
|
return InsideType::Outside;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1030,6 +1039,19 @@ QPointF VLayoutPaper::RoundedPoint(const QPointF &p) const
|
||||||
return QPointF(qRound(p.x()), qRound(p.y()));
|
return QPointF(qRound(p.x()), qRound(p.y()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QVector<QPointF> VLayoutPaper::Triplet(const QLineF &edge) const
|
||||||
|
{
|
||||||
|
QVector<QPointF> p;
|
||||||
|
QLineF line = edge;
|
||||||
|
line.setLength(edge.length()/2);
|
||||||
|
|
||||||
|
p.append(edge.p1());
|
||||||
|
p.append(line.p2());
|
||||||
|
p.append(edge.p2());
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QGraphicsItem *VLayoutPaper::GetItem() const
|
QGraphicsItem *VLayoutPaper::GetItem() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -116,6 +116,7 @@ private:
|
||||||
|
|
||||||
bool TrueIntersection(const QLineF &gEdge, const QLineF &dEdge, const QPointF &p) const;
|
bool TrueIntersection(const QLineF &gEdge, const QLineF &dEdge, const QPointF &p) const;
|
||||||
QPointF RoundedPoint(const QPointF &p) const;
|
QPointF RoundedPoint(const QPointF &p) const;
|
||||||
|
QVector<QPointF> Triplet(const QLineF &edge) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VLAYOUTPAPER_H
|
#endif // VLAYOUTPAPER_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user