Make sure that a point is really lies on curve.
--HG-- branch : feature
This commit is contained in:
parent
e1d559e1d3
commit
caba2db95b
|
@ -236,6 +236,33 @@ bool VAbstractCurve::IsIntersectLine(const QLineF &line) const
|
|||
return not points.isEmpty();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VAbstractCurve::IsPointOnCurve(const QPointF &p) const
|
||||
{
|
||||
const QVector<QPointF> points = GetPoints();
|
||||
|
||||
if (points.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (points.size() < 2)
|
||||
{
|
||||
return points.at(0) == p;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (qint32 i = 0; i < points.count()-1; ++i)
|
||||
{
|
||||
if (IsPointOnLineSegment(p, points.at(i), points.at(i+1)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VAbstractCurve::GetDuplicate() const
|
||||
{
|
||||
|
|
|
@ -70,6 +70,8 @@ public:
|
|||
virtual QVector<QPointF> IntersectLine(const QLineF &line) const;
|
||||
virtual bool IsIntersectLine(const QLineF &line) const;
|
||||
|
||||
bool IsPointOnCurve(const QPointF &p) const;
|
||||
|
||||
virtual qreal GetStartAngle () const=0;
|
||||
virtual qreal GetEndAngle () const=0;
|
||||
|
||||
|
|
|
@ -471,9 +471,13 @@ VSAPoint VPiece::StartSegment(const VContainer *data, int i, bool reverse) const
|
|||
if (at(CountNodes()-1).GetTypeTool() == Tool::NodePoint)
|
||||
{
|
||||
const VPieceNode node = at(CountNodes()-1);
|
||||
begin = VSAPoint(*data->GeometricObject<VPointF>(node.GetId()));
|
||||
begin.SetSAAfter(node.GetSAAfter());
|
||||
begin.SetSABefore(node.GetSABefore());
|
||||
const QPointF p = *data->GeometricObject<VPointF>(node.GetId());
|
||||
if (curve->IsPointOnCurve(p))
|
||||
{
|
||||
begin = VSAPoint(p);
|
||||
begin.SetSAAfter(node.GetSAAfter());
|
||||
begin.SetSABefore(node.GetSABefore());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -481,9 +485,13 @@ VSAPoint VPiece::StartSegment(const VContainer *data, int i, bool reverse) const
|
|||
if (at(i-1).GetTypeTool() == Tool::NodePoint)
|
||||
{
|
||||
const VPieceNode node = at(i-1);
|
||||
begin = VSAPoint(*data->GeometricObject<VPointF>(node.GetId()));
|
||||
begin.SetSAAfter(node.GetSAAfter());
|
||||
begin.SetSABefore(node.GetSABefore());
|
||||
const QPointF p = *data->GeometricObject<VPointF>(node.GetId());
|
||||
if (curve->IsPointOnCurve(p))
|
||||
{
|
||||
begin = VSAPoint(p);
|
||||
begin.SetSAAfter(node.GetSAAfter());
|
||||
begin.SetSABefore(node.GetSABefore());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -514,9 +522,13 @@ VSAPoint VPiece::EndSegment(const VContainer *data, int i, bool reverse) const
|
|||
if (at(0).GetTypeTool() == Tool::NodePoint)
|
||||
{
|
||||
const VPieceNode node = at(0);
|
||||
end = VSAPoint(*data->GeometricObject<VPointF>(node.GetId()));
|
||||
end.SetSAAfter(node.GetSAAfter());
|
||||
end.SetSABefore(node.GetSABefore());
|
||||
const QPointF p = *data->GeometricObject<VPointF>(node.GetId());
|
||||
if (curve->IsPointOnCurve(p))
|
||||
{
|
||||
end = VSAPoint(p);
|
||||
end.SetSAAfter(node.GetSAAfter());
|
||||
end.SetSABefore(node.GetSABefore());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -524,9 +536,13 @@ VSAPoint VPiece::EndSegment(const VContainer *data, int i, bool reverse) const
|
|||
if (at(i+1).GetTypeTool() == Tool::NodePoint)
|
||||
{
|
||||
const VPieceNode node = at(i+1);
|
||||
end = VSAPoint(*data->GeometricObject<VPointF>(node.GetId()));
|
||||
end.SetSAAfter(node.GetSAAfter());
|
||||
end.SetSABefore(node.GetSABefore());
|
||||
const QPointF p = *data->GeometricObject<VPointF>(node.GetId());
|
||||
if (curve->IsPointOnCurve(p))
|
||||
{
|
||||
end = VSAPoint(p);
|
||||
end.SetSAAfter(node.GetSAAfter());
|
||||
end.SetSABefore(node.GetSABefore());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user