summaryrefslogtreecommitdiff
path: root/basegfx
diff options
context:
space:
mode:
authorhdu <duerr@sun.com>2009-10-22 11:39:42 +0200
committerhdu <duerr@sun.com>2009-10-22 11:39:42 +0200
commitab818b36b52e646b43e390d1b6c0140b91a92523 (patch)
tree73609a5e78c54d2ccb89a61cc4c1699f12ba4fb9 /basegfx
parent350ea0397036814992d47c7b836ef6f5005c6e98 (diff)
#i106127# perf: consecutive polygon segments always touch so costly decisions based only on the touch-criterion should be avoided for this case
Diffstat (limited to 'basegfx')
-rw-r--r--basegfx/inc/basegfx/range/b1drange.hxx6
-rw-r--r--basegfx/inc/basegfx/range/b2drange.hxx9
-rw-r--r--basegfx/inc/basegfx/range/basicrange.hxx9
-rw-r--r--basegfx/source/polygon/b2dpolygoncutandtouch.cxx33
4 files changed, 50 insertions, 7 deletions
diff --git a/basegfx/inc/basegfx/range/b1drange.hxx b/basegfx/inc/basegfx/range/b1drange.hxx
index efca06d92dfd..366431c3cd50 100644
--- a/basegfx/inc/basegfx/range/b1drange.hxx
+++ b/basegfx/inc/basegfx/range/b1drange.hxx
@@ -7,7 +7,6 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: b1drange.hxx,v $
- * $Revision: 1.15 $
*
* This file is part of OpenOffice.org.
*
@@ -131,6 +130,11 @@ namespace basegfx
return maRange.overlaps(rRange.maRange);
}
+ bool overlapsMore(const B1DRange& rRange) const
+ {
+ return maRange.overlapsMore(rRange.maRange);
+ }
+
void expand(double fValue)
{
maRange.expand(fValue);
diff --git a/basegfx/inc/basegfx/range/b2drange.hxx b/basegfx/inc/basegfx/range/b2drange.hxx
index 66892865399f..8a70d4782f47 100644
--- a/basegfx/inc/basegfx/range/b2drange.hxx
+++ b/basegfx/inc/basegfx/range/b2drange.hxx
@@ -7,7 +7,6 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: b2drange.hxx,v $
- * $Revision: 1.19 $
*
* This file is part of OpenOffice.org.
*
@@ -222,6 +221,14 @@ namespace basegfx
);
}
+ bool overlapsMore(const B2DRange& rRange) const
+ {
+ return (
+ maRangeX.overlapsMore(rRange.maRangeX)
+ && maRangeY.overlapsMore(rRange.maRangeY)
+ );
+ }
+
void expand(const B2DTuple& rTuple)
{
maRangeX.expand(rTuple.getX());
diff --git a/basegfx/inc/basegfx/range/basicrange.hxx b/basegfx/inc/basegfx/range/basicrange.hxx
index a7c402c905c8..59d13cf530c0 100644
--- a/basegfx/inc/basegfx/range/basicrange.hxx
+++ b/basegfx/inc/basegfx/range/basicrange.hxx
@@ -7,7 +7,6 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: basicrange.hxx,v $
- * $Revision: 1.15 $
*
* This file is part of OpenOffice.org.
*
@@ -142,6 +141,14 @@ namespace basegfx
}
}
+ bool overlapsMore(const BasicRange& rRange) const
+ {
+ if(isEmpty() || rRange.isEmpty())
+ return false;
+ // returns true if the overlap is more than just a touching at the limits
+ return ((rRange.mnMaximum > mnMinimum) && (rRange.mnMinimum < mnMaximum));
+ }
+
bool operator==( const BasicRange& rRange ) const
{
return (mnMinimum == rRange.mnMinimum && mnMaximum == rRange.mnMaximum);
diff --git a/basegfx/source/polygon/b2dpolygoncutandtouch.cxx b/basegfx/source/polygon/b2dpolygoncutandtouch.cxx
index 7597bf1ed11b..e35e22ae3a04 100644
--- a/basegfx/source/polygon/b2dpolygoncutandtouch.cxx
+++ b/basegfx/source/polygon/b2dpolygoncutandtouch.cxx
@@ -567,7 +567,14 @@ namespace basegfx
const bool bEdgeBIsCurve(aCubicB.isBezier());
const B2DRange aRangeB(aCubicB.getRange());
- if(aRangeA.overlaps(aRangeB))
+ // only overlapping segments need to be tested
+ // consecutive segments touch of course
+ bool bOverlap = false;
+ if( b > a+1)
+ bOverlap = aRangeA.overlaps(aRangeB);
+ else
+ bOverlap = aRangeA.overlapsMore(aRangeB);
+ if( bOverlap)
{
if(bEdgeAIsCurve && bEdgeBIsCurve)
{
@@ -609,7 +616,13 @@ namespace basegfx
const B2DPoint aNextB(rCandidate.getB2DPoint(b + 1L == nPointCount ? 0L : b + 1L));
const B2DRange aRangeB(aCurrB, aNextB);
- if(aRangeA.overlaps(aRangeB))
+ // consecutive segments touch of course
+ bool bOverlap = false;
+ if( b > a+1)
+ bOverlap = aRangeA.overlaps(aRangeB);
+ else
+ bOverlap = aRangeA.overlapsMore(aRangeB);
+ if( bOverlap)
{
findEdgeCutsTwoEdges(aCurrA, aNextA, aCurrB, aNextB, a, b, rTempPoints, rTempPoints);
}
@@ -806,7 +819,13 @@ namespace basegfx
const bool bEdgeBIsCurve(aCubicB.isBezier());
const B2DRange aRangeB(aCubicB.getRange());
- if(aRangeA.overlaps(aRangeB))
+ // consecutive segments touch of course
+ bool bOverlap = false;
+ if( b > a+1)
+ bOverlap = aRangeA.overlaps(aRangeB);
+ else
+ bOverlap = aRangeA.overlapsMore(aRangeB);
+ if( bOverlap)
{
if(bEdgeAIsCurve && bEdgeBIsCurve)
{
@@ -848,7 +867,13 @@ namespace basegfx
const B2DPoint aNextB(rCandidateB.getB2DPoint(b + 1L == nPointCountB ? 0L : b + 1L));
const B2DRange aRangeB(aCurrB, aNextB);
- if(aRangeA.overlaps(aRangeB))
+ // consecutive segments touch of course
+ bool bOverlap = false;
+ if( b > a+1)
+ bOverlap = aRangeA.overlaps(aRangeB);
+ else
+ bOverlap = aRangeA.overlapsMore(aRangeB);
+ if( bOverlap)
{
// test for simple edge-edge cuts
findEdgeCutsTwoEdges(aCurrA, aNextA, aCurrB, aNextB, a, b, rTempPointsA, rTempPointsB);