summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2017-07-03 15:52:07 +0200
committerDavid Tardon <dtardon@redhat.com>2017-07-03 15:52:07 +0200
commit2501d71f919cc3234718634eda82fd81ba9c9e78 (patch)
treeebacafbdbcb97e0efae2d6297510af4b305010fc
parentc156c530df29972d6c9391348ec4351809cfd2e2 (diff)
use VSD_ALMOST_ZERO macro consistently
Change-Id: I8a40d35ac9a90d1e1683172dbff27bfd3250428c
-rw-r--r--src/lib/VSDContentCollector.cpp11
-rw-r--r--src/lib/libvisio_utils.h2
2 files changed, 6 insertions, 7 deletions
diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp
index 98fae36..720ff41 100644
--- a/src/lib/VSDContentCollector.cpp
+++ b/src/lib/VSDContentCollector.cpp
@@ -1327,7 +1327,6 @@ void libvisio::VSDContentCollector::collectDocumentTheme(const VSDXTheme *theme)
m_documentTheme = theme;
}
-#define LIBVISIO_EPSILON 1E-10
void libvisio::VSDContentCollector::collectEllipticalArcTo(unsigned /* id */, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc)
{
_handleLevelChange(level);
@@ -1348,7 +1347,7 @@ void libvisio::VSDContentCollector::collectEllipticalArcTo(unsigned /* id */, un
m_x = x3;
m_y = y3;
- if (fabs(((x1-x2n)*(y2n-y3n) - (x2n-x3n)*(y1-y2n))) <= LIBVISIO_EPSILON || fabs(((x2n-x3n)*(y1-y2n) - (x1-x2n)*(y2n-y3n))) <= LIBVISIO_EPSILON)
+ if (VSD_ALMOST_ZERO(((x1-x2n)*(y2n-y3n) - (x2n-x3n)*(y1-y2n))) || VSD_ALMOST_ZERO(((x2n-x3n)*(y1-y2n) - (x1-x2n)*(y2n-y3n))))
// most probably all of the points lie on the same line, so use lineTo instead
{
librevenge::RVNGPropertyList end;
@@ -2065,10 +2064,10 @@ double libvisio::VSDContentCollector::_NURBSBasis(unsigned knot, unsigned degree
else
return 0;
}
- if (knotVector.size() > knot+degree && fabs(knotVector[knot+degree]-knotVector[knot]) > LIBVISIO_EPSILON)
+ if (knotVector.size() > knot+degree && !VSD_ALMOST_ZERO(knotVector[knot+degree]-knotVector[knot]))
basis = (point-knotVector[knot])/(knotVector[knot+degree]-knotVector[knot]) * _NURBSBasis(knot, degree-1, point, knotVector);
- if (knotVector.size() > knot+degree+1 && fabs(knotVector[knot+degree+1] - knotVector[knot+1]) > LIBVISIO_EPSILON)
+ if (knotVector.size() > knot+degree+1 && !VSD_ALMOST_ZERO(knotVector[knot+degree+1] - knotVector[knot+1]))
basis += (knotVector[knot+degree+1]-point)/(knotVector[knot+degree+1]-knotVector[knot+1]) * _NURBSBasis(knot+1, degree-1, point, knotVector);
return basis;
@@ -2090,7 +2089,7 @@ void libvisio::VSDContentCollector::_generatePolylineFromNURBS(unsigned degree,
node.insert("librevenge:path-action", "L");
double x = 0;
double y = 0;
- double denominator = LIBVISIO_EPSILON;
+ double denominator = VSD_EPSILON;
for (unsigned p = 0; p < controlPoints.size() && p < weights.size(); p++)
{
@@ -2119,7 +2118,7 @@ bool libvisio::VSDContentCollector::_isUniform(const std::vector<double> &weight
double previousValue = weights[0];
for (std::vector<double>::size_type i = 0; i < weights.size(); ++i)
{
- if (fabs(weights[i] - previousValue) < LIBVISIO_EPSILON)
+ if (VSD_ALMOST_ZERO(weights[i] - previousValue))
previousValue = weights[i];
else
return false;
diff --git a/src/lib/libvisio_utils.h b/src/lib/libvisio_utils.h
index 773f5b0..3216ba2 100644
--- a/src/lib/libvisio_utils.h
+++ b/src/lib/libvisio_utils.h
@@ -20,7 +20,7 @@
#include "VSDTypes.h"
-#define VSD_EPSILON 1E-6
+#define VSD_EPSILON 1E-10
#define VSD_ALMOST_ZERO(m) (fabs(m) <= VSD_EPSILON)
#include <librevenge/librevenge.h>