Fixed broken checking intersection workpieces.

--HG--
branch : release
This commit is contained in:
Roman Telezhynskyi 2015-05-04 10:59:35 +03:00
parent 47c7609ebb
commit 2b6f9c9fef

View File

@ -368,6 +368,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);
@ -390,11 +393,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;
}
@ -645,11 +646,23 @@ void VPosition::Rotate(int increase)
bool VPosition::TrueIntersection(const QLineF &gEdge, const QLineF &dEdge, const QPointF &p) const
{
const QPointF pX = RoundedPoint(p);
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);
}
}
//---------------------------------------------------------------------------------------------------------------------