summaryrefslogtreecommitdiff
path: root/basegfx/inc/basegfx
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@Sun.COM>2009-12-08 19:04:39 +0100
committerArmin Le Grand <Armin.Le.Grand@Sun.COM>2009-12-08 19:04:39 +0100
commit3e659f82dedbb5ddeb2814ce5267445234f7e7fd (patch)
treebf4d7807ade3fcf54f0795f7116167607ace8310 /basegfx/inc/basegfx
parentb31166829b6c56b963e6ca58cd1af8c746e8ab6a (diff)
aw079: #i107360# numerical precision
Diffstat (limited to 'basegfx/inc/basegfx')
-rw-r--r--basegfx/inc/basegfx/numeric/ftools.hxx2
-rw-r--r--basegfx/inc/basegfx/polygon/b2dpolygoncutandtouch.hxx8
-rw-r--r--basegfx/inc/basegfx/polygon/b2dtrapezoid.hxx94
-rw-r--r--basegfx/inc/basegfx/tuple/b2dtuple.hxx10
-rw-r--r--basegfx/inc/basegfx/tuple/b2i64tuple.hxx2
-rw-r--r--basegfx/inc/basegfx/tuple/b2ituple.hxx2
-rw-r--r--basegfx/inc/basegfx/tuple/b3dtuple.hxx10
-rw-r--r--basegfx/inc/basegfx/tuple/b3i64tuple.hxx2
-rw-r--r--basegfx/inc/basegfx/tuple/b3ituple.hxx2
9 files changed, 119 insertions, 13 deletions
diff --git a/basegfx/inc/basegfx/numeric/ftools.hxx b/basegfx/inc/basegfx/numeric/ftools.hxx
index 5003ede0c4cf..e20464d92816 100644
--- a/basegfx/inc/basegfx/numeric/ftools.hxx
+++ b/basegfx/inc/basegfx/numeric/ftools.hxx
@@ -178,7 +178,7 @@ namespace basegfx
static bool equal(const double& rfValA, const double& rfValB, const double& rfSmallValue)
{
- return (fabs(rfValA) - fabs(rfValB) <= rfSmallValue);
+ return (fabs(rfValA - rfValB) <= rfSmallValue);
}
static bool less(const double& rfValA, const double& rfValB)
diff --git a/basegfx/inc/basegfx/polygon/b2dpolygoncutandtouch.hxx b/basegfx/inc/basegfx/polygon/b2dpolygoncutandtouch.hxx
index aa4682a665cd..12adcb7cc551 100644
--- a/basegfx/inc/basegfx/polygon/b2dpolygoncutandtouch.hxx
+++ b/basegfx/inc/basegfx/polygon/b2dpolygoncutandtouch.hxx
@@ -68,6 +68,14 @@ namespace basegfx
B2DPolygon addPointsAtCuts(const B2DPolygon& rCandidate, const B2DPolyPolygon& rMask);
B2DPolyPolygon addPointsAtCuts(const B2DPolyPolygon& rCandidate, const B2DPolyPolygon& rMask);
+ // look for self-intersections in given polygon and add extra points there. Result will have no
+ // intersections on an edge
+ B2DPolygon addPointsAtCuts(const B2DPolygon& rCandidate);
+
+ // add points at all self-intersections of single polygons (depends on bSelfIntersections)
+ // and at polygon-polygon intersections
+ B2DPolyPolygon addPointsAtCuts(const B2DPolyPolygon& rCandidate, bool bSelfIntersections = true);
+
} // end of namespace tools
} // end of namespace basegfx
diff --git a/basegfx/inc/basegfx/polygon/b2dtrapezoid.hxx b/basegfx/inc/basegfx/polygon/b2dtrapezoid.hxx
new file mode 100644
index 000000000000..20bc1c79d390
--- /dev/null
+++ b/basegfx/inc/basegfx/polygon/b2dtrapezoid.hxx
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: b2dpolygontriangulator.hxx,v $
+ * $Revision: 1.5 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_POLYGON_B2DTRAPEZOID_HXX
+#define _BGFX_POLYGON_B2DTRAPEZOID_HXX
+
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dPolypolygon.hxx>
+#include <vector>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace basegfx
+{
+ // class to hold a single trapezoid
+ class B2DTrapezoid
+ {
+ private:
+ // geometry data
+ double mfTopXLeft;
+ double mfTopXRight;
+ double mfTopY;
+ double mfBottomXLeft;
+ double mfBottomXRight;
+ double mfBottomY;
+
+ public:
+ // constructor
+ B2DTrapezoid(
+ const double& rfTopXLeft,
+ const double& rfTopXRight,
+ const double& rfTopY,
+ const double& rfBottomXLeft,
+ const double& rfBottomXRight,
+ const double& rfBottomY);
+
+ // data read access
+ const double& getTopXLeft() const { return mfTopXLeft; }
+ const double& getTopXRight() const { return mfTopXRight; }
+ const double& getTopY() const { return mfTopY; }
+ const double& getBottomXLeft() const { return mfBottomXLeft; }
+ const double& getBottomXRight() const { return mfBottomXRight; }
+ const double& getBottomY() const { return mfBottomY; }
+
+ // convenience method to get content as Polygon
+ B2DPolygon getB2DPolygon() const;
+ };
+
+ typedef ::std::vector< B2DTrapezoid > B2DTrapezoidVector;
+
+} // end of namespace basegfx
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace basegfx
+{
+ namespace tools
+ {
+ // convert SourcePolyPolygon to trapezoids
+ B2DTrapezoidVector trapezoidSubdivide(const B2DPolyPolygon& rSourcePolyPolygon);
+
+ } // end of namespace tools
+} // end of namespace basegfx
+
+//////////////////////////////////////////////////////////////////////////////
+
+#endif /* _BGFX_POLYGON_B2DTRAPEZOID_HXX */
diff --git a/basegfx/inc/basegfx/tuple/b2dtuple.hxx b/basegfx/inc/basegfx/tuple/b2dtuple.hxx
index 7c4c1d585d2c..cb6adbda2d9e 100644
--- a/basegfx/inc/basegfx/tuple/b2dtuple.hxx
+++ b/basegfx/inc/basegfx/tuple/b2dtuple.hxx
@@ -158,15 +158,17 @@ namespace basegfx
bool equal(const B2DTuple& rTup) const
{
return (
- fTools::equal(mfX, rTup.mfX) &&
- fTools::equal(mfY, rTup.mfY));
+ this == &rTup ||
+ (fTools::equal(mfX, rTup.mfX) &&
+ fTools::equal(mfY, rTup.mfY)));
}
bool equal(const B2DTuple& rTup, const double& rfSmallValue) const
{
return (
- fTools::equal(mfX, rTup.mfX, rfSmallValue) &&
- fTools::equal(mfY, rTup.mfY, rfSmallValue));
+ this == &rTup ||
+ (fTools::equal(mfX, rTup.mfX, rfSmallValue) &&
+ fTools::equal(mfY, rTup.mfY, rfSmallValue)));
}
// operators
diff --git a/basegfx/inc/basegfx/tuple/b2i64tuple.hxx b/basegfx/inc/basegfx/tuple/b2i64tuple.hxx
index 627feb9f7875..b6fe0e886c10 100644
--- a/basegfx/inc/basegfx/tuple/b2i64tuple.hxx
+++ b/basegfx/inc/basegfx/tuple/b2i64tuple.hxx
@@ -185,7 +185,7 @@ namespace basegfx
bool operator==( const B2I64Tuple& rTup ) const
{
- return rTup.mnX == mnX && rTup.mnY == mnY;
+ return this == &rTup || (rTup.mnX == mnX && rTup.mnY == mnY);
}
bool operator!=( const B2I64Tuple& rTup ) const
diff --git a/basegfx/inc/basegfx/tuple/b2ituple.hxx b/basegfx/inc/basegfx/tuple/b2ituple.hxx
index bee473e88837..4b8b19ad767a 100644
--- a/basegfx/inc/basegfx/tuple/b2ituple.hxx
+++ b/basegfx/inc/basegfx/tuple/b2ituple.hxx
@@ -184,7 +184,7 @@ namespace basegfx
bool operator==( const B2ITuple& rTup ) const
{
- return rTup.mnX == mnX && rTup.mnY == mnY;
+ return this == &rTup || (rTup.mnX == mnX && rTup.mnY == mnY);
}
bool operator!=( const B2ITuple& rTup ) const
diff --git a/basegfx/inc/basegfx/tuple/b3dtuple.hxx b/basegfx/inc/basegfx/tuple/b3dtuple.hxx
index 04711aae017f..369693be3c3f 100644
--- a/basegfx/inc/basegfx/tuple/b3dtuple.hxx
+++ b/basegfx/inc/basegfx/tuple/b3dtuple.hxx
@@ -182,17 +182,19 @@ namespace basegfx
bool equal(const B3DTuple& rTup) const
{
return (
- ::basegfx::fTools::equal(mfX, rTup.mfX) &&
+ this == &rTup ||
+ (::basegfx::fTools::equal(mfX, rTup.mfX) &&
::basegfx::fTools::equal(mfY, rTup.mfY) &&
- ::basegfx::fTools::equal(mfZ, rTup.mfZ));
+ ::basegfx::fTools::equal(mfZ, rTup.mfZ)));
}
bool equal(const B3DTuple& rTup, const double& rfSmallValue) const
{
return (
- ::basegfx::fTools::equal(mfX, rTup.mfX, rfSmallValue) &&
+ this == &rTup ||
+ (::basegfx::fTools::equal(mfX, rTup.mfX, rfSmallValue) &&
::basegfx::fTools::equal(mfY, rTup.mfY, rfSmallValue) &&
- ::basegfx::fTools::equal(mfZ, rTup.mfZ, rfSmallValue));
+ ::basegfx::fTools::equal(mfZ, rTup.mfZ, rfSmallValue)));
}
// operators
diff --git a/basegfx/inc/basegfx/tuple/b3i64tuple.hxx b/basegfx/inc/basegfx/tuple/b3i64tuple.hxx
index 3791cbd63480..8f8001ba8d48 100644
--- a/basegfx/inc/basegfx/tuple/b3i64tuple.hxx
+++ b/basegfx/inc/basegfx/tuple/b3i64tuple.hxx
@@ -215,7 +215,7 @@ namespace basegfx
bool operator==( const B3I64Tuple& rTup ) const
{
- return rTup.mnX == mnX && rTup.mnY == mnY && rTup.mnZ == mnZ;
+ return this == &rTup || (rTup.mnX == mnX && rTup.mnY == mnY && rTup.mnZ == mnZ);
}
bool operator!=( const B3I64Tuple& rTup ) const
diff --git a/basegfx/inc/basegfx/tuple/b3ituple.hxx b/basegfx/inc/basegfx/tuple/b3ituple.hxx
index 33432122913b..33800766f78f 100644
--- a/basegfx/inc/basegfx/tuple/b3ituple.hxx
+++ b/basegfx/inc/basegfx/tuple/b3ituple.hxx
@@ -215,7 +215,7 @@ namespace basegfx
bool operator==( const B3ITuple& rTup ) const
{
- return rTup.mnX == mnX && rTup.mnY == mnY && rTup.mnZ == mnZ;
+ return this == &rTup || (rTup.mnX == mnX && rTup.mnY == mnY && rTup.mnZ == mnZ);
}
bool operator!=( const B3ITuple& rTup ) const