summaryrefslogtreecommitdiff
path: root/basegfx/source/polygon
diff options
context:
space:
mode:
authorRĂ¼diger Timm <rt@openoffice.org>2004-12-13 07:48:11 +0000
committerRĂ¼diger Timm <rt@openoffice.org>2004-12-13 07:48:11 +0000
commit66ecdf3c952231c593f45342be114b8320550ecc (patch)
tree03b8de3725a1b844ba8ce78cdf00d28163b10642 /basegfx/source/polygon
parent11cb3daead3bf3a6c43522b05af4fcf57ff147ab (diff)
INTEGRATION: CWS aw022 (1.14.2); FILE MERGED
2004/11/25 11:09:19 aw 1.14.2.2: #i37443# 2004/11/18 11:47:38 aw 1.14.2.1: #i37380#
Diffstat (limited to 'basegfx/source/polygon')
-rw-r--r--basegfx/source/polygon/b2dpolygontools.cxx92
1 files changed, 82 insertions, 10 deletions
diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx
index ef92305a1ed0..24fdabab58bc 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpolygontools.cxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: rt $ $Date: 2004-11-26 18:38:29 $
+ * last change: $Author: rt $ $Date: 2004-12-13 08:48:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -97,6 +97,14 @@
#include <numeric>
+// #i37443#
+#define ANGLE_BOUND_START_VALUE (2.25)
+#define ANGLE_BOUND_MINIMUM_VALUE (0.1)
+#define COUNT_SUBDIVIDE_DEFAULT (4L)
+#ifdef DBG_UTIL
+static double fAngleBoundStartValue = ANGLE_BOUND_START_VALUE;
+#endif
+
//////////////////////////////////////////////////////////////////////////////
namespace basegfx
@@ -319,6 +327,20 @@ namespace basegfx
const sal_uInt32 nPointCount(rCandidate.isClosed() ? rCandidate.count() : rCandidate.count() - 1L);
aRetval.clear();
+ // #i37443# prepare convenient AngleBound if none was given
+ if(0.0 == fAngleBound)
+ {
+#ifdef DBG_UTIL
+ fAngleBound = fAngleBoundStartValue;
+#else
+ fAngleBound = ANGLE_BOUND_START_VALUE;
+#endif
+ }
+ else if(fTools::less(fAngleBound, ANGLE_BOUND_MINIMUM_VALUE))
+ {
+ fAngleBound = 0.1;
+ }
+
for(sal_uInt32 a(0L); a < nPointCount; a++)
{
const B2DVector aVectorA(rCandidate.getControlVectorA(a));
@@ -335,17 +357,67 @@ namespace basegfx
B2DCubicBezier aBezier(
aPointA, B2DPoint(aPointA + aVectorA), B2DPoint(aPointA + aVectorB), aPointB);
- // generate AngleBound
- double fBound(fAngleBound);
+ // call adaptive subdivide, do not add last point
+ // #i37443# allow unsharpen the criteria
+ aBezier.adaptiveSubdivideByAngle(aRetval, fAngleBound, false, true);
+ }
+ else
+ {
+ // no vectors used, add point
+ aRetval.append(rCandidate.getB2DPoint(a));
+ }
+ }
- // make sure angle bound is not too small
- if(fTools::less(fAngleBound, 0.1))
- {
- fAngleBound = 0.1;
- }
+ // add last point if not closed. If the last point had vectors,
+ // they are lost since they make no sense.
+ if(!rCandidate.isClosed())
+ {
+ aRetval.append(rCandidate.getB2DPoint(rCandidate.count() - 1));
+ }
+
+ // check closed flag, aRetval was cleared and thus it may be invalid.
+ if(aRetval.isClosed() != rCandidate.isClosed())
+ {
+ aRetval.setClosed(rCandidate.isClosed());
+ }
+ }
+
+ return aRetval;
+ }
+
+ B2DPolygon adaptiveSubdivideByCount(const B2DPolygon& rCandidate, sal_uInt32 nCount)
+ {
+ B2DPolygon aRetval(rCandidate);
+
+ if(aRetval.areControlPointsUsed())
+ {
+ const sal_uInt32 nPointCount(rCandidate.isClosed() ? rCandidate.count() : rCandidate.count() - 1L);
+ aRetval.clear();
+
+ // #i37443# prepare convenient count if none was given
+ if(0L == nCount)
+ {
+ nCount = COUNT_SUBDIVIDE_DEFAULT;
+ }
+
+ for(sal_uInt32 a(0L); a < nPointCount; a++)
+ {
+ const B2DVector aVectorA(rCandidate.getControlVectorA(a));
+ const B2DVector aVectorB(rCandidate.getControlVectorB(a));
+
+ if(!aVectorA.equalZero() || !aVectorB.equalZero())
+ {
+ // vectors are used, get points
+ const sal_uInt32 nNext(getIndexOfSuccessor(a, rCandidate));
+ B2DPoint aPointA(rCandidate.getB2DPoint(a));
+ B2DPoint aPointB(rCandidate.getB2DPoint(nNext));
+
+ // build CubicBezier segment
+ B2DCubicBezier aBezier(
+ aPointA, B2DPoint(aPointA + aVectorA), B2DPoint(aPointA + aVectorB), aPointB);
// call adaptive subdivide, do not add last point
- adaptiveSubdivideByAngle(aRetval, aBezier, fBound, false);
+ aBezier.adaptiveSubdivideByCount(aRetval, nCount, false);
}
else
{