diff --git a/src/libs/vlayout/vlayoutdef.h b/src/libs/vlayout/vlayoutdef.h index 1634624a4..ee6aba976 100644 --- a/src/libs/vlayout/vlayoutdef.h +++ b/src/libs/vlayout/vlayoutdef.h @@ -108,4 +108,10 @@ struct VBestSquareResData qreal sidePosition{0}; }; +struct VCachedPositions +{ + QRectF boundingRect{}; + QPainterPath layoutAllowancePath{}; +}; + #endif // VLAYOUTDEF_H diff --git a/src/libs/vlayout/vlayoutpaper.cpp b/src/libs/vlayout/vlayoutpaper.cpp index 1085c0362..8a0b4b6b5 100644 --- a/src/libs/vlayout/vlayoutpaper.cpp +++ b/src/libs/vlayout/vlayoutpaper.cpp @@ -266,7 +266,12 @@ bool VLayoutPaper::SaveResult(const VBestSquare &bestResult, const VLayoutPiece } d->details.append(workDetail); d->globalContour.SetContour(newGContour); - d->positionsCache.append(VLayoutPiece::PainterPath(workDetail.GetLayoutAllowancePoints())); + + VCachedPositions positionChache; + QVector layoutPoints = workDetail.GetLayoutAllowancePoints(); + positionChache.boundingRect = VLayoutPiece::BoundingRect(layoutPoints); + positionChache.layoutAllowancePath = VLayoutPiece::PainterPath(layoutPoints); + d->positionsCache.append(positionChache); } else if (bestResult.IsTerminatedByException()) { diff --git a/src/libs/vlayout/vlayoutpaper_p.h b/src/libs/vlayout/vlayoutpaper_p.h index e1646824b..2d51de511 100644 --- a/src/libs/vlayout/vlayoutpaper_p.h +++ b/src/libs/vlayout/vlayoutpaper_p.h @@ -72,7 +72,7 @@ public: /** @brief details list of arranged details. */ QVector details{}; - QVector positionsCache{}; + QVector positionsCache{}; /** @brief globalContour list of global points contour. */ VContour globalContour{}; diff --git a/src/libs/vlayout/vposition.cpp b/src/libs/vlayout/vposition.cpp index cb5074561..a75afa327 100644 --- a/src/libs/vlayout/vposition.cpp +++ b/src/libs/vlayout/vposition.cpp @@ -325,17 +325,24 @@ VPosition::CrossingType VPosition::Crossing(const VLayoutPiece &detail) const return CrossingType::NoIntersection; } - const QPainterPath layoutAllowancePath = VLayoutPiece::PainterPath(detail.GetLayoutAllowancePoints()); + const QVector layoutPoints = detail.GetLayoutAllowancePoints(); + const QRectF layoutBoundingRect = VLayoutPiece::BoundingRect(layoutPoints); + const QPainterPath layoutAllowancePath = VLayoutPiece::PainterPath(layoutPoints); const QVector contourPoints = detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn() ? detail.GetMappedSeamAllowancePoints() : detail.GetMappedContourPoints(); + const QRectF detailBoundingRect = VLayoutPiece::BoundingRect(contourPoints); const QPainterPath contourPath = VLayoutPiece::PainterPath(contourPoints); for(auto &position : m_data.positionsCache) { - if (position.contains(contourPath) || position.intersects(layoutAllowancePath)) + if (position.boundingRect.intersects(layoutBoundingRect) || position.boundingRect.contains(detailBoundingRect)) { - return CrossingType::Intersection; + if (position.layoutAllowancePath.contains(contourPath) || + position.layoutAllowancePath.intersects(layoutAllowancePath)) + { + return CrossingType::Intersection; + } } } diff --git a/src/libs/vlayout/vposition.h b/src/libs/vlayout/vposition.h index e11cafeda..0daa7442e 100644 --- a/src/libs/vlayout/vposition.h +++ b/src/libs/vlayout/vposition.h @@ -49,7 +49,7 @@ struct VPositionData bool rotate{false}; int rotationNumber{0}; bool followGrainline{false}; - QVector positionsCache{}; + QVector positionsCache{}; bool isOriginPaperOrientationPortrait{true}; };