diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2008-08-19 23:03:21 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2008-08-19 23:03:21 +0000 |
commit | ce1a9b8fc4d4f9970f1465be74f1b74beac4e74c (patch) | |
tree | 385f47fd11c789a2737e8527b5a0161e446856a4 /basegfx | |
parent | 394b10d8f53742a7ab87248a92c04412f5e4aa54 (diff) |
INTEGRATION: CWS aw033 (1.12.2); FILE MERGED
2008/05/14 14:40:10 aw 1.12.2.13: RESYNC: (1.16-1.18); FILE MERGED
2007/12/12 13:13:34 aw 1.12.2.12: #i39532# clipping changes
2007/11/26 11:21:59 aw 1.12.2.11: #i39532# reworked B2DPolygon default decomposition
2007/11/22 14:56:58 aw 1.12.2.10: #i39532# polygon bezier changes
2007/11/19 10:17:03 aw 1.12.2.9: #i39532# Lot of changes to make polygon stuff bezier-able
2007/11/07 14:24:30 aw 1.12.2.8: #i39532# committing to have a base for HDU
2007/10/17 10:41:29 aw 1.12.2.7: #i39532# support for reSegmentPolygonEdges
2007/08/09 22:04:35 aw 1.12.2.6: RESYNC: (1.15-1.16); FILE MERGED
2006/09/27 16:29:23 aw 1.12.2.5: #i39532# changes after resync to m185
2006/09/26 14:50:29 aw 1.12.2.4: RESYNC: (1.13-1.15); FILE MERGED
2006/05/12 14:35:51 aw 1.12.2.3: RESYNC: (1.12-1.13); FILE MERGED
2006/05/12 11:36:07 aw 1.12.2.2: code changes for primitive support
2005/10/28 11:24:15 aw 1.12.2.1: #i39532#
Diffstat (limited to 'basegfx')
-rw-r--r-- | basegfx/source/polygon/b2dpolypolygontools.cxx | 224 |
1 files changed, 126 insertions, 98 deletions
diff --git a/basegfx/source/polygon/b2dpolypolygontools.cxx b/basegfx/source/polygon/b2dpolypolygontools.cxx index df37532ec66c..7d2f6dcc8f01 100644 --- a/basegfx/source/polygon/b2dpolypolygontools.cxx +++ b/basegfx/source/polygon/b2dpolypolygontools.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: b2dpolypolygontools.cxx,v $ - * $Revision: 1.18 $ + * $Revision: 1.19 $ * * This file is part of OpenOffice.org. * @@ -84,24 +84,48 @@ namespace basegfx return aRetval; } - B2DPolyPolygon removeIntersections(const B2DPolyPolygon& rCandidate) + B2DPolyPolygon correctOutmostPolygon(const B2DPolyPolygon& rCandidate) { - return SolveCrossovers(rCandidate, false); - } + const sal_uInt32 nCount(rCandidate.count()); - B2DPolyPolygon removeAllIntersections(const B2DPolyPolygon& rCandidate) - { - return SolveCrossovers(rCandidate); - } + if(nCount > 1L) + { + for(sal_uInt32 a(0L); a < nCount; a++) + { + const B2DPolygon aCandidate(rCandidate.getB2DPolygon(a)); + sal_uInt32 nDepth(0L); - B2DPolyPolygon removeNeutralPolygons(const B2DPolyPolygon& rCandidate, bool bUseOr) - { - B2DPolyPolygon aRetval(rCandidate); + for(sal_uInt32 b(0L); b < nCount; b++) + { + if(b != a) + { + const B2DPolygon aCompare(rCandidate.getB2DPolygon(b)); - aRetval = StripNeutralPolygons(aRetval); - aRetval = StripDispensablePolygons(aRetval, !bUseOr); + if(tools::isInside(aCompare, aCandidate, true)) + { + nDepth++; + } + } + } - return aRetval; + if(!nDepth) + { + B2DPolyPolygon aRetval(rCandidate); + + if(a != 0L) + { + // exchange polygon a and polygon 0L + aRetval.setB2DPolygon(0L, aCandidate); + aRetval.setB2DPolygon(a, rCandidate.getB2DPolygon(0L)); + } + + // exit + return aRetval; + } + } + } + + return rCandidate; } B2DPolyPolygon adaptiveSubdivideByDistance(const B2DPolyPolygon& rCandidate, double fDistanceBound) @@ -218,7 +242,7 @@ namespace basegfx } } - B2DRange getRange(const B2DPolyPolygon& rCandidate) + B2DRange getRangeWithControlPoints(const B2DPolyPolygon& rCandidate) { B2DRange aRetval; const sal_uInt32 nPolygonCount(rCandidate.count()); @@ -226,116 +250,60 @@ namespace basegfx for(sal_uInt32 a(0L); a < nPolygonCount; a++) { B2DPolygon aCandidate = rCandidate.getB2DPolygon(a); - aRetval.expand(tools::getRange(aCandidate)); + aRetval.expand(tools::getRangeWithControlPoints(aCandidate)); } return aRetval; } - B2DPolyPolygon applyLineDashing(const B2DPolyPolygon& rCandidate, const ::std::vector<double>& raDashDotArray, double fFullDashDotLen) + B2DRange getRange(const B2DPolyPolygon& rCandidate) { - B2DPolyPolygon aRetval; - - if(0.0 == fFullDashDotLen && raDashDotArray.size()) - { - // calculate fFullDashDotLen from raDashDotArray - fFullDashDotLen = ::std::accumulate(raDashDotArray.begin(), raDashDotArray.end(), 0.0); - } + B2DRange aRetval; + const sal_uInt32 nPolygonCount(rCandidate.count()); - if(rCandidate.count() && fFullDashDotLen > 0.0) + for(sal_uInt32 a(0L); a < nPolygonCount; a++) { - for(sal_uInt32 a(0L); a < rCandidate.count(); a++) - { - B2DPolygon aCandidate = rCandidate.getB2DPolygon(a); - aRetval.append(applyLineDashing(aCandidate, raDashDotArray, fFullDashDotLen)); - } + B2DPolygon aCandidate = rCandidate.getB2DPolygon(a); + aRetval.expand(tools::getRange(aCandidate)); } return aRetval; } - B2DPolyPolygon mergeDashedLines(const B2DPolyPolygon& rCandidate) + void applyLineDashing(const B2DPolyPolygon& rCandidate, const ::std::vector<double>& rDotDashArray, B2DPolyPolygon* pLineTarget, B2DPolyPolygon* pGapTarget, double fFullDashDotLen) { - B2DPolyPolygon aRetval; - const sal_uInt32 nPolygonCount(rCandidate.count()); + if(0.0 == fFullDashDotLen && rDotDashArray.size()) + { + // calculate fFullDashDotLen from rDotDashArray + fFullDashDotLen = ::std::accumulate(rDotDashArray.begin(), rDotDashArray.end(), 0.0); + } - if(nPolygonCount) + if(rCandidate.count() && fFullDashDotLen > 0.0) { - B2DPolygon aMergePolygon; + B2DPolyPolygon aLineTarget, aGapTarget; - for(sal_uInt32 a(0L); a < nPolygonCount; a++) + for(sal_uInt32 a(0L); a < rCandidate.count(); a++) { - if(aMergePolygon.count()) - { - B2DPolygon aNewCandidate = rCandidate.getB2DPolygon(a); + const B2DPolygon aCandidate(rCandidate.getB2DPolygon(a)); - if(aNewCandidate.count()) - { - // does aNewCandidate start where aMergePolygon ends? - if(aNewCandidate.getB2DPoint(0L) == aMergePolygon.getB2DPoint(aMergePolygon.count() - 1L)) - { - // copy remaining points to aMergePolygon - for(sal_uInt32 b(1L); b < aNewCandidate.count(); b++) - { - aMergePolygon.append(aNewCandidate.getB2DPoint(b)); - } - } - else - { - // new start point, add aMergePolygon - aRetval.append(aMergePolygon); + applyLineDashing( + aCandidate, + rDotDashArray, + pLineTarget ? &aLineTarget : 0, + pGapTarget ? &aGapTarget : 0, + fFullDashDotLen); - // set aMergePolygon to the new polygon - aMergePolygon = aNewCandidate; - } - } - } - else + if(pLineTarget) { - // set aMergePolygon to the new polygon - aMergePolygon = rCandidate.getB2DPolygon(a); + pLineTarget->append(aLineTarget); } - } - // append the last used merge polygon - if(aMergePolygon.count()) - { - aRetval.append(aMergePolygon); - } - - // test if last and first need to be appended, too - if(aRetval.count() > 1) - { - B2DPolygon aFirst = aRetval.getB2DPolygon(0L); - B2DPolygon aLast = aRetval.getB2DPolygon(aRetval.count() - 1L); - - if(aFirst.getB2DPoint(0L) == aLast.getB2DPoint(aLast.count() - 1L)) + if(pGapTarget) { - // copy remaining points to aLast - for(sal_uInt32 a(1L); a < aFirst.count(); a++) - { - aLast.append(aFirst.getB2DPoint(a)); - } - - // create new retval - B2DPolyPolygon aNewRetval; - - // copy the unchanged part polygons - for(sal_uInt32 b(1L); b < aRetval.count() - 1L; b++) - { - aNewRetval.append(aRetval.getB2DPolygon(b)); - } - - // append new part polygon - aNewRetval.append(aLast); - - // use as return value - aRetval = aNewRetval; + pGapTarget->append(aGapTarget); } } } - - return aRetval; } bool isInEpsilonRange(const B2DPolyPolygon& rCandidate, const B2DPoint& rTestPosition, double fDistance) @@ -484,6 +452,54 @@ namespace basegfx } } + B2DPolyPolygon growInNormalDirection(const B2DPolyPolygon& rCandidate, double fValue) + { + if(0.0 != fValue) + { + B2DPolyPolygon aRetval; + + for(sal_uInt32 a(0L); a < rCandidate.count(); a++) + { + aRetval.append(growInNormalDirection(rCandidate.getB2DPolygon(a), fValue)); + } + + return aRetval; + } + else + { + return rCandidate; + } + } + + void correctGrowShrinkPolygonPair(B2DPolyPolygon& /*rOriginal*/, B2DPolyPolygon& /*rGrown*/) + { + } + + B2DPolyPolygon reSegmentPolyPolygon(const B2DPolyPolygon& rCandidate, sal_uInt32 nSegments) + { + B2DPolyPolygon aRetval; + + for(sal_uInt32 a(0L); a < rCandidate.count(); a++) + { + aRetval.append(reSegmentPolygon(rCandidate.getB2DPolygon(a), nSegments)); + } + + return aRetval; + } + + B2DPolyPolygon interpolate(const B2DPolyPolygon& rOld1, const B2DPolyPolygon& rOld2, double t) + { + OSL_ENSURE(rOld1.count() == rOld2.count(), "B2DPolyPolygon interpolate: Different geometry (!)"); + B2DPolyPolygon aRetval; + + for(sal_uInt32 a(0L); a < rOld1.count(); a++) + { + aRetval.append(interpolate(rOld1.getB2DPolygon(a), rOld2.getB2DPolygon(a), t)); + } + + return aRetval; + } + bool isRectangle( const B2DPolyPolygon& rPoly ) { // exclude some cheap cases first @@ -513,6 +529,18 @@ namespace basegfx } } + B2DPolyPolygon reSegmentPolyPolygonEdges(const B2DPolyPolygon& rCandidate, sal_uInt32 nSubEdges, bool bHandleCurvedEdges, bool bHandleStraightEdges) + { + B2DPolyPolygon aRetval; + + for(sal_uInt32 a(0L); a < rCandidate.count(); a++) + { + aRetval.append(reSegmentPolygonEdges(rCandidate.getB2DPolygon(a), nSubEdges, bHandleCurvedEdges, bHandleStraightEdges)); + } + + return aRetval; + } + ////////////////////////////////////////////////////////////////////// // comparators with tolerance for 2D PolyPolygons |