Added several comments.
--HG-- branch : feature
This commit is contained in:
parent
4237456228
commit
afb267c05c
|
@ -350,15 +350,16 @@ qreal VAbstractPiece::MaxLocalSA(const VSAPoint &p, qreal width)
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief EkvPoint return vector of points of equidistant two lines. Last point of two lines must be equal.
|
* @brief EkvPoint return seam aloowance points in place of intersection two edges. Last points of two edges should be
|
||||||
* @param width width of equidistant.
|
* equal.
|
||||||
* @return vector of points.
|
* @param width global seam allowance width.
|
||||||
|
* @return seam aloowance points.
|
||||||
*/
|
*/
|
||||||
QVector<QPointF> VAbstractPiece::EkvPoint(const VSAPoint &p1Line1, const VSAPoint &p2Line1,
|
QVector<QPointF> VAbstractPiece::EkvPoint(const VSAPoint &p1Line1, const VSAPoint &p2Line1,
|
||||||
const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width)
|
const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width)
|
||||||
{
|
{
|
||||||
if (width < 0)
|
if (width < 0)
|
||||||
{
|
{ // width can't be < 0
|
||||||
return QVector<QPointF>();
|
return QVector<QPointF>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,35 +367,38 @@ QVector<QPointF> VAbstractPiece::EkvPoint(const VSAPoint &p1Line1, const VSAPoin
|
||||||
if (p2Line1 != p2Line2)
|
if (p2Line1 != p2Line2)
|
||||||
{
|
{
|
||||||
qDebug()<<"Last points of two lines must be equal.";
|
qDebug()<<"Last points of two lines must be equal.";
|
||||||
return QVector<QPointF>();
|
return QVector<QPointF>(); // Wrong edges
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF CrosPoint;
|
|
||||||
const QLineF bigLine1 = ParallelLine(p1Line1, p2Line1, width );
|
const QLineF bigLine1 = ParallelLine(p1Line1, p2Line1, width );
|
||||||
const QLineF bigLine2 = ParallelLine(p2Line2, p1Line2, width );
|
const QLineF bigLine2 = ParallelLine(p2Line2, p1Line2, width );
|
||||||
QLineF::IntersectType type = bigLine1.intersect( bigLine2, &CrosPoint );
|
QPointF CrosPoint;
|
||||||
|
const QLineF::IntersectType type = bigLine1.intersect( bigLine2, &CrosPoint );
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{// There are at least three big cases
|
||||||
case (QLineF::BoundedIntersection):
|
case (QLineF::BoundedIntersection):
|
||||||
|
// The easiest, real intersection
|
||||||
points.append(CrosPoint);
|
points.append(CrosPoint);
|
||||||
return points;
|
return points;
|
||||||
break;
|
break;
|
||||||
case (QLineF::UnboundedIntersection):
|
case (QLineF::UnboundedIntersection):
|
||||||
{
|
{ // Most common case
|
||||||
const qreal localWidth = MaxLocalSA(p2Line1, width);
|
const qreal localWidth = MaxLocalSA(p2Line1, width);
|
||||||
QLineF line( p2Line1, CrosPoint );
|
QLineF line( p2Line1, CrosPoint );
|
||||||
|
|
||||||
|
// Checking two subcases
|
||||||
const QLineF b1 = BisectorLine(p1Line1, p2Line1, p1Line2);
|
const QLineF b1 = BisectorLine(p1Line1, p2Line1, p1Line2);
|
||||||
const QLineF b2 = BisectorLine(bigLine1.p1(), CrosPoint, bigLine2.p2());
|
const QLineF b2 = BisectorLine(bigLine1.p1(), CrosPoint, bigLine2.p2());
|
||||||
|
|
||||||
const qreal angle = AngleBetweenBisectors(b1, b2);
|
const qreal angle = AngleBetweenBisectors(b1, b2);
|
||||||
|
|
||||||
|
// Comparison bisector angles helps to find direction
|
||||||
if (angle <= 90)// Go in a same direction
|
if (angle <= 90)// Go in a same direction
|
||||||
{//Regular equdistant case
|
{//Regular equdistant case
|
||||||
const qreal length = line.length();
|
const qreal length = line.length();
|
||||||
if (length > localWidth*2.4)
|
if (length > localWidth*2.4)
|
||||||
{ // Cutting too long a cut angle
|
{ // Cutting too long a cut angle
|
||||||
line.setLength(localWidth); // Not sure about width value here
|
line.setLength(localWidth);
|
||||||
QLineF cutLine(line.p2(), CrosPoint); // Cut line is a perpendicular
|
QLineF cutLine(line.p2(), CrosPoint); // Cut line is a perpendicular
|
||||||
cutLine.setLength(length); // Decided take this length
|
cutLine.setLength(length); // Decided take this length
|
||||||
|
|
||||||
|
@ -417,13 +421,13 @@ QVector<QPointF> VAbstractPiece::EkvPoint(const VSAPoint &p1Line1, const VSAPoin
|
||||||
points.append(px);
|
points.append(px);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{ // The point just fine
|
||||||
points.append(CrosPoint);
|
points.append(CrosPoint);
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{ // Different directions
|
||||||
QLineF bisector(p2Line1, p1Line1);
|
QLineF bisector(p2Line1, p1Line1);
|
||||||
bisector.setAngle(b1.angle());
|
bisector.setAngle(b1.angle());
|
||||||
|
|
||||||
|
@ -431,8 +435,8 @@ QVector<QPointF> VAbstractPiece::EkvPoint(const VSAPoint &p1Line1, const VSAPoin
|
||||||
const qreal result2 = PointPosition(bisector.p2(), QLineF(p2Line2, p1Line2));
|
const qreal result2 = PointPosition(bisector.p2(), QLineF(p2Line2, p1Line2));
|
||||||
|
|
||||||
if (result1 <=0 && result2 <= 0)
|
if (result1 <=0 && result2 <= 0)
|
||||||
{
|
{// Dart case. A bisector watch outside. In some cases a point still valid, but ignore if going
|
||||||
// Dart. Ignore if going outside of equdistant
|
// outside of an equdistant.
|
||||||
const QLineF bigEdge = ParallelLine(p1Line1, p1Line2, localWidth );
|
const QLineF bigEdge = ParallelLine(p1Line1, p1Line2, localWidth );
|
||||||
QPointF px;
|
QPointF px;
|
||||||
const QLineF::IntersectType type = bigEdge.intersect(line, &px);
|
const QLineF::IntersectType type = bigEdge.intersect(line, &px);
|
||||||
|
@ -446,26 +450,26 @@ QVector<QPointF> VAbstractPiece::EkvPoint(const VSAPoint &p1Line1, const VSAPoin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{ // New subcase. This is not a dart. An angle is acute and bisector watch inside.
|
||||||
const qreal result1 = PointPosition(CrosPoint, QLineF(p1Line1, p2Line1));
|
const qreal result1 = PointPosition(CrosPoint, QLineF(p1Line1, p2Line1));
|
||||||
const qreal result2 = PointPosition(CrosPoint, QLineF(p2Line2, p1Line2));
|
const qreal result2 = PointPosition(CrosPoint, QLineF(p2Line2, p1Line2));
|
||||||
|
|
||||||
if (result1 <=0 && result2 <= 0)
|
if (result1 <=0 && result2 <= 0)
|
||||||
{
|
{// The cross point is still outside of a piece
|
||||||
if (line.length() >= localWidth)
|
if (line.length() >= localWidth)
|
||||||
{
|
{
|
||||||
points.append(CrosPoint);
|
points.append(CrosPoint);
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{// but not enough far, fix it
|
||||||
line.setLength(localWidth);
|
line.setLength(localWidth);
|
||||||
points.append(line.p2());
|
points.append(line.p2());
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{// Wrong cross point, probably inside of a piece. Manually creating correct seam allowance
|
||||||
const QLineF bigEdge = ParallelLine(bigLine1.p2(), bigLine2.p1(), localWidth );
|
const QLineF bigEdge = ParallelLine(bigLine1.p2(), bigLine2.p1(), localWidth );
|
||||||
points.append(bigEdge.p1());
|
points.append(bigEdge.p1());
|
||||||
points.append(bigEdge.p2());
|
points.append(bigEdge.p2());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user