diff options
Diffstat (limited to 'basegfx')
-rw-r--r-- | basegfx/source/curve/b2dcubicbezier.cxx | 55 | ||||
-rw-r--r-- | basegfx/source/polygon/b2dtrapezoid.cxx | 3 | ||||
-rw-r--r-- | basegfx/test/basegfx1d.cxx | 2 | ||||
-rw-r--r-- | basegfx/test/basegfx2d.cxx | 2 | ||||
-rw-r--r-- | basegfx/test/basegfx3d.cxx | 2 | ||||
-rw-r--r-- | basegfx/test/basegfxtools.cxx | 2 | ||||
-rw-r--r-- | basegfx/test/boxclipper.cxx | 2 | ||||
-rw-r--r-- | basegfx/test/clipstate.cxx | 2 | ||||
-rw-r--r-- | basegfx/test/genericclipper.cxx | 2 | ||||
-rw-r--r-- | basegfx/test/makefile.mk | 7 |
10 files changed, 50 insertions, 29 deletions
diff --git a/basegfx/source/curve/b2dcubicbezier.cxx b/basegfx/source/curve/b2dcubicbezier.cxx index 80bd8922160b..adf819a214a1 100644 --- a/basegfx/source/curve/b2dcubicbezier.cxx +++ b/basegfx/source/curve/b2dcubicbezier.cxx @@ -996,12 +996,11 @@ namespace basegfx if( fD >= 0.0 ) { const double fS = sqrt(fD); - // same as above but for very small fAX and/or fCX - // this has much better numerical stability - // see NRC chapter 5-6 (thanks THB!) - const double fQ = fBX + ((fBX >= 0) ? +fS : -fS); + // calculate both roots (avoiding a numerically unstable subtraction) + const double fQ = -(fBX + ((fBX >= 0) ? +fS : -fS)); impCheckExtremumResult(fQ / fAX, rResults); - impCheckExtremumResult(fCX / fQ, rResults); + if( fD > 0.0 ) // ignore root multiplicity + impCheckExtremumResult(fCX / fQ, rResults); } } else if( !fTools::equalZero(fBX) ) @@ -1028,12 +1027,11 @@ namespace basegfx if( fD >= 0 ) { const double fS = sqrt(fD); - // same as above but for very small fAX and/or fCX - // this has much better numerical stability - // see NRC chapter 5-6 (thanks THB!) - const double fQ = fBY + ((fBY >= 0) ? +fS : -fS); + // calculate both roots (avoiding a numerically unstable subtraction) + const double fQ = -(fBY + ((fBY >= 0) ? +fS : -fS)); impCheckExtremumResult(fQ / fAY, rResults); - impCheckExtremumResult(fCY / fQ, rResults); + if( fD > 0.0 ) // ignore root multiplicity, TODO: use equalZero() instead? + impCheckExtremumResult(fCY / fQ, rResults); } } else if( !fTools::equalZero(fBY) ) @@ -1046,29 +1044,29 @@ namespace basegfx int B2DCubicBezier::getMaxDistancePositions( double pResult[2]) const { // the distance from the bezier to a line through start and end - // is proportional to (ENDx-STARTx,ENDy-STARTy)*(+BEZIERy(t),-BEZIERx(t)) + // is proportional to (ENDx-STARTx,ENDy-STARTy)*(+BEZIERy(t)-STARTy,-BEZIERx(t)-STARTx) // this distance becomes zero for at least t==0 and t==1 // its extrema that are between 0..1 are interesting as split candidates // its derived function has the form dD/dt = fA*t^2 + 2*fB*t + fC const B2DPoint aRelativeEndPoint(maEndPoint-maStartPoint); - const double fA = 3 * (maEndPoint.getX() - maControlPointB.getX()) * aRelativeEndPoint.getY() - - 3 * (maEndPoint.getY() - maControlPointB.getY()) * aRelativeEndPoint.getX(); - const double fB = (maControlPointB.getX() - maControlPointA.getX()) * aRelativeEndPoint.getY() - - (maControlPointB.getY() - maControlPointA.getY()) * aRelativeEndPoint.getX(); + const double fA = (3 * (maControlPointA.getX() - maControlPointB.getX()) + aRelativeEndPoint.getX()) * aRelativeEndPoint.getY() + - (3 * (maControlPointA.getY() - maControlPointB.getY()) + aRelativeEndPoint.getY()) * aRelativeEndPoint.getX(); + const double fB = (maControlPointB.getX() - 2 * maControlPointA.getX() + maStartPoint.getX()) * aRelativeEndPoint.getY() + - (maControlPointB.getY() - 2 * maControlPointA.getY() + maStartPoint.getY()) * aRelativeEndPoint.getX(); const double fC = (maControlPointA.getX() - maStartPoint.getX()) * aRelativeEndPoint.getY() - (maControlPointA.getY() - maStartPoint.getY()) * aRelativeEndPoint.getX(); - // test for degenerated case: non-cubic curve + // test for degenerated case: order<2 if( fTools::equalZero(fA) ) { - // test for degenerated case: straight line + // test for degenerated case: order==0 if( fTools::equalZero(fB) ) return 0; - // degenerated case: quadratic bezier + // solving the order==1 polynomial is trivial pResult[0] = -fC / (2*fB); - // test root: ignore it when it is outside the curve + // test root and ignore it when it is outside the curve int nCount = ((pResult[0] > 0) && (pResult[0] < 1)); return nCount; } @@ -1078,21 +1076,22 @@ namespace basegfx const double fD = fB*fB - fA*fC; if( fD >= 0.0 ) // TODO: is this test needed? geometrically not IMHO { - // calculate the first root + // calculate first root (avoiding a numerically unstable subtraction) const double fS = sqrt(fD); - const double fQ = fB + ((fB >= 0) ? +fS : -fS); + const double fQ = -(fB + ((fB >= 0) ? +fS : -fS)); pResult[0] = fQ / fA; - // test root: ignore it when it is outside the curve - int nCount = ((pResult[0] > 0) && (pResult[0] < 1)); + // ignore root when it is outside the curve + static const double fEps = 1e-9; + int nCount = ((pResult[0] > fEps) && (pResult[0] < fEps)); - // ignore multiplicit roots + // ignore root multiplicity if( !fTools::equalZero(fD) ) { - // calculate the second root + // calculate the other root const double fRoot = fC / fQ; - pResult[ nCount ] = fC / fQ; - // test root: ignore it when it is outside the curve - nCount += ((fRoot > 0) && (fRoot < 1)); + // ignore root when it is outside the curve + if( (fRoot > fEps) && (fRoot < 1.0-fEps) ) + pResult[ nCount++ ] = fRoot; } return nCount; diff --git a/basegfx/source/polygon/b2dtrapezoid.cxx b/basegfx/source/polygon/b2dtrapezoid.cxx index 4cd63f938114..c1e0f7f6c7c1 100644 --- a/basegfx/source/polygon/b2dtrapezoid.cxx +++ b/basegfx/source/polygon/b2dtrapezoid.cxx @@ -1161,7 +1161,8 @@ namespace basegfx if(aSource.areControlPointsUsed()) { - aSource = aSource.getDefaultAdaptiveSubdivision(); + const double fPrecisionFactor = 0.25; + aSource = adaptiveSubdivideByDistance( aSource, fLineWidth * fPrecisionFactor ); } const sal_uInt32 nPointCount(aSource.count()); diff --git a/basegfx/test/basegfx1d.cxx b/basegfx/test/basegfx1d.cxx index 41ac65da56e3..9b189bd8b236 100644 --- a/basegfx/test/basegfx1d.cxx +++ b/basegfx/test/basegfx1d.cxx @@ -30,10 +30,12 @@ #include "precompiled_basegfx.hxx" // autogenerated file with codegen.pl +#include "preextstl.h" #include "cppunit/TestAssert.h" #include "cppunit/TestFixture.h" #include "cppunit/extensions/HelperMacros.h" #include "cppunit/plugin/TestPlugIn.h" +#include "postextstl.h" namespace basegfx1d { diff --git a/basegfx/test/basegfx2d.cxx b/basegfx/test/basegfx2d.cxx index 31005a158982..53501d190c03 100644 --- a/basegfx/test/basegfx2d.cxx +++ b/basegfx/test/basegfx2d.cxx @@ -30,9 +30,11 @@ #include "precompiled_basegfx.hxx" // autogenerated file with codegen.pl +#include "preextstl.h" #include "cppunit/TestAssert.h" #include "cppunit/TestFixture.h" #include "cppunit/extensions/HelperMacros.h" +#include "postextstl.h" #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/polygon/b2dpolygon.hxx> diff --git a/basegfx/test/basegfx3d.cxx b/basegfx/test/basegfx3d.cxx index a16132e0810f..4871dcbd16c4 100644 --- a/basegfx/test/basegfx3d.cxx +++ b/basegfx/test/basegfx3d.cxx @@ -30,9 +30,11 @@ #include "precompiled_basegfx.hxx" // autogenerated file with codegen.pl +#include "preextstl.h" #include "cppunit/TestAssert.h" #include "cppunit/TestFixture.h" #include "cppunit/extensions/HelperMacros.h" +#include "postextstl.h" namespace basegfx3d { diff --git a/basegfx/test/basegfxtools.cxx b/basegfx/test/basegfxtools.cxx index 1a8b97a559b2..7e385f1eb78c 100644 --- a/basegfx/test/basegfxtools.cxx +++ b/basegfx/test/basegfxtools.cxx @@ -30,9 +30,11 @@ #include "precompiled_basegfx.hxx" // autogenerated file with codegen.pl +#include "preextstl.h" #include "cppunit/TestAssert.h" #include "cppunit/TestFixture.h" #include "cppunit/extensions/HelperMacros.h" +#include "postextstl.h" #include <basegfx/tools/keystoplerp.hxx> #include <basegfx/numeric/ftools.hxx> diff --git a/basegfx/test/boxclipper.cxx b/basegfx/test/boxclipper.cxx index d52218a51ee0..b1e08087136f 100644 --- a/basegfx/test/boxclipper.cxx +++ b/basegfx/test/boxclipper.cxx @@ -30,9 +30,11 @@ #include "precompiled_basegfx.hxx" // autogenerated file with codegen.pl +#include "preextstl.h" #include "cppunit/TestAssert.h" #include "cppunit/TestFixture.h" #include "cppunit/extensions/HelperMacros.h" +#include "postextstl.h" #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/curve/b2dcubicbezier.hxx> diff --git a/basegfx/test/clipstate.cxx b/basegfx/test/clipstate.cxx index 3d9f59979aa7..48c1e5967260 100644 --- a/basegfx/test/clipstate.cxx +++ b/basegfx/test/clipstate.cxx @@ -30,9 +30,11 @@ #include "precompiled_basegfx.hxx" // autogenerated file with codegen.pl +#include "preextstl.h" #include "cppunit/TestAssert.h" #include "cppunit/TestFixture.h" #include "cppunit/extensions/HelperMacros.h" +#include "postextstl.h" #include <basegfx/tools/b2dclipstate.hxx> #include <basegfx/range/b2dpolyrange.hxx> diff --git a/basegfx/test/genericclipper.cxx b/basegfx/test/genericclipper.cxx index 84230a084493..d6c97c0567dc 100644 --- a/basegfx/test/genericclipper.cxx +++ b/basegfx/test/genericclipper.cxx @@ -30,9 +30,11 @@ #include "precompiled_basegfx.hxx" // autogenerated file with codegen.pl +#include "preextstl.h" #include "cppunit/TestAssert.h" #include "cppunit/TestFixture.h" #include "cppunit/extensions/HelperMacros.h" +#include "postextstl.h" #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/curve/b2dcubicbezier.hxx> diff --git a/basegfx/test/makefile.mk b/basegfx/test/makefile.mk index 2c0f30c291a9..09d8b805f9f5 100644 --- a/basegfx/test/makefile.mk +++ b/basegfx/test/makefile.mk @@ -36,6 +36,13 @@ ENABLE_EXCEPTIONS=TRUE .INCLUDE : settings.mk +#building with stlport, but cppunit was not built with stlport +.IF "$(USE_SYSTEM_STL)"!="YES" +.IF "$(SYSTEM_CPPUNIT)"=="YES" +CFLAGSCXX+=-DADAPT_EXT_STL +.ENDIF +.ENDIF + CFLAGSCXX += $(CPPUNIT_CFLAGS) # --- Common ---------------------------------------------------------- |