Refactoring. Use more safe function VFuzzyComparePossibleNulls.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-03-23 16:09:30 +02:00
parent 38dac0ada5
commit be7277eeba
35 changed files with 105 additions and 65 deletions

View file

@ -42,4 +42,20 @@ inline QString NameRegExp()
#pragma GCC diagnostic pop
#endif
static inline bool QmuFuzzyComparePossibleNulls(double p1, double p2)
{
if(qFuzzyIsNull(p1))
{
return qFuzzyIsNull(p2);
}
else if(qFuzzyIsNull(p2))
{
return false;
}
else
{
return qFuzzyCompare(p1, p2);
}
}
#endif // QMUDEF_H

View file

@ -389,9 +389,9 @@ qreal QmuParser::Diff(qreal *a_Var, qreal a_fPos, qreal a_fEpsilon) const
// Backwards compatible calculation of epsilon inc case the user doesnt provide
// his own epsilon
if (qFuzzyCompare(fEpsilon + 1, 1 + 0))
if (qFuzzyIsNull(fEpsilon))
{
fEpsilon = (qFuzzyCompare(a_fPos + 1, 1 + 0)) ? static_cast<qreal>(1e-10) : static_cast<qreal>(1e-7) * a_fPos;
fEpsilon = qFuzzyIsNull(a_fPos) ? static_cast<qreal>(1e-10) : static_cast<qreal>(1e-7) * a_fPos;
}
*a_Var = a_fPos+2 * fEpsilon; f[0] = Eval();

View file

