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};
|
qreal sidePosition{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VCachedPositions
|
|
||||||
{
|
|
||||||
QRectF boundingRect{};
|
|
||||||
QPainterPath layoutAllowancePath{};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // VLAYOUTDEF_H
|
#endif // VLAYOUTDEF_H
|
||||||
|
|
|
@ -266,12 +266,7 @@ bool VLayoutPaper::SaveResult(const VBestSquare &bestResult, const VLayoutPiece
|
||||||
}
|
}
|
||||||
d->details.append(workDetail);
|
d->details.append(workDetail);
|
||||||
d->globalContour.SetContour(newGContour);
|
d->globalContour.SetContour(newGContour);
|
||||||
|
d->positionsCache.append(VLayoutPiece::PainterPath(workDetail.GetLayoutAllowancePoints()));
|
||||||
VCachedPositions positionChache;
|
|
||||||
QVector<QPointF> layoutPoints = workDetail.GetLayoutAllowancePoints();
|
|
||||||
positionChache.boundingRect = VLayoutPiece::BoundingRect(layoutPoints);
|
|
||||||
positionChache.layoutAllowancePath = VLayoutPiece::PainterPath(layoutPoints);
|
|
||||||
d->positionsCache.append(positionChache);
|
|
||||||
}
|
}
|
||||||
else if (bestResult.IsTerminatedByException())
|
else if (bestResult.IsTerminatedByException())
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,7 +72,7 @@ public:
|
||||||
/** @brief details list of arranged details. */
|
/** @brief details list of arranged details. */
|
||||||
QVector<VLayoutPiece> details{};
|
QVector<VLayoutPiece> details{};
|
||||||
|
|
||||||
QVector<VCachedPositions> positionsCache{};
|
QVector<QPainterPath> positionsCache{};
|
||||||
|
|
||||||
/** @brief globalContour list of global points contour. */
|
/** @brief globalContour list of global points contour. */
|
||||||
VContour globalContour{};
|
VContour globalContour{};
|
||||||
|
|
|
@ -325,26 +325,19 @@ VPosition::CrossingType VPosition::Crossing(const VLayoutPiece &detail) const
|
||||||
return CrossingType::NoIntersection;
|
return CrossingType::NoIntersection;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QVector<QPointF> layoutPoints = detail.GetLayoutAllowancePoints();
|
const QPainterPath layoutAllowancePath = VLayoutPiece::PainterPath(detail.GetLayoutAllowancePoints());
|
||||||
const QRectF layoutBoundingRect = VLayoutPiece::BoundingRect(layoutPoints);
|
|
||||||
const QPainterPath layoutAllowancePath = VLayoutPiece::PainterPath(layoutPoints);
|
|
||||||
|
|
||||||
const QVector<QPointF> contourPoints = detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn() ?
|
const QVector<QPointF> contourPoints = detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn() ?
|
||||||
detail.GetMappedSeamAllowancePoints() : detail.GetMappedContourPoints();
|
detail.GetMappedSeamAllowancePoints() : detail.GetMappedContourPoints();
|
||||||
const QRectF detailBoundingRect = VLayoutPiece::BoundingRect(contourPoints);
|
|
||||||
const QPainterPath contourPath = VLayoutPiece::PainterPath(contourPoints);
|
const QPainterPath contourPath = VLayoutPiece::PainterPath(contourPoints);
|
||||||
|
|
||||||
for(auto &position : m_data.positionsCache)
|
for(auto &position : m_data.positionsCache)
|
||||||
{
|
{
|
||||||
if (position.boundingRect.intersects(layoutBoundingRect) || position.boundingRect.contains(detailBoundingRect))
|
if (position.contains(contourPath) || position.intersects(layoutAllowancePath))
|
||||||
{
|
|
||||||
if (position.layoutAllowancePath.contains(contourPath) ||
|
|
||||||
position.layoutAllowancePath.intersects(layoutAllowancePath))
|
|
||||||
{
|
{
|
||||||
return CrossingType::Intersection;
|
return CrossingType::Intersection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return CrossingType::NoIntersection;
|
return CrossingType::NoIntersection;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ struct VPositionData
|
||||||
bool rotate{false};
|
bool rotate{false};
|
||||||
int rotationNumber{0};
|
int rotationNumber{0};
|
||||||
bool followGrainline{false};
|
bool followGrainline{false};
|
||||||
QVector<VCachedPositions> positionsCache{};
|
QVector<QPainterPath> positionsCache{};
|
||||||
bool isOriginPaperOrientationPortrait{true};
|
bool isOriginPaperOrientationPortrait{true};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user