Handle firt default angle type.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-11-19 15:29:54 +02:00
parent c614a2783e
commit 7aa7ba8e57
3 changed files with 90 additions and 34 deletions

View File

@ -395,36 +395,20 @@ QVector<QPointF> VAbstractPiece::EkvPoint(const VSAPoint &p1Line1, const VSAPoin
// Comparison bisector angles helps to find direction
if (angle <= 90)// Go in a same direction
{//Regular equdistant case
const qreal length = line.length();
if (length > localWidth*2.4)
{ // Cutting too long a cut angle
line.setLength(localWidth);
QLineF cutLine(line.p2(), CrosPoint); // Cut line is a perpendicular
cutLine.setLength(length); // Decided take this length
// We do not check intersection type because intersection must alwayse exist
QPointF px;
cutLine.setAngle(cutLine.angle()+90);
QLineF::IntersectType type = bigLine1.intersect( cutLine, &px );
if (type == QLineF::NoIntersection)
{
qDebug()<<"Couldn't find intersection with cut line.";
}
points.append(px);
cutLine.setAngle(cutLine.angle()-180);
type = bigLine2.intersect( cutLine, &px );
if (type == QLineF::NoIntersection)
{
qDebug()<<"Couldn't find intersection with cut line.";
}
points.append(px);
}
else
{ // The point just fine
points.append(CrosPoint);
return points;
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
switch (p2Line1.GetAngleType())
{
case PieceNodeAngle::ByLength:
return AngleByLength(p2Line1, bigLine1.p1(), CrosPoint, bigLine2.p2(), localWidth);
case PieceNodeAngle::ByPointsIntersection:
case PieceNodeAngle::ByFirstEdgeSymmetry:
case PieceNodeAngle::BySecondEdgeSymmetry:
case PieceNodeAngle::ByFirstEdgeRightAngle:
case PieceNodeAngle::BySecondEdgeRightAngle:
break;
}
QT_WARNING_POP
}
else
{ // Different directions
@ -437,6 +421,7 @@ QVector<QPointF> VAbstractPiece::EkvPoint(const VSAPoint &p1Line1, const VSAPoin
if (result1 <=0 && result2 <= 0)
{// Dart case. A bisector watch outside. In some cases a point still valid, but ignore if going
// outside of an equdistant.
const QLineF bigEdge = ParallelLine(p1Line1, p1Line2, localWidth );
QPointF px;
const QLineF::IntersectType type = bigEdge.intersect(line, &px);
@ -490,6 +475,45 @@ QVector<QPointF> VAbstractPiece::EkvPoint(const VSAPoint &p1Line1, const VSAPoin
return points;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<QPointF> VAbstractPiece::AngleByLength(const QPointF &p2, const QPointF &sp1, const QPointF &sp2,
const QPointF &sp3, qreal width)
{
QVector<QPointF> points;
QLineF line(p2, sp2);
const qreal length = line.length();
if (length > width*2.4)
{ // Cutting too long a cut angle
line.setLength(width);
QLineF cutLine(line.p2(), sp2); // Cut line is a perpendicular
cutLine.setLength(length); // Decided take this length
// We do not check intersection type because intersection must alwayse exist
QPointF px;
cutLine.setAngle(cutLine.angle()+90);
QLineF::IntersectType type = QLineF(sp1, sp2).intersect(cutLine, &px);
if (type == QLineF::NoIntersection)
{
qDebug()<<"Couldn't find intersection with cut line.";
}
points.append(px);
cutLine.setAngle(cutLine.angle()-180);
type = QLineF(sp2, sp3).intersect(cutLine, &px);
if (type == QLineF::NoIntersection)
{
qDebug()<<"Couldn't find intersection with cut line.";
}
points.append(px);
}
else
{ // The point just fine
points.append(sp2);
}
return points;
}
//---------------------------------------------------------------------------------------------------------------------
QLineF VAbstractPiece::ParallelLine(const VSAPoint &p1, const VSAPoint &p2, qreal width)
{

View File

@ -35,6 +35,7 @@
#include <QDebug>
#include "../vmisc/diagnostic.h"
#include "../vmisc/def.h"
#include "../vgeometry/vgobject.h"
template <class T> class QVector;
@ -61,9 +62,13 @@ public:
Q_DECL_CONSTEXPR qreal GetSAAfter() const;
void SetSAAfter(qreal value);
Q_DECL_CONSTEXPR PieceNodeAngle GetAngleType() const;
void SetAngleType(PieceNodeAngle value);
private:
qreal m_before;
qreal m_after;
qreal m_before;
qreal m_after;
PieceNodeAngle m_angle;
};
Q_DECLARE_METATYPE(VSAPoint)
@ -73,21 +78,24 @@ Q_DECLARE_TYPEINFO(VSAPoint, Q_MOVABLE_TYPE);
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint()
: QPointF(),
m_before(-1),
m_after(-1)
m_after(-1),
m_angle(PieceNodeAngle::ByLength)
{}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(qreal xpos, qreal ypos)
: QPointF(xpos, ypos),
m_before(-1),
m_after(-1)
m_after(-1),
m_angle(PieceNodeAngle::ByLength)
{}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(const QPointF &p)
: QPointF(p),
m_before(-1),
m_after(-1)
m_after(-1),
m_angle(PieceNodeAngle::ByLength)
{}
//---------------------------------------------------------------------------------------------------------------------
@ -114,6 +122,18 @@ inline void VSAPoint::SetSAAfter(qreal value)
value < 0 ? m_after = -1 : m_after = value;
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline PieceNodeAngle VSAPoint::GetAngleType() const
{
return m_angle;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VSAPoint::SetAngleType(PieceNodeAngle value)
{
m_angle = value;
}
QT_WARNING_POP
class VAbstractPiece
@ -154,6 +174,8 @@ private:
static qreal MaxLocalSA(const VSAPoint &p, qreal width);
static QVector<QPointF> EkvPoint(const VSAPoint &p1Line1, const VSAPoint &p2Line1,
const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width);
static QVector<QPointF> AngleByLength(const QPointF &p2, const QPointF &sp1, const QPointF &sp2, const QPointF &sp3,
qreal width);
static QLineF ParallelLine(const VSAPoint &p1, const VSAPoint &p2, qreal width);
static QLineF ParallelLine(const QPointF &p1, const QPointF &p2, qreal width);
static QPointF SingleParallelPoint(const QPointF &p1, const QPointF &p2, qreal angle, qreal width);

View File

@ -224,6 +224,7 @@ QVector<QPointF> VPiece::SeamAllowancePoints(const VContainer *data) const
p.SetSAAfter(node.GetSAAfter(*data->GetPatternUnit()));
p.SetSABefore(node.GetSABefore(*data->GetPatternUnit()));
p.SetAngleType(node.GetAngleType());
pointsEkv.append(p);
}
break;
@ -399,11 +400,13 @@ void VPiece::CurveSeamAllowanceSegment(QVector<VSAPoint> &pointsEkv, const VCont
{ // first point
p.SetSAAfter(begin.GetSAAfter());
p.SetSABefore(begin.GetSABefore());
p.SetAngleType(begin.GetAngleType());
}
else if (i == points.size() - 1)
{ // last point
p.SetSAAfter(end.GetSAAfter());
p.SetSABefore(end.GetSABefore());
p.SetAngleType(end.GetAngleType());
}
pointsEkv.append(p);
}
@ -428,6 +431,7 @@ void VPiece::CurveSeamAllowanceSegment(QVector<VSAPoint> &pointsEkv, const VCont
VSAPoint p(points.at(0));//First point in the list
p.SetSAAfter(begin.GetSAAfter());
p.SetSABefore(begin.GetSABefore());
p.SetAngleType(begin.GetAngleType());
pointsEkv.append(p);
qreal length = 0; // how much we handle
@ -440,6 +444,7 @@ void VPiece::CurveSeamAllowanceSegment(QVector<VSAPoint> &pointsEkv, const VCont
{// last point
p.SetSAAfter(end.GetSAAfter());
p.SetSABefore(end.GetSABefore());
p.SetAngleType(end.GetAngleType());
}
else
{
@ -448,6 +453,7 @@ void VPiece::CurveSeamAllowanceSegment(QVector<VSAPoint> &pointsEkv, const VCont
p.SetSAAfter(localWidth);
p.SetSABefore(localWidth);
// curve points have angle type by default
}
pointsEkv.append(p);
@ -485,6 +491,7 @@ VSAPoint VPiece::StartSegment(const VContainer *data, int i, bool reverse) const
begin = VSAPoint(p);
begin.SetSAAfter(node.GetSAAfter(*data->GetPatternUnit()));
begin.SetSABefore(node.GetSABefore(*data->GetPatternUnit()));
begin.SetAngleType(node.GetAngleType());
}
}
}
@ -499,6 +506,7 @@ VSAPoint VPiece::StartSegment(const VContainer *data, int i, bool reverse) const
begin = VSAPoint(p);
begin.SetSAAfter(node.GetSAAfter(*data->GetPatternUnit()));
begin.SetSABefore(node.GetSABefore(*data->GetPatternUnit()));
begin.SetAngleType(node.GetAngleType());
}
}
}
@ -536,6 +544,7 @@ VSAPoint VPiece::EndSegment(const VContainer *data, int i, bool reverse) const
end = VSAPoint(p);
end.SetSAAfter(node.GetSAAfter(*data->GetPatternUnit()));
end.SetSABefore(node.GetSABefore(*data->GetPatternUnit()));
end.SetAngleType(node.GetAngleType());
}
}
}
@ -550,6 +559,7 @@ VSAPoint VPiece::EndSegment(const VContainer *data, int i, bool reverse) const
end = VSAPoint(p);
end.SetSAAfter(node.GetSAAfter(*data->GetPatternUnit()));
end.SetSABefore(node.GetSABefore(*data->GetPatternUnit()));
end.SetAngleType(node.GetAngleType());
}
}
}