diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2008-04-24 14:06:29 +0000 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2008-04-24 14:06:29 +0000 |
commit | 0505d4fb6c781b98117f01cc9ac8bf505e390484 (patch) | |
tree | 6ccfcbc21058574710edcbc9fba79e90bb7c47c9 /basegfx/source/polygon/b2dpolygontools.cxx | |
parent | 04bca394babfaa3ddc5411d7812611d394c1b9b3 (diff) |
INTEGRATION: CWS aw055 (1.26.26); FILE MERGED
2008/02/29 04:32:01 aw 1.26.26.1: removed op equal at polygons, added to tooling. Done for 2D and 3D
Diffstat (limited to 'basegfx/source/polygon/b2dpolygontools.cxx')
-rw-r--r-- | basegfx/source/polygon/b2dpolygontools.cxx | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx index 13cda99eacb9..ea19a5abe44c 100644 --- a/basegfx/source/polygon/b2dpolygontools.cxx +++ b/basegfx/source/polygon/b2dpolygontools.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: b2dpolygontools.cxx,v $ - * $Revision: 1.27 $ + * $Revision: 1.28 $ * * This file is part of OpenOffice.org. * @@ -2745,6 +2745,57 @@ namespace basegfx return rCandidate; } + ////////////////////////////////////////////////////////////////////// + // comparators with tolerance for 2D Polygons + + bool equal(const B2DPolygon& rCandidateA, const B2DPolygon& rCandidateB, const double& rfSmallValue) + { + const sal_uInt32 nPointCount(rCandidateA.count()); + + if(nPointCount != rCandidateB.count()) + return false; + + const bool bClosed(rCandidateA.isClosed()); + + if(bClosed != rCandidateB.isClosed()) + return false; + + const bool bAreControlPointsUsed(rCandidateA.areControlPointsUsed()); + + if(bAreControlPointsUsed != rCandidateB.areControlPointsUsed()) + return false; + + for(sal_uInt32 a(0); a < nPointCount; a++) + { + const B2DPoint aPoint(rCandidateA.getB2DPoint(a)); + + if(!aPoint.equal(rCandidateB.getB2DPoint(a), rfSmallValue)) + return false; + + if(bAreControlPointsUsed) + { + const basegfx::B2DPoint aPrev(rCandidateA.getPrevControlPoint(a)); + + if(!aPrev.equal(rCandidateB.getPrevControlPoint(a), rfSmallValue)) + return false; + + const basegfx::B2DPoint aNext(rCandidateA.getNextControlPoint(a)); + + if(!aNext.equal(rCandidateB.getNextControlPoint(a), rfSmallValue)) + return false; + } + } + + return true; + } + + bool equal(const B2DPolygon& rCandidateA, const B2DPolygon& rCandidateB) + { + const double fSmallValue(fTools::getSmallValue()); + + return equal(rCandidateA, rCandidateB, fSmallValue); + } + } // end of namespace tools } // end of namespace basegfx |