Skip excluded nodes when prepare segment of curve.
--HG-- branch : feature
This commit is contained in:
parent
6ac1a1247c
commit
e9c9d263f6
|
@ -387,10 +387,13 @@ VSAPoint VPiecePath::StartSegment(const VContainer *data, const QVector<VPieceNo
|
||||||
if (nodes.size() > 1)
|
if (nodes.size() > 1)
|
||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
i == 0 ? index = nodes.size()-1 : index = i-1;
|
i == 0 ? index = FindInLoopNotExcludedUp(nodes.size()-1, nodes) : index = FindInLoopNotExcludedUp(i-1, nodes);
|
||||||
|
|
||||||
|
if (index != -1 && index != i)
|
||||||
|
{
|
||||||
begin = CurveStartPoint(begin, data, nodes.at(index), points);
|
begin = CurveStartPoint(begin, data, nodes.at(index), points);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return begin;
|
return begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,10 +419,13 @@ VSAPoint VPiecePath::EndSegment(const VContainer *data, const QVector<VPieceNode
|
||||||
if (nodes.size() > 2)
|
if (nodes.size() > 2)
|
||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
i == nodes.size() - 1 ? index = 0 : index = i+1;
|
i == nodes.size()-1 ? index=FindInLoopNotExcludedDown(0, nodes) : index=FindInLoopNotExcludedDown(i+1, nodes);
|
||||||
|
|
||||||
|
if (index != -1 && index != i)
|
||||||
|
{
|
||||||
end = CurveEndPoint(end, data, nodes.at(index), points);
|
end = CurveEndPoint(end, data, nodes.at(index), points);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -762,6 +768,62 @@ QPointF VPiecePath::NodeNextPoint(const VContainer *data, int i) const
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
int VPiecePath::FindInLoopNotExcludedUp(int candidate, const QVector<VPieceNode> &nodes)
|
||||||
|
{
|
||||||
|
if (candidate < 0 || candidate >= nodes.size())
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int checked = 0;
|
||||||
|
int i = candidate;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (not nodes.at(i).IsExcluded())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
++checked;
|
||||||
|
--i;
|
||||||
|
if (i < 0)
|
||||||
|
{
|
||||||
|
i = nodes.size() - 1;
|
||||||
|
}
|
||||||
|
} while (checked < nodes.size());
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
int VPiecePath::FindInLoopNotExcludedDown(int candidate, const QVector<VPieceNode> &nodes)
|
||||||
|
{
|
||||||
|
if (candidate < 0 || candidate >= nodes.size())
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int checked = 0;
|
||||||
|
int i = candidate;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (not nodes.at(i).IsExcluded())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
++checked;
|
||||||
|
++i;
|
||||||
|
if (i >= nodes.size())
|
||||||
|
{
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
} while (checked < nodes.size());
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VSAPoint VPiecePath::PreparePointEkv(const VPieceNode &node, const VContainer *data)
|
VSAPoint VPiecePath::PreparePointEkv(const VPieceNode &node, const VContainer *data)
|
||||||
{
|
{
|
||||||
|
|
|
@ -94,6 +94,9 @@ public:
|
||||||
QPointF NodePreviousPoint(const VContainer *data, int i) const;
|
QPointF NodePreviousPoint(const VContainer *data, int i) const;
|
||||||
QPointF NodeNextPoint(const VContainer *data, int i) const;
|
QPointF NodeNextPoint(const VContainer *data, int i) const;
|
||||||
|
|
||||||
|
static int FindInLoopNotExcludedUp(int candidate, const QVector<VPieceNode> &nodes);
|
||||||
|
static int FindInLoopNotExcludedDown(int candidate, const QVector<VPieceNode> &nodes);
|
||||||
|
|
||||||
static VSAPoint StartSegment(const VContainer *data, const QVector<VPieceNode> &nodes, int i, bool reverse);
|
static VSAPoint StartSegment(const VContainer *data, const QVector<VPieceNode> &nodes, int i, bool reverse);
|
||||||
static VSAPoint EndSegment(const VContainer *data, const QVector<VPieceNode> &nodes, int i, bool reverse);
|
static VSAPoint EndSegment(const VContainer *data, const QVector<VPieceNode> &nodes, int i, bool reverse);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user