diff --git a/src/libs/vlayout/vlayoutpaper.cpp b/src/libs/vlayout/vlayoutpaper.cpp index 3be950d56..68c59c032 100644 --- a/src/libs/vlayout/vlayoutpaper.cpp +++ b/src/libs/vlayout/vlayoutpaper.cpp @@ -190,8 +190,6 @@ bool VLayoutPaper::AddToSheet(const VLayoutDetail &detail, bool &stop) { for (int i=1; i<= detail.EdgesCount(); i++) { - //QCoreApplication::processEvents(); - VPosition *thread = new VPosition(d->globalContour, j, detail, i, &stop, d->rotate, d->rotationIncrease); //Info for debug #ifdef LAYOUT_DEBUG diff --git a/src/libs/vlayout/vposition.cpp b/src/libs/vlayout/vposition.cpp index 13374e081..42cd56952 100644 --- a/src/libs/vlayout/vposition.cpp +++ b/src/libs/vlayout/vposition.cpp @@ -375,6 +375,9 @@ VPosition::CrossingType VPosition::Crossing(const VLayoutDetail &detail, const i return CrossingType::EdgeError; } + const QLineF gEdge = gContour.GlobalEdge(globalI); + const QLineF dEdge = detail.Edge(detailI); + for (int i = 1; i <= globalEdgesCount; i++) { const QLineF globalEdge = gContour.GlobalEdge(i); @@ -397,11 +400,9 @@ VPosition::CrossingType VPosition::Crossing(const VLayoutDetail &detail, const i } QPointF xPoint; - QLineF::IntersectType type = globalEdge.intersect(detailEdge, &xPoint); - - if (type == QLineF::BoundedIntersection) + if (globalEdge.intersect(detailEdge, &xPoint) == QLineF::BoundedIntersection) { - if (TrueIntersection(gContour.GlobalEdge(globalI), detail.Edge(detailI), xPoint)) + if (TrueIntersection(gEdge, dEdge, xPoint)) { return CrossingType::Intersection; } @@ -653,11 +654,23 @@ void VPosition::Rotate(int increase) bool VPosition::TrueIntersection(const QLineF &gEdge, const QLineF &dEdge, const QPointF &p) const { const QPointF pX = RoundedPoint(p); - const QPointF gP1 = RoundedPoint(gEdge.p1()); - const QPointF gP2 = RoundedPoint(gEdge.p2()); - const QPointF dP1 = RoundedPoint(dEdge.p1()); - const QPointF dP2 = RoundedPoint(dEdge.p2()); - return !(pX == gP1 || pX == gP2 || pX == dP1 || pX == dP2); + + QPointF xPoint; + if (gEdge.intersect(dEdge, &xPoint) == QLineF::NoIntersection) + { + const QPointF gP1 = RoundedPoint(gEdge.p1()); + const QPointF gP2 = RoundedPoint(gEdge.p2()); + const QPointF dP1 = RoundedPoint(dEdge.p1()); + const QPointF dP2 = RoundedPoint(dEdge.p2()); + + // If two edges are same line ignorring all intersection point that are equal to the start or the end point + return !(pX == gP1 || pX == gP2 || pX == dP1 || pX == dP2); + } + else + { + // Rotation case. Ignore intersection only in the point of edges intersection. + return pX != RoundedPoint(xPoint); + } } //---------------------------------------------------------------------------------------------------------------------