Have found case where the program returns wrong curve segment.
--HG-- branch : develop
This commit is contained in:
parent
7be1690e39
commit
1c92165467
|
@ -76,7 +76,7 @@ QVector<QPointF> VAbstractCurve::FromBegin(const QVector<QPointF> &points, const
|
||||||
{
|
{
|
||||||
if (theBegin == false)
|
if (theBegin == false)
|
||||||
{
|
{
|
||||||
if (IsPointOnLineSegment(begin.toPoint(), points.at(i).toPoint(), points.at(i+1).toPoint()))
|
if (IsPointOnLineSegment(begin, points.at(i), points.at(i+1)))
|
||||||
{
|
{
|
||||||
theBegin = true;
|
theBegin = true;
|
||||||
segment.append(begin);
|
segment.append(begin);
|
||||||
|
|
|
@ -418,7 +418,7 @@ void VGObject::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c
|
||||||
*
|
*
|
||||||
* Original idea http://www.sunshine2k.de/coding/java/PointOnLine/PointOnLine.html
|
* Original idea http://www.sunshine2k.de/coding/java/PointOnLine/PointOnLine.html
|
||||||
*/
|
*/
|
||||||
bool VGObject::IsPointOnLineSegment(const QPoint &t, const QPoint &p1, const QPoint &p2)
|
bool VGObject::IsPointOnLineSegment(const QPointF &t, const QPointF &p1, const QPointF &p2)
|
||||||
{
|
{
|
||||||
// The test point must lie inside the bounding box spanned by the two line points.
|
// The test point must lie inside the bounding box spanned by the two line points.
|
||||||
if (not ( (p1.x() <= t.x() && t.x() <= p2.x()) || (p2.x() <= t.x() && t.x() <= p1.x()) ))
|
if (not ( (p1.x() <= t.x() && t.x() <= p2.x()) || (p2.x() <= t.x() && t.x() <= p1.x()) ))
|
||||||
|
@ -443,7 +443,7 @@ bool VGObject::IsPointOnLineSegment(const QPoint &t, const QPoint &p1, const QPo
|
||||||
*
|
*
|
||||||
* The pdp is zero only if the t lies on the line e1 = vector from p1 to p2.
|
* The pdp is zero only if the t lies on the line e1 = vector from p1 to p2.
|
||||||
*/
|
*/
|
||||||
bool VGObject::IsPointOnLineviaPDP(const QPoint &t, const QPoint &p1, const QPoint &p2)
|
bool VGObject::IsPointOnLineviaPDP(const QPointF &t, const QPointF &p1, const QPointF &p2)
|
||||||
{
|
{
|
||||||
return ( qAbs(PerpDotProduct(p1, p2, t) < GetEpsilon(p1, p2)) );
|
return ( qAbs(PerpDotProduct(p1, p2, t) < GetEpsilon(p1, p2)) );
|
||||||
}
|
}
|
||||||
|
@ -454,7 +454,7 @@ bool VGObject::IsPointOnLineviaPDP(const QPoint &t, const QPoint &p1, const QPoi
|
||||||
* This is actually the same as the area of the triangle defined by the three points, multiplied by 2.
|
* This is actually the same as the area of the triangle defined by the three points, multiplied by 2.
|
||||||
* @return 2 * triangleArea(a,b,c)
|
* @return 2 * triangleArea(a,b,c)
|
||||||
*/
|
*/
|
||||||
double VGObject::PerpDotProduct(const QPoint &t, const QPoint &p1, const QPoint &p2)
|
double VGObject::PerpDotProduct(const QPointF &t, const QPointF &p1, const QPointF &p2)
|
||||||
{
|
{
|
||||||
return (p1.x() - t.x()) * (p2.y() - t.y()) - (p1.y() - t.y()) * (p2.x() - t.x());
|
return (p1.x() - t.x()) * (p2.y() - t.y()) - (p1.y() - t.y()) * (p2.x() - t.x());
|
||||||
}
|
}
|
||||||
|
@ -470,8 +470,8 @@ double VGObject::PerpDotProduct(const QPoint &t, const QPoint &p1, const QPoint
|
||||||
*/
|
*/
|
||||||
double VGObject::GetEpsilon(const QPointF &p1, const QPointF &p2)
|
double VGObject::GetEpsilon(const QPointF &p1, const QPointF &p2)
|
||||||
{
|
{
|
||||||
const int dx1 = p2.toPoint().x() - p1.toPoint().x();
|
const double dx1 = p2.x() - p1.x();
|
||||||
const int dy1 = p2.toPoint().y() - p1.toPoint().y();
|
const double dy1 = p2.y() - p1.y();
|
||||||
const double epsilon = 0.003 * (dx1 * dx1 + dy1 * dy1); //-V636
|
const double epsilon = 0.003 * (dx1 * dx1 + dy1 * dy1); //-V636
|
||||||
return epsilon;
|
return epsilon;
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,15 +82,15 @@ public:
|
||||||
static QPointF ClosestPoint(const QLineF &line, const QPointF &point);
|
static QPointF ClosestPoint(const QLineF &line, const QPointF &point);
|
||||||
static QPointF addVector (const QPointF &p, const QPointF &p1, const QPointF &p2, qreal k);
|
static QPointF addVector (const QPointF &p, const QPointF &p1, const QPointF &p2, qreal k);
|
||||||
static void LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c);
|
static void LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c);
|
||||||
static bool IsPointOnLineSegment (const QPoint &t, const QPoint &p1, const QPoint &p2);
|
static bool IsPointOnLineSegment (const QPointF &t, const QPointF &p1, const QPointF &p2);
|
||||||
|
|
||||||
static QVector<QPointF> GetReversePoints(const QVector<QPointF> &points);
|
static QVector<QPointF> GetReversePoints(const QVector<QPointF> &points);
|
||||||
static int GetLengthContour(const QVector<QPointF> &contour, const QVector<QPointF> &newPoints);
|
static int GetLengthContour(const QVector<QPointF> &contour, const QVector<QPointF> &newPoints);
|
||||||
private:
|
private:
|
||||||
QSharedDataPointer<VGObjectData> d;
|
QSharedDataPointer<VGObjectData> d;
|
||||||
|
|
||||||
static bool IsPointOnLineviaPDP(const QPoint &t, const QPoint &p1, const QPoint &p2);
|
static bool IsPointOnLineviaPDP(const QPointF &t, const QPointF &p1, const QPointF &p2);
|
||||||
static double PerpDotProduct(const QPoint &t, const QPoint &p1, const QPoint &p2);
|
static double PerpDotProduct(const QPointF &t, const QPointF &p1, const QPointF &p2);
|
||||||
static double GetEpsilon(const QPointF &p1, const QPointF &p2);
|
static double GetEpsilon(const QPointF &p1, const QPointF &p2);
|
||||||
|
|
||||||
static int PointInCircle (const QPointF &p, const QPointF ¢er, qreal radius);
|
static int PointInCircle (const QPointF &p, const QPointF ¢er, qreal radius);
|
||||||
|
|
|
@ -418,7 +418,7 @@ QVector<QPointF> VDetail::SeamAllowancePoints(const VContainer *data) const
|
||||||
const QPointF begin = StartSegment(data, i);
|
const QPointF begin = StartSegment(data, i);
|
||||||
const QPointF end = EndSegment(data, i);
|
const QPointF end = EndSegment(data, i);
|
||||||
|
|
||||||
QVector<QPointF> nodePoints = curve->GetSegmentPoints(begin, end, at(i).getReverse());
|
const QVector<QPointF> nodePoints = curve->GetSegmentPoints(begin, end, at(i).getReverse());
|
||||||
pointsEkv << biasPoints(nodePoints, at(i).getMx(), at(i).getMy());
|
pointsEkv << biasPoints(nodePoints, at(i).getMx(), at(i).getMy());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -520,7 +520,14 @@ int VDetail::indexOfNode(const QVector<VNodeDetail> &list, const quint32 &id)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QPointF VDetail::StartSegment(const VContainer *data, const int &i) const
|
QPointF VDetail::StartSegment(const VContainer *data, const int &i) const
|
||||||
{
|
{
|
||||||
QPointF begin;
|
if (i < 0 && i > CountNode()-1)
|
||||||
|
{
|
||||||
|
return QPointF();
|
||||||
|
}
|
||||||
|
|
||||||
|
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(at(i).getId());
|
||||||
|
|
||||||
|
QPointF begin = curve->GetPoints().first();
|
||||||
if (CountNode() > 1)
|
if (CountNode() > 1)
|
||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
|
@ -544,7 +551,14 @@ QPointF VDetail::StartSegment(const VContainer *data, const int &i) const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QPointF VDetail::EndSegment(const VContainer *data, const int &i) const
|
QPointF VDetail::EndSegment(const VContainer *data, const int &i) const
|
||||||
{
|
{
|
||||||
QPointF end;
|
if (i < 0 && i > CountNode()-1)
|
||||||
|
{
|
||||||
|
return QPointF();
|
||||||
|
}
|
||||||
|
|
||||||
|
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(at(i).getId());
|
||||||
|
|
||||||
|
QPointF end = curve->GetPoints().last();
|
||||||
if (CountNode() > 2)
|
if (CountNode() > 2)
|
||||||
{
|
{
|
||||||
if (i == CountNode() - 1)
|
if (i == CountNode() - 1)
|
||||||
|
|
|
@ -101,10 +101,8 @@ QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF ¢e
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
const bool flagP1 = VGObject::IsPointOnLineSegment (p1.toPoint(), firstPoint.toPoint(),
|
const bool flagP1 = VGObject::IsPointOnLineSegment (p1, firstPoint, secondPoint);
|
||||||
secondPoint.toPoint());
|
const bool flagP2 = VGObject::IsPointOnLineSegment (p2, firstPoint, secondPoint);
|
||||||
const bool flagP2 = VGObject::IsPointOnLineSegment (p2.toPoint(), firstPoint.toPoint(),
|
|
||||||
secondPoint.toPoint());
|
|
||||||
if ((flagP1 == true && flagP2 == true) ||
|
if ((flagP1 == true && flagP2 == true) ||
|
||||||
(flagP1 == false && flagP2 == false)/*In case we have something wrong*/)
|
(flagP1 == false && flagP2 == false)/*In case we have something wrong*/)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user