diff options
author | Oliver Bolte <obo@openoffice.org> | 2007-07-18 10:05:55 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2007-07-18 10:05:55 +0000 |
commit | faf6e9c244eb811e5a71d6e7d237f519fd7af91d (patch) | |
tree | c76dcf03a044c5a08c5fec9276164de22f5b2856 /basegfx/source/polygon/b2dpolygonclipper.cxx | |
parent | INTEGRATION: CWS aw051 (1.18.24); FILE MERGED (diff) | |
download | core-faf6e9c244eb811e5a71d6e7d237f519fd7af91d.tar.gz core-faf6e9c244eb811e5a71d6e7d237f519fd7af91d.zip |
INTEGRATION: CWS aw051 (1.4.30); FILE MERGED
2007/06/07 09:32:49 aw 1.4.30.2: #i77162# changes to B2DPolygon bezier handling
2007/06/06 15:49:41 aw 1.4.30.1: #i77162# B2DPolygin control point interface changes
Diffstat (limited to 'basegfx/source/polygon/b2dpolygonclipper.cxx')
-rw-r--r-- | basegfx/source/polygon/b2dpolygonclipper.cxx | 109 |
1 files changed, 53 insertions, 56 deletions
diff --git a/basegfx/source/polygon/b2dpolygonclipper.cxx b/basegfx/source/polygon/b2dpolygonclipper.cxx index 8566f696c3f6..e7668a08ee01 100644 --- a/basegfx/source/polygon/b2dpolygonclipper.cxx +++ b/basegfx/source/polygon/b2dpolygonclipper.cxx @@ -4,9 +4,9 @@ * * $RCSfile: b2dpolygonclipper.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: obo $ $Date: 2006-09-17 08:01:32 $ + * last change: $Author: obo $ $Date: 2007-07-18 11:05:55 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -443,77 +443,74 @@ namespace basegfx if(nPointCount) { const sal_uInt32 nEdgeCount(aCandidate.isClosed() ? nPointCount : nPointCount - 1L); - B2DPolygon aRun; - B2DPoint aCurrent(aCandidate.getB2DPoint(0L)); - for(sal_uInt32 b(0L); b < nEdgeCount; b++) + if(nEdgeCount) { - B2DVector aControlVectorA; - B2DVector aControlVectorB; - bool bCurveEdge(false); - - if(aCandidate.areControlPointsUsed()) + // prepare partial polygon + B2DPolygon aRun; + B2DPoint aCurrent(aCandidate.getB2DPoint(0L)); + B2DPoint aControlPointPrev; + B2DPoint aControlPointNext; + bool bInside(false); + + for(sal_uInt32 b(0L); b < nEdgeCount; b++) { - aControlVectorA = aCandidate.getControlVectorA(b); - aControlVectorB = aCandidate.getControlVectorB(b); - bCurveEdge = !(aControlVectorA.equalZero() && aControlVectorB.equalZero()); - } - - const sal_uInt32 nNextIndex((b + 1L == nPointCount) ? 0L : b + 1L); - const B2DPoint aNext(aCandidate.getB2DPoint(nNextIndex)); - B2DPoint aComparePoint; + const sal_uInt32 nNextIndex((b + 1L) % nPointCount); + const B2DPoint aNext(aCandidate.getB2DPoint(nNextIndex)); + bool bCurveEdge(false); - if(bCurveEdge) - { - B2DCubicBezier aCubicBezier(aCurrent, aControlVectorA, aControlVectorB, aNext); - aComparePoint = aCubicBezier.interpolatePoint(0.5); - } - else - { - aComparePoint = average(aCurrent, aNext); - } + if(aCandidate.areControlPointsUsed()) + { + aControlPointNext = aCandidate.getNextControlPoint(b); + aControlPointPrev = aCandidate.getPrevControlPoint(nNextIndex); + bCurveEdge = !aControlPointNext.equal(aCurrent) || !aControlPointPrev.equal(aNext); + } - const bool bInside(isInside(rClip, aComparePoint) != bInvert); + if(bCurveEdge) + { + const B2DCubicBezier aCubicBezier(aCurrent, aControlPointNext, aControlPointPrev, aNext); + const B2DPoint aComparePoint(aCubicBezier.interpolatePoint(0.5)); + bInside = (isInside(rClip, aComparePoint) != bInvert); + } + else + { + const B2DPoint aComparePoint(average(aCurrent, aNext)); + bInside = (isInside(rClip, aComparePoint) != bInvert); + } - if(bInside) - { - if(!aRun.count()) + if(bInside) { - aRun.append(aCurrent); + if(!aRun.count()) + { + aRun.append(aCurrent); + } if(bCurveEdge) { - const sal_uInt32 nNextRunIndex(aRun.count() - 1L); - aRun.setControlVectorA(nNextRunIndex, aControlVectorA); - aRun.setControlVectorB(nNextRunIndex, aControlVectorB); + aRun.appendBezierSegment(aControlPointNext, aControlPointPrev, aNext); + } + else + { + aRun.append(aNext); } } - - aRun.append(aNext); - - if(bCurveEdge) + else { - const sal_uInt32 nNextRunIndex(aRun.count() - 1L); - aRun.setControlVectorA(nNextRunIndex, aCandidate.getControlVectorA(nNextIndex)); - aRun.setControlVectorB(nNextRunIndex, aCandidate.getControlVectorB(nNextIndex)); + if(aRun.count()) + { + aRetval.append(aRun); + aRun.clear(); + } } + + // prepare next step + aCurrent = aNext; } - else + + if(aRun.count()) { - if(aRun.count()) - { - aRetval.append(aRun); - aRun.clear(); - } + aRetval.append(aRun); } - - // prepare next step - aCurrent = aNext; - } - - if(aRun.count()) - { - aRetval.append(aRun); } } } |