@ -20,6 +20,7 @@
******************************************************************************************************/
#include "qmuparserbase.h"
#include "qmudef.h"
#include <QDebug>
#ifdef QMUP_USE_OPENMP
@ -854,7 +855,7 @@ void QmuParserBase::ApplyIfElse(QStack<token_type> &a_stOpt, QStack<token_type>
token_type vVal1 = a_stVal.pop();
token_type vExpr = a_stVal.pop();
a_stVal.push( (qFuzzyCompare(vExpr.GetVal()+1, 1+0)==false) ? vVal1 : vVal2);
a_stVal.push( not qFuzzyIsNull(vExpr.GetVal()) ? vVal1 : vVal2);
token_type opIf = a_stOpt.pop();
Q_ASSERT(opElse.GetCode()==cmELSE);
@ -983,11 +984,11 @@ qreal QmuParserBase::ParseCmdCodeBulk(int nOffset, int nThreadID) const
continue;
case cmNEQ:
--sidx;
Stack[sidx] = (qFuzzyCompare(Stack[sidx], Stack[sidx+1])==false);
Stack[sidx] = not QmuFuzzyComparePossibleNulls(Stack[sidx], Stack[sidx+1]);
continue;
case cmEQ:
--sidx;
Stack[sidx] = qFuzzyCompare(Stack[sidx], Stack[sidx+1]);
Stack[sidx] = QmuFuzzyComparePossibleNulls(Stack[sidx], Stack[sidx+1]);
continue;
case cmLT:
--sidx;
@ -1059,7 +1060,7 @@ qreal QmuParserBase::ParseCmdCodeBulk(int nOffset, int nThreadID) const
//Stack[sidx] = *pTok->Oprt.ptr = Stack[sidx+1];
//continue;
case cmIF:
if (qFuzzyCompare(Stack[sidx--]+1, 1+0))
if (qFuzzyIsNull(Stack[sidx--]))
{
pTok += pTok->Oprt.offset;
}

View file

@ -20,11 +20,12 @@
******************************************************************************************************/
#include "qmuparserbytecode.h"
#include "qmuparsertoken.h"
#include "qmudef.h"
#include <QStack>
#include <QString>
#include <QDebug>
#include "qmuparsertoken.h"
#include <QtCore/qmath.h>
#include <QtGlobal>
@ -165,11 +166,11 @@ void QmuParserByteCode::ConstantFolding(ECmdCode a_Oprt)
m_vRPN.pop_back();
break;
case cmNEQ:
x = (qFuzzyCompare(x, y) == false);
x = not QmuFuzzyComparePossibleNulls(x, y);
m_vRPN.pop_back();
break;
case cmEQ:
x = qFuzzyCompare(x, y);
x = QmuFuzzyComparePossibleNulls(x, y);
m_vRPN.pop_back();
break;
case cmADD:
@ -342,7 +343,7 @@ void QmuParserByteCode::AddOp(ECmdCode a_Oprt)
break;
case cmDIV:
if (m_vRPN.at(sz-1).Cmd == cmVAL && m_vRPN.at(sz-2).Cmd == cmVARMUL &&
(qFuzzyCompare(m_vRPN.at(sz-1).Val.data2+1, 1+0)==false))
not qFuzzyIsNull(m_vRPN.at(sz-1).Val.data2))
{
// Optimization: 4*a/2 -> 2*a
m_vRPN[sz-2].Val.data /= m_vRPN.at(sz-1).Val.data2;

View file

@ -20,6 +20,7 @@
******************************************************************************************************/
#include "qmuparsertest.h"
#include "qmudef.h"
#include <QString>
#include <QDebug>
@ -1345,7 +1346,7 @@ int QmuParserTester::EqnTest ( const QString &a_str, double a_fRes, bool a_fPass
// String parsing and bytecode parsing must yield the same result
fVal[0] = p1->Eval(); // result from stringparsing
fVal[1] = p1->Eval(); // result from bytecode
if ( qFuzzyCompare( fVal[0], fVal[1] ) == false )
if ( not QmuFuzzyComparePossibleNulls( fVal[0], fVal[1] ) )
{
throw QmuParserError ( "Bytecode / string parsing mismatch." );
}
@ -1400,7 +1401,8 @@ int QmuParserTester::EqnTest ( const QString &a_str, double a_fRes, bool a_fPass
#pragma warning(pop)
#endif
{
bCloseEnough &= (qFuzzyCompare( fabs ( fVal[i] ), std::numeric_limits<qreal>::infinity())==false );
bCloseEnough &= (not QmuFuzzyComparePossibleNulls( fabs ( fVal[i] ),
std::numeric_limits<qreal>::infinity()) );
}
}
@ -1422,8 +1424,9 @@ int QmuParserTester::EqnTest ( const QString &a_str, double a_fRes, bool a_fPass
{
if ( a_fPass )
{
if ( (qFuzzyCompare(fVal[0], fVal[2])==false) && (qFuzzyCompare(fVal[0], -999)==false) &&
(qFuzzyCompare(fVal[1], -998 )==false))
if ( not QmuFuzzyComparePossibleNulls(fVal[0], fVal[2]) &&
not QmuFuzzyComparePossibleNulls(fVal[0], -999) &&
not QmuFuzzyComparePossibleNulls(fVal[1], -998 ))
{
qWarning() << "\n fail: " << a_str << " (copy construction)";
}

View file

@ -165,8 +165,8 @@ QPointF VArc::GetP2 () const
*/
qreal VArc::AngleArc() const
{
if ((qFuzzyCompare(d->f1+1, 0+1) && qFuzzyCompare(d->f2, 360)) ||
(qFuzzyCompare(d->f1, 360) && qFuzzyCompare(d->f2+1, 0+1)))
if ((qFuzzyIsNull(d->f1) && qFuzzyCompare(d->f2, 360)) ||
(qFuzzyCompare(d->f1, 360) && qFuzzyIsNull(d->f2)))
{
return 360;
}

View file

@ -198,12 +198,12 @@ QPointF VEllipticalArc::GetPoint (qreal angle) const
{
y = -y;
}
else if (qFuzzyCompare(angle, 90))
else if (VFuzzyComparePossibleNulls(angle, 90))
{
x = 0;
y = d->radius2;
}
else if (qFuzzyCompare(angle, 270))
else if (VFuzzyComparePossibleNulls(angle, 270))
{
x = 0;
y = -d->radius2;

View file

@ -304,7 +304,8 @@ QPointF VGObject::LineIntersectRect(const QRectF &rec, const QLineF &line)
//---------------------------------------------------------------------------------------------------------------------
int VGObject::IntersectionCircles(const QPointF &c1, double r1, const QPointF &c2, double r2, QPointF &p1, QPointF &p2)
{
if (qFuzzyCompare(c1.x(), c2.x()) && qFuzzyCompare(c1.y(), c2.y()) && qFuzzyCompare(r1, r2))
if (VFuzzyComparePossibleNulls(c1.x(), c2.x()) && VFuzzyComparePossibleNulls(c1.y(), c2.y())
&& VFuzzyComparePossibleNulls(r1, r2))
{
return 3;// Circles are equal
}
@ -319,7 +320,7 @@ int VGObject::IntersectionCircles(const QPointF &c1, double r1, const QPointF &c
{
return 0;
}
else if (qFuzzyCompare(c*c, r1*r1*(a*a+b*b)))
else if (VFuzzyComparePossibleNulls(c*c, r1*r1*(a*a+b*b)))
{
p1 = QPointF(x0 + c1.x(), y0 + c1.y());
return 1;
@ -360,7 +361,7 @@ qint32 VGObject::LineIntersectCircle(const QPointF &center, qreal radius, const
// how many solutions?
qint32 flag = 0;
const qreal d = QLineF (center, p).length();
if (qFuzzyCompare(d, radius))
if (VFuzzyComparePossibleNulls(d, radius))
{
flag = 1;
}
@ -507,7 +508,7 @@ double VGObject::GetEpsilon(const QPointF &p1, const QPointF &p2)
int VGObject::PointInCircle(const QPointF &p, const QPointF &center, qreal radius)
{
const double d = QLineF (p, center).length();
if (qFuzzyCompare(radius, d))
if (VFuzzyComparePossibleNulls(radius, d))
{
return 1; // on circle
}

View file

@ -412,7 +412,7 @@ qint32 VSpline::Cubic(QVector<qreal> &x, qreal a, qreal b, qreal c)
x.insert(0, aa+bb-a/3.); // Real root
x.insert(1, (-0.5)*(aa+bb)-a/3.); //Complex root
x.insert(2, (sqrt(3.)*0.5)*fabs(aa-bb)); // Complex root
if (qFuzzyCompare(x.at(2) + 1, 0. + 1))
if (qFuzzyIsNull(x.at(2)))
{
return(2);
}

View file

@ -30,9 +30,11 @@
#define VSPLINEPOINT_P_H
#include <QSharedData>
#include "vpointf.h"
#include <QDebug>
#include "vpointf.h"
#include "../vmisc/def.h"
#ifdef Q_CC_GNU
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
@ -57,9 +59,9 @@ public:
kAsm1(kAsm1),
kAsm2(kAsm2)
{
if (not qFuzzyCompare(qAbs(angle1-angle2), 180) || qFuzzyIsNull(qAbs(angle1-angle2)))
if (VFuzzyComparePossibleNulls(angle1, angle2) || not qFuzzyCompare(qAbs(angle1-angle2), 180) )
{
qDebug()<<"angle1 and angle2 are not equal.";
qDebug()<<"Make angle1 and angle2 correct.";
this->angle1 = angle1;
this->angle2 = angle1 + 180;
}
@ -127,9 +129,9 @@ public:
length2(length2),
length2F(length2F)
{
if (not qFuzzyCompare(qAbs(angle1-angle2), 180) || qFuzzyIsNull(qAbs(angle1-angle2)))
if (VFuzzyComparePossibleNulls(angle1, angle2) || not qFuzzyCompare(qAbs(angle1-angle2), 180))
{
qDebug()<<"angle1 and angle2 are not equal.";
qDebug()<<"Make angle1 and angle2 correct.";
this->angle2 = angle1 + 180;
this->angle2F = QString().number(angle2);
}

View file

@ -501,7 +501,7 @@ VPosition::InsideType VPosition::InsideContour(const VLayoutDetail &detail, cons
const qreal xj = gContour.at(j).x(); //-V807
const qreal yi = gContour.at(i).y();
const qreal yj = gContour.at(j).y();
if (qFuzzyCompare(yj, yi))
if (VFuzzyComparePossibleNulls(yj, yi))
{
constant.insert(i, xi);
multiple.insert(i, 0);
@ -539,7 +539,7 @@ VPosition::InsideType VPosition::InsideContour(const VLayoutDetail &detail, cons
const qreal yi = gContour.at(i).y();
const qreal yj = gContour.at(j).y();
const QPointF &pn = p.at(n);
const QPointF &pn = p.at(n);
if (((yi < pn.y() && yj >= pn.y()) || (yj < pn.y() && yi >= pn.y())))
{
oddNodes ^= (pn.y() * multiple.at(i) + constant.at(i) < pn.x());
@ -586,7 +586,7 @@ void VPosition::CombineEdges(VLayoutDetail &detail, const QLineF &globalEdge, co
// Now we move detail to position near to global contour edge.
detail.Translate(dx, dy);
if (not qFuzzyCompare(angle_between+360, 0+360))
if (not qFuzzyIsNull(angle_between) || not qFuzzyCompare(angle_between, 360))
{
detail.Rotate(detailEdge.p2(), -angle_between);
}
@ -675,7 +675,7 @@ QVector<QPointF> VPosition::CutEdge(const QLineF &edge, quint32 shift)
void VPosition::Rotate(int increase)
{
int startAngle = 0;
if (qFuzzyCompare(angle_between+360, 0+360))
if (VFuzzyComparePossibleNulls(angle_between, 360))
{
startAngle = increase;
}

View file

@ -606,4 +606,20 @@ QSharedPointer<QPrinter> DefaultPrinter();
QPixmap darkenPixmap(const QPixmap &pixmap);
static inline bool VFuzzyComparePossibleNulls(double p1, double p2)
{
if(qFuzzyIsNull(p1))
{
return qFuzzyIsNull(p2);
}
else if(qFuzzyIsNull(p2))
{
return false;
}
else
{
return qFuzzyCompare(p1, p2);
}
}
#endif // DEF_H

View file

@ -94,7 +94,7 @@ void VVariable::SetValue(const qreal &size, const qreal &height, Unit patternUni
//---------------------------------------------------------------------------------------------------------------------
bool VVariable::IsNotUsed() const
{
if (qFuzzyCompare(d->base+1, 0+1) && qFuzzyCompare(d->ksize+1, 0+1) && qFuzzyCompare(d->kheight+1, 0+1))
if (qFuzzyIsNull(d->base) && qFuzzyIsNull(d->ksize) && qFuzzyIsNull(d->kheight))
{
return true;
}

View file

@ -82,7 +82,7 @@ bool VFormula::operator==(const VFormula &formula) const
if (this->formula == formula.GetFormula() && this->value == formula.getStringValue() &&
this->checkZero == formula.getCheckZero() && this->data == formula.getData() &&
this->toolId == formula.getToolId() && this->postfix == formula.getPostfix() &&
this->_error == formula.error() && qFuzzyCompare(this->dValue, formula.getDoubleValue()))
this->_error == formula.error() && VFuzzyComparePossibleNulls(this->dValue, formula.getDoubleValue()))
{
isEqual = true;
}
@ -232,7 +232,7 @@ void VFormula::Eval()
delete cal;
//if result equal 0
if (checkZero && qFuzzyCompare(1 + result, 1 + 0))
if (checkZero && qFuzzyIsNull(result))
{
value = QString("0");
_error = true;

View file

@ -396,7 +396,7 @@ void DialogArc::CheckAngles()
return;
}
if (qFuzzyCompare(angleF1 + 1, angleF2 + 1))
if (VFuzzyComparePossibleNulls(angleF1, angleF2))
{
flagF1 = false;
ChangeColor(ui->labelEditF1, Qt::red);

View file

@ -368,7 +368,7 @@ void DialogArcWithLength::Length()
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
const qreal length = Eval(ui->plainTextEditLength->toPlainText(), flagLength, ui->labelResultLength, postfix);
if (qFuzzyCompare(length+1, 0+1))
if (qFuzzyIsNull(length))
{
flagLength = false;
ChangeColor(labelEditFormula, Qt::red);

View file

@ -480,7 +480,7 @@ qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QSt
delete cal;
//if result equal 0
if (checkZero && qFuzzyCompare(1 + result, 1 + 0))
if (checkZero && qFuzzyIsNull(result))
{
flag = false;
ChangeColor(labelEditFormula, Qt::red);

View file

@ -244,7 +244,7 @@ void VToolArc::SetFormulaF1(const VFormula &value)
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
if (qFuzzyCompare(value.getDoubleValue() + 1, arc->GetEndAngle() + 1)==false)// Angles can't be equal
if (not VFuzzyComparePossibleNulls(value.getDoubleValue(), arc->GetEndAngle()))// Angles can't be equal
{
arc->SetFormulaF1(value.GetFormula(FormulaType::FromUser), value.getDoubleValue());
SaveOption(obj);
@ -272,7 +272,7 @@ void VToolArc::SetFormulaF2(const VFormula &value)
{
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
if (qFuzzyCompare(value.getDoubleValue() + 1, arc->GetStartAngle() + 1)==false)// Angles can't be equal
if (not VFuzzyComparePossibleNulls(value.getDoubleValue(), arc->GetStartAngle()))// Angles can't be equal
{
arc->SetFormulaF2(value.GetFormula(FormulaType::FromUser), value.getDoubleValue());
SaveOption(obj);

View file

@ -213,7 +213,7 @@ void VToolArcWithLength::SetFormulaF1(const VFormula &value)
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
QSharedPointer<VArc> arc = qSharedPointerDynamicCast<VArc>(obj);
if (qFuzzyCompare(value.getDoubleValue() + 1, arc->GetEndAngle() + 1)==false)// Angles can't be equal
if (not VFuzzyComparePossibleNulls(value.getDoubleValue(), arc->GetEndAngle()))// Angles can't be equal
{
arc->SetFormulaF1(value.GetFormula(FormulaType::FromUser), value.getDoubleValue());
SaveOption(obj);

View file

@ -100,7 +100,7 @@ QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Li
qDebug()<<"Correction of length in shoulder point tool. Parameter length too small.";
toolLength = dist;
}
if (qFuzzyCompare(dist, toolLength))
if (VFuzzyComparePossibleNulls(dist, toolLength))
{
return line.p2();
}

View file

@ -112,7 +112,7 @@ void VToolUnionDetails::AddToNewDetail(VMainGraphicsScene *scene, VAbstractPatte
{
case (Tool::NodePoint):
{
if ( qFuzzyCompare(dx+1, 1) && qFuzzyCompare(dy+1, 1) && (pRotate == 0))
if ( qFuzzyIsNull(dx) && qFuzzyIsNull(dy) && (pRotate == 0))
{
id = det.at(i).getId();
}
@ -133,7 +133,7 @@ void VToolUnionDetails::AddToNewDetail(VMainGraphicsScene *scene, VAbstractPatte
break;
case (Tool::NodeArc):
{
if (qFuzzyCompare(dx+1, 1) && qFuzzyCompare(dy+1, 1) && pRotate == 0)
if (qFuzzyIsNull(dx) && qFuzzyIsNull(dy) && pRotate == 0)
{
id = det.at(i).getId();
}
@ -170,7 +170,7 @@ void VToolUnionDetails::AddToNewDetail(VMainGraphicsScene *scene, VAbstractPatte
break;
case (Tool::NodeSpline):
{
if (qFuzzyCompare(dx+1, 1) && qFuzzyCompare(dy+1, 1) && pRotate == 0)
if (qFuzzyIsNull(dx) && qFuzzyIsNull(dy) && pRotate == 0)
{
id = det.at(i).getId();
}
@ -207,7 +207,7 @@ void VToolUnionDetails::AddToNewDetail(VMainGraphicsScene *scene, VAbstractPatte
break;
case (Tool::NodeSplinePath):
{
if (qFuzzyCompare(dx+1, 1) && qFuzzyCompare(dy+1, 1) && pRotate == 0)
if (qFuzzyIsNull(dx) && qFuzzyIsNull(dy) && pRotate == 0)
{
id = det.at(i).getId();
}
@ -297,7 +297,7 @@ void VToolUnionDetails::UpdatePoints(VContainer *data, const VDetail &det, const
{
case (Tool::NodePoint):
{
if (qFuzzyCompare(dx+1, 1) == false || qFuzzyCompare(dy+1, 1) == false || pRotate != 0)
if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != 0)
{
VPointF *point = new VPointF(*data->GeometricObject<VPointF>(det.at(i).getId()));
point->setMode(Draw::Modeling);
@ -308,7 +308,7 @@ void VToolUnionDetails::UpdatePoints(VContainer *data, const VDetail &det, const
break;
case (Tool::NodeArc):
{
if (qFuzzyCompare(dx+1, 1) == false || qFuzzyCompare(dy+1, 1) == false || pRotate != 0)
if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != 0)
{
const QPointF p = data->GeometricObject<VPointF>(pRotate)->toQPointF();
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(det.at(i).getId());
@ -334,7 +334,7 @@ void VToolUnionDetails::UpdatePoints(VContainer *data, const VDetail &det, const
break;
case (Tool::NodeSpline):
{
if (qFuzzyCompare(dx+1, 1) == false || qFuzzyCompare(dy+1, 1) == false || pRotate != 0)
if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != 0)
{
const QSharedPointer<VSpline> spline = data->GeometricObject<VSpline>(det.at(i).getId());
@ -360,7 +360,7 @@ void VToolUnionDetails::UpdatePoints(VContainer *data, const VDetail &det, const
break;
case (Tool::NodeSplinePath):
{
if (qFuzzyCompare(dx+1, 1) == false || qFuzzyCompare(dy+1, 1) == false || pRotate != 0)
if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != 0)
{
VSplinePath *path = new VSplinePath();
path->setMode(Draw::Modeling);

View file

@ -79,7 +79,7 @@ void VisToolAlongLine::RefreshGeometry()
DrawLine(line, QLineF(first->toQPointF(), second->toQPointF()), supportColor);
if (qFuzzyCompare(1 + length, 1 + 0) == false)
if (not qFuzzyIsNull(length))
{
QLineF mainLine = VGObject::BuildLine(first->toQPointF(), length, line->line().angle());
DrawLine(this, mainLine, mainColor, lineStyle);

View file

@ -50,7 +50,7 @@ void VisToolArc::RefreshGeometry()
const QSharedPointer<VPointF> first = Visualization::data->GeometricObject<VPointF>(object1Id);
DrawPoint(arcCenter, first->toQPointF(), supportColor);
if (qFuzzyCompare(1 + radius, 1 + 0) == false && f1 >= 0 && f2 >= 0 && qFuzzyCompare(1 + f1, 1 + f2) == false)
if (not qFuzzyIsNull(radius) && f1 >= 0 && f2 >= 0 && not VFuzzyComparePossibleNulls(f1, f2))
{
VArc arc = VArc (*first, radius, f1, f2);
DrawPath(this, arc.GetPath(PathDirection::Show), mainColor, Qt::SolidLine, Qt::RoundCap);

View file

@ -50,7 +50,7 @@ void VisToolArcWithLength::RefreshGeometry()
const QSharedPointer<VPointF> first = Visualization::data->GeometricObject<VPointF>(object1Id);
DrawPoint(arcCenter, first->toQPointF(), supportColor);
if (qFuzzyCompare(1 + radius, 1 + 0) == false && f1 >= 0 && qFuzzyCompare(1 + length, 1 + 0) == false)
if (not qFuzzyIsNull(radius) && f1 >= 0 && not qFuzzyIsNull(length))
{
VArc arc = VArc (length, *first, radius, f1);
DrawPath(this, arc.GetPath(PathDirection::Show), mainColor, Qt::SolidLine, Qt::RoundCap);

View file

@ -98,7 +98,7 @@ void VisToolBisector::RefreshGeometry()
DrawLine(line2, QLineF(second->toQPointF(), third->toQPointF()), supportColor);
if (qFuzzyCompare(1 + length, 1 + 0) == false)
if (not qFuzzyIsNull(length))
{
qreal angle = VToolBisector::BisectorAngle(first->toQPointF(), second->toQPointF(),
third->toQPointF());

View file

@ -61,7 +61,7 @@ void VisToolCurveIntersectAxis::RefreshGeometry()
{
QLineF axis;
const QSharedPointer<VPointF> first = Visualization::data->GeometricObject<VPointF>(axisPointId);
if (qFuzzyCompare(angle, -1))
if (VFuzzyComparePossibleNulls(angle, -1))
{
axis = Axis(first->toQPointF(), Visualization::scenePos);
}

View file

@ -56,7 +56,7 @@ void VisToolCutArc::RefreshGeometry()
const QSharedPointer<VArc> arc = Visualization::data->GeometricObject<VArc>(object1Id);
DrawPath(this, arc->GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap);
if (qFuzzyCompare(1 + length, 1 + 0) == false)
if (not qFuzzyIsNull(length))
{
VArc ar1;
VArc ar2;

View file

@ -56,7 +56,7 @@ void VisToolCutSpline::RefreshGeometry()
const auto spl = Visualization::data->GeometricObject<VAbstractCubicBezier>(object1Id);
DrawPath(this, spl->GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap);
if (qFuzzyCompare(1 + length, 1 + 0) == false)
if (not qFuzzyIsNull(length))
{
QPointF spl1p2;
QPointF spl1p3;

View file

@ -75,7 +75,7 @@ void VisToolLineIntersectAxis::RefreshGeometry()
{
QLineF axis;
const QSharedPointer<VPointF> third = Visualization::data->GeometricObject<VPointF>(axisPointId);
if (qFuzzyCompare(angle, -1))
if (VFuzzyComparePossibleNulls(angle, -1))
{
axis = Axis(third->toQPointF(), Visualization::scenePos);
}

View file

@ -73,7 +73,7 @@ void VisToolNormal::RefreshGeometry()
QLineF line_mouse(first->toQPointF(), second->toQPointF());
DrawLine(line, line_mouse, supportColor);
if (qFuzzyCompare(1 + length, 1 + 0))
if (qFuzzyIsNull(length))
{
QLineF normal = line_mouse.normalVector();
QPointF endRay = Ray(normal.p1(), normal.angle());

View file

@ -74,7 +74,7 @@ void VisToolPointOfContact::RefreshGeometry()
const QSharedPointer<VPointF> third = Visualization::data->GeometricObject<VPointF>(radiusId);
DrawPoint(arc_point, third->toQPointF(), supportColor);
if (qFuzzyCompare(1 + radius, 1 + 0) == false)
if (not qFuzzyIsNull(radius))
{
QPointF fPoint = VToolPointOfContact::FindPoint(radius, third->toQPointF(), first->toQPointF(),
second->toQPointF());

View file

@ -80,7 +80,7 @@ void VisToolShoulderPoint::RefreshGeometry()
DrawLine(line2, QLineF(second->toQPointF(), third->toQPointF()), supportColor);
if (qFuzzyCompare(1 + length, 1 + 0) == false)
if (not qFuzzyIsNull(length))
{
QPointF fPoint = VToolShoulderPoint::FindPoint(second->toQPointF(), third->toQPointF(),
first->toQPointF(), length);

View file

@ -141,7 +141,7 @@ void VisToolSpline::RefreshGeometry()
}
}
if (qFuzzyCompare(angle1, EMPTY_ANGLE) || qFuzzyCompare(angle2, EMPTY_ANGLE))
if (VFuzzyComparePossibleNulls(angle1, EMPTY_ANGLE) || VFuzzyComparePossibleNulls(angle2, EMPTY_ANGLE))
{
VSpline spline(*first, p2, p3, *second);
DrawPath(this, spline.GetPath(PathDirection::Hide), mainColor, Qt::SolidLine, Qt::RoundCap);

View file

@ -192,7 +192,7 @@ void TST_VArc::TestGetPoints()
{
qreal gSquere = 0.0;// geometry square
if (qFuzzyCompare(arc.AngleArc(), 360.0))
if (VFuzzyComparePossibleNulls(arc.AngleArc(), 360.0))
{// circle square
gSquere = M_PI * radius * radius;
}

View file

@ -335,7 +335,7 @@ void TST_VEllipticalArc::TestGetPoints3()
VEllipticalArc arc(center, radius1, radius2, startAngle, endAngle, rotationAngle);
QVector<QPointF> points = arc.GetPoints();
if (qFuzzyCompare(arc.AngleArc(), 360.0))
if (VFuzzyComparePossibleNulls(arc.AngleArc(), 360.0))
{// calculated full ellipse square
const qreal ellipseSquare = M_PI * radius1 * radius2;
const qreal epsSquare = ellipseSquare * 0.5 / 100; // computing error 0.5 % from origin squere
@ -361,7 +361,7 @@ void TST_VEllipticalArc::TestGetPoints4()
const VPointF center;
VEllipticalArc arc(center, radius1, radius2, startAngle, endAngle, rotationAngle);
if (qFuzzyCompare(arc.AngleArc(), 360.0))
if (VFuzzyComparePossibleNulls(arc.AngleArc(), 360.0))
{// calculated full ellipse length
const qreal h = ((radius1-radius2)*(radius1-radius2))/((radius1+radius2)*(radius1+radius2));
const qreal ellipseLength = M_PI*(radius1+radius2)*(1+3*h/(10+qSqrt(4-3*h)));