diff --git a/src/libs/vlayout/vlayoutpaper.cpp b/src/libs/vlayout/vlayoutpaper.cpp index 7d7c548ea..ad8975880 100644 --- a/src/libs/vlayout/vlayoutpaper.cpp +++ b/src/libs/vlayout/vlayoutpaper.cpp @@ -575,35 +575,44 @@ VLayoutPaper::InsideType VLayoutPaper::InsideContour(const VLayoutDetail &detail 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 (p.isNull()) + if (m == detailI) + { + continue; + } + + const QLineF detailEdge = detail.Edge(m); + if (detailEdge.isNull()) // Got null edge { return InsideType::EdgeError; } - if (p != detailEdge.p1() && p != detailEdge.p2()) + const QVector p = Triplet(detailEdge); + for (int n=0; nglobalContour.at(i).y(); - const qreal yj = d->globalContour.at(j).y(); + int j = polyCorners-1; + bool oddNodes = false; - if (((yi < p.y() && yj >= p.y()) || (yj < p.y() && yi >= p.y()))) + for (int i=0; iglobalContour.at(i).y(); + const qreal yj = d->globalContour.at(j).y(); + + if (((yi < p.at(n).y() && yj >= p.at(n).y()) || (yj < p.at(n).y() && yi >= p.at(n).y()))) + { + oddNodes ^= (p.at(n).y() * multiple.at(i) + constant.at(i) < p.at(n).x()); + } + + j=i; } - j=i; - } - - if (oddNodes) - { - return InsideType::Inside; + if (oddNodes) + { + return InsideType::Inside; + } } } } @@ -1030,6 +1039,19 @@ QPointF VLayoutPaper::RoundedPoint(const QPointF &p) const return QPointF(qRound(p.x()), qRound(p.y())); } +//--------------------------------------------------------------------------------------------------------------------- +QVector VLayoutPaper::Triplet(const QLineF &edge) const +{ + QVector 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 { diff --git a/src/libs/vlayout/vlayoutpaper.h b/src/libs/vlayout/vlayoutpaper.h index ce74ccf0e..62d477af9 100644 --- a/src/libs/vlayout/vlayoutpaper.h +++ b/src/libs/vlayout/vlayoutpaper.h @@ -116,6 +116,7 @@ private: bool TrueIntersection(const QLineF &gEdge, const QLineF &dEdge, const QPointF &p) const; QPointF RoundedPoint(const QPointF &p) const; + QVector Triplet(const QLineF &edge) const; }; #endif // VLAYOUTPAPER_H