summaryrefslogtreecommitdiff
path: root/basegfx/source/polygon/b2dpolypolygontools.cxx
diff options
context:
space:
mode:
authorArmin Weiss <aw@openoffice.org>2003-11-28 10:18:16 +0000
committerArmin Weiss <aw@openoffice.org>2003-11-28 10:18:16 +0000
commitd539c95155ccc7030411f7494704894a3ac610a8 (patch)
treedc3dbd283a5f501f6e48dd585d80bb158db920e3 /basegfx/source/polygon/b2dpolypolygontools.cxx
parentce0ce72d1fd37f7b8e7cb4ebc372d8cd6b4ab9c0 (diff)
Removed in-between namespaces (curve, matrix, numeric, point, polygon, range, tuple, vector). Names were too common and e.g. vector leaded to problems with some defines. This is now avoided. Also some bug fixes, addition of 3d polygon tooling etc.
Diffstat (limited to 'basegfx/source/polygon/b2dpolypolygontools.cxx')
-rw-r--r--basegfx/source/polygon/b2dpolypolygontools.cxx221
1 files changed, 116 insertions, 105 deletions
diff --git a/basegfx/source/polygon/b2dpolypolygontools.cxx b/basegfx/source/polygon/b2dpolypolygontools.cxx
index 3ddb6f11a0a3..60f61b347135 100644
--- a/basegfx/source/polygon/b2dpolypolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolypolygontools.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dpolypolygontools.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: aw $ $Date: 2003-11-26 14:40:12 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -87,153 +87,164 @@
namespace basegfx
{
- namespace polygon
+ namespace tools
{
- namespace tools
+ // B2DPolyPolygon tools
+
+ void correctOrientations(::basegfx::B2DPolyPolygon& rCandidate)
{
- // B2DPolyPolygon tools
+ const sal_uInt32 nPolygonCount(rCandidate.count());
+ sal_uInt32 nIndexOfOutmostPolygon(0L);
+ sal_Bool bIndexOfOutmostPolygonSet(sal_False);
- void correctOrientations(::basegfx::polygon::B2DPolyPolygon& rCandidate)
+ for(sal_uInt32 a(0L); a < nPolygonCount; a++)
{
- const sal_uInt32 nPolygonCount(rCandidate.count());
- sal_uInt32 nIndexOfOutmostPolygon(0L);
- sal_Bool bIndexOfOutmostPolygonSet(sal_False);
+ ::basegfx::B2DPolygon aCandidate = rCandidate.getB2DPolygon(a);
- for(sal_uInt32 a(0L); a < nPolygonCount; a++)
+ if(aCandidate.count() > 2L)
{
- ::basegfx::polygon::B2DPolygon aCandidate = rCandidate.getB2DPolygon(a);
-
- if(aCandidate.count() > 2L)
+ ::basegfx::B2DVectorOrientation aOrientation =
+ ::basegfx::tools::getOrientation(aCandidate);
+ sal_Bool bDoFlip(::basegfx::ORIENTATION_POSITIVE != aOrientation);
+
+ // init values for depth and compare point for
+ // inside test. Since the ordering makes only sense when assuming
+ // that there are no intersections, the inside test is done with
+ // any point of the candidate, so teke the first one.
+ sal_uInt32 nDepth(0L);
+ const ::basegfx::B2DPoint aTestPoint(aCandidate.getB2DPoint(0L));
+
+ // loop over other polygons and calculate depth
+ for(sal_uInt32 b(0L); b < nPolygonCount; b++)
{
- ::basegfx::vector::B2DVectorOrientation aOrientation =
- ::basegfx::polygon::tools::getOrientation(aCandidate);
- sal_Bool bDoFlip(::basegfx::vector::ORIENTATION_POSITIVE != aOrientation);
-
- // init values for depth and compare point for
- // inside test. Since the ordering makes only sense when assuming
- // that there are no intersections, the inside test is done with
- // any point of the candidate, so teke the first one.
- sal_uInt32 nDepth(0L);
- const ::basegfx::point::B2DPoint aTestPoint(aCandidate.getB2DPoint(0L));
-
- // loop over other polygons and calculate depth
- for(sal_uInt32 b(0L); b < nPolygonCount; b++)
+ if(b != a)
{
- if(b != a)
- {
- ::basegfx::polygon::B2DPolygon aComparePolygon = rCandidate.getB2DPolygon(b);
+ ::basegfx::B2DPolygon aComparePolygon = rCandidate.getB2DPolygon(b);
- if(::basegfx::polygon::tools::isInside(aComparePolygon, aTestPoint))
- {
- nDepth++;
- }
+ if(::basegfx::tools::isInside(aComparePolygon, aTestPoint))
+ {
+ nDepth++;
}
}
+ }
- // if nDepth is odd it is a hole
- sal_Bool bIsHole(1L == (nDepth & 0x00000001));
+ // if nDepth is odd it is a hole
+ sal_Bool bIsHole(1L == (nDepth & 0x00000001));
- // does polygon need to be flipped?
- if((bDoFlip && !bIsHole) || (!bDoFlip && bIsHole))
- {
- aCandidate.flip();
-
- // write back changed polygon
- rCandidate.setB2DPolygon(a, aCandidate);
- }
+ // does polygon need to be flipped?
+ if((bDoFlip && !bIsHole) || (!bDoFlip && bIsHole))
+ {
+ aCandidate.flip();
- // remember the index if it's the outmost polygon
- if(!bIndexOfOutmostPolygonSet && 0L == nDepth)
- {
- bIndexOfOutmostPolygonSet = sal_True;
- nIndexOfOutmostPolygon = a;
- }
+ // write back changed polygon
+ rCandidate.setB2DPolygon(a, aCandidate);
}
- }
- // if the outmost polygon is not the first, move it in front
- if(bIndexOfOutmostPolygonSet && nIndexOfOutmostPolygon > 0L)
- {
- ::basegfx::polygon::B2DPolygon aOutmostPolygon = rCandidate.getB2DPolygon(nIndexOfOutmostPolygon);
- rCandidate.remove(nIndexOfOutmostPolygon);
- rCandidate.insert(0L, aOutmostPolygon);
+ // remember the index if it's the outmost polygon
+ if(!bIndexOfOutmostPolygonSet && 0L == nDepth)
+ {
+ bIndexOfOutmostPolygonSet = sal_True;
+ nIndexOfOutmostPolygon = a;
+ }
}
}
- void removeIntersections(::basegfx::polygon::B2DPolyPolygon& rCandidate,
- sal_Bool bForceOrientation, sal_Bool bInvertRemove)
+ // if the outmost polygon is not the first, move it in front
+ if(bIndexOfOutmostPolygonSet && nIndexOfOutmostPolygon > 0L)
{
- ::basegfx::polygon::B2DPolyPolygonCutter aCutter;
-
- aCutter.addPolyPolygon(rCandidate, bForceOrientation);
- aCutter.removeSelfIntersections();
- aCutter.removeDoubleIntersections();
- aCutter.removeIncludedPolygons(!bInvertRemove);
- rCandidate.clear();
- aCutter.getPolyPolygon(rCandidate);
+ ::basegfx::B2DPolygon aOutmostPolygon = rCandidate.getB2DPolygon(nIndexOfOutmostPolygon);
+ rCandidate.remove(nIndexOfOutmostPolygon);
+ rCandidate.insert(0L, aOutmostPolygon);
}
+ }
+
+ void removeIntersections(::basegfx::B2DPolyPolygon& rCandidate,
+ sal_Bool bForceOrientation, sal_Bool bInvertRemove)
+ {
+ ::basegfx::B2DPolyPolygonCutter aCutter;
+
+ aCutter.addPolyPolygon(rCandidate, bForceOrientation);
+ aCutter.removeSelfIntersections();
+ aCutter.removeDoubleIntersections();
+ aCutter.removeIncludedPolygons(!bInvertRemove);
+ rCandidate.clear();
+ aCutter.getPolyPolygon(rCandidate);
+ }
- ::basegfx::polygon::B2DPolyPolygon adaptiveSubdivideByDistance(const ::basegfx::polygon::B2DPolyPolygon& rCandidate, double fDistanceBound)
+ ::basegfx::B2DPolyPolygon adaptiveSubdivideByDistance(const ::basegfx::B2DPolyPolygon& rCandidate, double fDistanceBound)
+ {
+ ::basegfx::B2DPolyPolygon aRetval(rCandidate);
+
+ if(aRetval.areControlPointsUsed())
{
- ::basegfx::polygon::B2DPolyPolygon aRetval(rCandidate);
+ const sal_uInt32 nPolygonCount(aRetval.count());
- if(aRetval.areControlPointsUsed())
+ for(sal_uInt32 a(0L); aRetval.areControlPointsUsed() && a < nPolygonCount; a++)
{
- const sal_uInt32 nPolygonCount(aRetval.count());
+ ::basegfx::B2DPolygon aCandidate = aRetval.getB2DPolygon(a);
- for(sal_uInt32 a(0L); aRetval.areControlPointsUsed() && a < nPolygonCount; a++)
+ if(aCandidate.areControlPointsUsed())
{
- ::basegfx::polygon::B2DPolygon aCandidate = aRetval.getB2DPolygon(a);
-
- if(aCandidate.areControlPointsUsed())
- {
- aCandidate = ::basegfx::polygon::tools::adaptiveSubdivideByDistance(aCandidate, fDistanceBound);
- aRetval.setB2DPolygon(a, aCandidate);
- }
+ aCandidate = ::basegfx::tools::adaptiveSubdivideByDistance(aCandidate, fDistanceBound);
+ aRetval.setB2DPolygon(a, aCandidate);
}
}
-
- return aRetval;
}
- ::basegfx::polygon::B2DPolyPolygon adaptiveSubdivideByAngle(const ::basegfx::polygon::B2DPolyPolygon& rCandidate, double fAngleBound)
+ return aRetval;
+ }
+
+ ::basegfx::B2DPolyPolygon adaptiveSubdivideByAngle(const ::basegfx::B2DPolyPolygon& rCandidate, double fAngleBound)
+ {
+ ::basegfx::B2DPolyPolygon aRetval(rCandidate);
+
+ if(aRetval.areControlPointsUsed())
{
- ::basegfx::polygon::B2DPolyPolygon aRetval(rCandidate);
+ const sal_uInt32 nPolygonCount(aRetval.count());
- if(aRetval.areControlPointsUsed())
+ for(sal_uInt32 a(0L); aRetval.areControlPointsUsed() && a < nPolygonCount; a++)
{
- const sal_uInt32 nPolygonCount(aRetval.count());
+ ::basegfx::B2DPolygon aCandidate = aRetval.getB2DPolygon(a);
- for(sal_uInt32 a(0L); aRetval.areControlPointsUsed() && a < nPolygonCount; a++)
+ if(aCandidate.areControlPointsUsed())
{
- ::basegfx::polygon::B2DPolygon aCandidate = aRetval.getB2DPolygon(a);
-
- if(aCandidate.areControlPointsUsed())
- {
- aCandidate = ::basegfx::polygon::tools::adaptiveSubdivideByAngle(aCandidate, fAngleBound);
- aRetval.setB2DPolygon(a, aCandidate);
- }
+ aCandidate = ::basegfx::tools::adaptiveSubdivideByAngle(aCandidate, fAngleBound);
+ aRetval.setB2DPolygon(a, aCandidate);
}
}
-
- return aRetval;
}
- ::basegfx::range::B2DRange getRange(const ::basegfx::polygon::B2DPolyPolygon& rCandidate)
+ return aRetval;
+ }
+
+ ::basegfx::B2DRange getRange(const ::basegfx::B2DPolyPolygon& rCandidate)
+ {
+ ::basegfx::B2DRange aRetval;
+ const sal_uInt32 nPolygonCount(rCandidate.count());
+
+ for(sal_uInt32 a(0L); a < nPolygonCount; a++)
{
- ::basegfx::range::B2DRange aRetval;
- const sal_uInt32 nPolygonCount(rCandidate.count());
+ ::basegfx::B2DPolygon aCandidate = rCandidate.getB2DPolygon(a);
+ aRetval.expand(::basegfx::tools::getRange(aCandidate));
+ }
- for(sal_uInt32 a(0L); a < nPolygonCount; a++)
- {
- ::basegfx::polygon::B2DPolygon aCandidate = rCandidate.getB2DPolygon(a);
- aRetval.expand(::basegfx::polygon::tools::getRange(aCandidate));
- }
+ return aRetval;
+ }
+
+ ::basegfx::B2DPolyPolygon applyLineDashing(const ::basegfx::B2DPolyPolygon& rCandidate, const ::std::vector<double>& raDashDotArray, double fFullDashDotLen)
+ {
+ ::basegfx::B2DPolyPolygon aRetval;
+ const sal_uInt32 nPolygonCount(rCandidate.count());
- return aRetval;
+ for(sal_uInt32 a(0L); a < nPolygonCount; a++)
+ {
+ ::basegfx::B2DPolygon aCandidate = rCandidate.getB2DPolygon(a);
+ aRetval.append(applyLineDashing(aCandidate, raDashDotArray, fFullDashDotLen));
}
- } // end of namespace tools
- } // end of namespace polygon
+
+ return aRetval;
+ }
+ } // end of namespace tools
} // end of namespace basegfx
//////////////////////////////////////////////////////////////////////////////