diff options
author | Kurt Zenker <kz@openoffice.org> | 2004-06-10 10:35:45 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2004-06-10 10:35:45 +0000 |
commit | 09da9cb02736389ca4d71af32c3c2b87d8335e5d (patch) | |
tree | fe5d72ea86a4875f5ac15631787792dfd205fc9b /tools/source | |
parent | 07c32744c26384305bf30ff086bf03e75aeb1df6 (diff) |
INTEGRATION: CWS aw011 (1.6.16); FILE MERGED
2004/05/28 18:49:34 thb 1.6.16.1: #i24832# Added implementation for build-in clipper, should neither gpc nor libart be available. Subject to detailed performance analysis, this might also become the default clipper in the future
Diffstat (limited to 'tools/source')
-rw-r--r-- | tools/source/generic/poly2.cxx | 92 |
1 files changed, 90 insertions, 2 deletions
diff --git a/tools/source/generic/poly2.cxx b/tools/source/generic/poly2.cxx index afd50345dd70..e8e8a15112d2 100644 --- a/tools/source/generic/poly2.cxx +++ b/tools/source/generic/poly2.cxx @@ -2,9 +2,9 @@ * * $RCSfile: poly2.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: hr $ $Date: 2004-05-10 14:40:36 $ + * last change: $Author: kz $ $Date: 2004-06-10 11:35:45 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -108,6 +108,10 @@ extern "C" #include <basegfx/polygon/b2dpolygon.hxx> #endif +#ifndef _BGFX_POLYGON_B2DPOLYPOLYGONTOOLS_HXX +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#endif + // --------------- // - PolyPolygon - // --------------- @@ -785,6 +789,90 @@ void PolyPolygon::ImplDoOperation( const PolyPolygon& rPolyPoly, PolyPolygon& rR void PolyPolygon::ImplDoOperation( const PolyPolygon& rPolyPoly, PolyPolygon& rResult, ULONG nOperation ) const { + // Convert to B2DPolyPolygon, temporarily. It might be + // advantageous in the future, to have a PolyPolygon adaptor that + // just simulates a B2DPolyPolygon here... + ::basegfx::B2DPolyPolygon aMergePolyPolygonA( getB2DPolyPolygon() ); + ::basegfx::B2DPolyPolygon aMergePolyPolygonB( rPolyPoly.getB2DPolyPolygon() ); + + // normalize the two polypolygons before. Force properly oriented + // polygons. + if( aMergePolyPolygonA.areControlPointsUsed() ) + aMergePolyPolygonA = ::basegfx::tools::adaptiveSubdivideByAngle(aMergePolyPolygonA); + ::basegfx::tools::correctOrientations( aMergePolyPolygonA ); + + if( aMergePolyPolygonB.areControlPointsUsed() ) + aMergePolyPolygonB = ::basegfx::tools::adaptiveSubdivideByAngle(aMergePolyPolygonB); + ::basegfx::tools::correctOrientations( aMergePolyPolygonB ); + + switch( nOperation ) + { + // All code extracted from svx/source/svdraw/svedtv2.cxx + // ----------------------------------------------------- + + case GPC_UNION: + { + // simple merge all contained parts (OR) + aMergePolyPolygonA.append(aMergePolyPolygonB); + ::basegfx::tools::removeIntersections(aMergePolyPolygonA, sal_False); + break; + } + + case GPC_DIFF: + { + // take selected poly 2..n (is in Polygon B), merge them, flipdirections + // and merge with poly 1 + ::basegfx::tools::removeIntersections(aMergePolyPolygonA, sal_False); + ::basegfx::tools::removeIntersections(aMergePolyPolygonB, sal_False); + aMergePolyPolygonB.flip(); + aMergePolyPolygonA.append(aMergePolyPolygonB); + ::basegfx::tools::removeIntersections(aMergePolyPolygonA, sal_False); + + // #72995# one more call to resolve self intersections which + // may have been built by substracting (see bug) + //aMergePolyPolygonA.Merge(FALSE); + ::basegfx::tools::removeIntersections(aMergePolyPolygonA, sal_False); + break; + } + + case GPC_XOR: + { + // compute XOR between poly A and B. As basegfx clipper + // has no direct support for this, we first compute the + // intersection and the union of the two polygons, and + // then subtract the intersection from the union + ::basegfx::tools::removeIntersections(aMergePolyPolygonA, sal_False); + ::basegfx::tools::removeIntersections(aMergePolyPolygonB, sal_False); + ::basegfx::B2DPolyPolygon aAintersectsB( aMergePolyPolygonA ); + + // A /\ B + aAintersectsB.append(aMergePolyPolygonB); + ::basegfx::tools::removeIntersections(aAintersectsB, sal_False, sal_True); + + // A + B + aMergePolyPolygonA.append(aMergePolyPolygonB); + ::basegfx::tools::removeIntersections(aMergePolyPolygonA, sal_False); + + // (A+B) \ (A/\B) + aAintersectsB.flip(); + aMergePolyPolygonA.append(aAintersectsB); + ::basegfx::tools::removeIntersections(aMergePolyPolygonA, sal_False); + break; + } + + default: + case GPC_INT: + { + // cut poly 1 against polys 2..n (AND) + ::basegfx::tools::removeIntersections(aMergePolyPolygonA, sal_False); + ::basegfx::tools::removeIntersections(aMergePolyPolygonB, sal_False); + aMergePolyPolygonA.append(aMergePolyPolygonB); + ::basegfx::tools::removeIntersections(aMergePolyPolygonA, sal_False, sal_True); + break; + } + } + + rResult = PolyPolygon( aMergePolyPolygonA ); } #endif // HAVE_LIBART_H |