Left the most robust way to find intersections.
--HG-- branch : develop
This commit is contained in:
parent
cc2aa8d1ba
commit
8482f3dd28
|
@ -108,10 +108,4 @@ struct VBestSquareResData
|
|||
qreal sidePosition{0};
|
||||
};
|
||||
|
||||
struct VCachedPositions
|
||||
{
|
||||
QRectF boundingRect{};
|
||||
QPainterPath layoutAllowancePath{};
|
||||
};
|
||||
|
||||
#endif // VLAYOUTDEF_H
|
||||
|
|
|
@ -266,12 +266,7 @@ bool VLayoutPaper::SaveResult(const VBestSquare &bestResult, const VLayoutPiece
|
|||
}
|
||||
d->details.append(workDetail);
|
||||
d->globalContour.SetContour(newGContour);
|
||||
|
||||
VCachedPositions positionChache;
|
||||
QVector<QPointF> layoutPoints = workDetail.GetLayoutAllowancePoints();
|
||||
positionChache.boundingRect = VLayoutPiece::BoundingRect(layoutPoints);
|
||||
positionChache.layoutAllowancePath = VLayoutPiece::PainterPath(layoutPoints);
|
||||
d->positionsCache.append(positionChache);
|
||||
d->positionsCache.append(VLayoutPiece::PainterPath(workDetail.GetLayoutAllowancePoints()));
|
||||
}
|
||||
else if (bestResult.IsTerminatedByException())
|
||||
{
|
||||
|
|
|
@ -72,7 +72,7 @@ public:
|
|||
/** @brief details list of arranged details. */
|
||||
QVector<VLayoutPiece> details{};
|
||||
|
||||
QVector<VCachedPositions> positionsCache{};
|
||||
QVector<QPainterPath> positionsCache{};
|
||||
|
||||
/** @brief globalContour list of global points contour. */
|
||||
VContour globalContour{};
|
||||
|
|
|
@ -325,26 +325,19 @@ VPosition::CrossingType VPosition::Crossing(const VLayoutPiece &detail) const
|
|||
return CrossingType::NoIntersection;
|
||||
}
|
||||
|
||||
const QVector<QPointF> layoutPoints = detail.GetLayoutAllowancePoints();
|
||||
const QRectF layoutBoundingRect = VLayoutPiece::BoundingRect(layoutPoints);
|
||||
const QPainterPath layoutAllowancePath = VLayoutPiece::PainterPath(layoutPoints);
|
||||
const QPainterPath layoutAllowancePath = VLayoutPiece::PainterPath(detail.GetLayoutAllowancePoints());
|
||||
|
||||
const QVector<QPointF> 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.boundingRect.intersects(layoutBoundingRect) || position.boundingRect.contains(detailBoundingRect))
|
||||
{
|
||||
if (position.layoutAllowancePath.contains(contourPath) ||
|
||||
position.layoutAllowancePath.intersects(layoutAllowancePath))
|
||||
if (position.contains(contourPath) || position.intersects(layoutAllowancePath))
|
||||
{
|
||||
return CrossingType::Intersection;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return CrossingType::NoIntersection;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ struct VPositionData
|
|||
bool rotate{false};
|
||||
int rotationNumber{0};
|
||||
bool followGrainline{false};
|
||||
QVector<VCachedPositions> positionsCache{};
|
||||
QVector<QPainterPath> positionsCache{};
|
||||
bool isOriginPaperOrientationPortrait{true};
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user