summaryrefslogtreecommitdiffstats
path: root/basegfx/source/polygon/b2dpolygonclipper.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'basegfx/source/polygon/b2dpolygonclipper.cxx')
-rw-r--r--basegfx/source/polygon/b2dpolygonclipper.cxx31
1 files changed, 19 insertions, 12 deletions
diff --git a/basegfx/source/polygon/b2dpolygonclipper.cxx b/basegfx/source/polygon/b2dpolygonclipper.cxx
index 246d5a10ab84..e2f1f060381e 100644
--- a/basegfx/source/polygon/b2dpolygonclipper.cxx
+++ b/basegfx/source/polygon/b2dpolygonclipper.cxx
@@ -25,6 +25,7 @@
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <basegfx/curve/b2dcubicbezier.hxx>
#include <basegfx/utils/rectcliptools.hxx>
+#include <sal/log.hxx>
namespace basegfx::utils
{
@@ -161,12 +162,11 @@ namespace basegfx::utils
B2DPolyPolygon clipPolyPolygonOnParallelAxis(const B2DPolyPolygon& rCandidate, bool bParallelToXAxis, bool bAboveAxis, double fValueOnOtherAxis, bool bStroke)
{
- const sal_uInt32 nPolygonCount(rCandidate.count());
B2DPolyPolygon aRetval;
- for(sal_uInt32 a(0); a < nPolygonCount; a++)
+ for(const auto& rB2DPolygon : rCandidate )
{
- const B2DPolyPolygon aClippedPolyPolygon(clipPolygonOnParallelAxis(rCandidate.getB2DPolygon(a), bParallelToXAxis, bAboveAxis, fValueOnOtherAxis, bStroke));
+ const B2DPolyPolygon aClippedPolyPolygon(clipPolygonOnParallelAxis(rB2DPolygon, bParallelToXAxis, bAboveAxis, fValueOnOtherAxis, bStroke));
if(aClippedPolyPolygon.count())
{
@@ -283,10 +283,9 @@ namespace basegfx::utils
B2DPolyPolygon clipPolyPolygonOnRange(const B2DPolyPolygon& rCandidate, const B2DRange& rRange, bool bInside, bool bStroke)
{
- const sal_uInt32 nPolygonCount(rCandidate.count());
B2DPolyPolygon aRetval;
- if(!nPolygonCount)
+ if(!rCandidate.count())
{
// source is empty
return aRetval;
@@ -308,9 +307,9 @@ namespace basegfx::utils
if(bInside)
{
- for(sal_uInt32 a(0); a < nPolygonCount; a++)
+ for( const auto& rClippedPoly : rCandidate)
{
- const B2DPolyPolygon aClippedPolyPolygon(clipPolygonOnRange(rCandidate.getB2DPolygon(a), rRange, bInside, bStroke));
+ const B2DPolyPolygon aClippedPolyPolygon(clipPolygonOnRange(rClippedPoly , rRange, bInside, bStroke));
if(aClippedPolyPolygon.count())
{
@@ -330,7 +329,8 @@ namespace basegfx::utils
return aRetval;
}
- B2DPolyPolygon clipPolyPolygonOnPolyPolygon(const B2DPolyPolygon& rCandidate, const B2DPolyPolygon& rClip, bool bInside, bool bStroke)
+ B2DPolyPolygon clipPolyPolygonOnPolyPolygon(const B2DPolyPolygon& rCandidate, const B2DPolyPolygon& rClip,
+ bool bInside, bool bStroke, size_t* pPointLimit)
{
B2DPolyPolygon aRetval;
@@ -343,10 +343,10 @@ namespace basegfx::utils
// line clipping, create line snippets by first adding all cut points and
// then marching along the edges and detecting if they are inside or outside
// the clip polygon
- for(sal_uInt32 a(0); a < rCandidate.count(); a++)
+ for(const auto& rPolygon : rCandidate)
{
// add cuts with clip to polygon, including bezier segments
- const B2DPolygon aCandidate(addPointsAtCuts(rCandidate.getB2DPolygon(a), rClip));
+ const B2DPolygon aCandidate(addPointsAtCuts(rPolygon, rClip));
const sal_uInt32 nPointCount(aCandidate.count());
const sal_uInt32 nEdgeCount(aCandidate.isClosed() ? nPointCount : nPointCount - 1);
B2DCubicBezier aEdge;
@@ -471,7 +471,14 @@ namespace basegfx::utils
// prepare 2nd source polygon in same way
- B2DPolyPolygon aMergePolyPolygonB = solveCrossovers(rCandidate);
+ B2DPolyPolygon aMergePolyPolygonB = solveCrossovers(rCandidate, pPointLimit);
+
+ if (pPointLimit && !*pPointLimit)
+ {
+ SAL_WARN("basegfx", "clipPolyPolygonOnPolyPolygon hit point limit");
+ return aRetval;
+ }
+
aMergePolyPolygonB = stripNeutralPolygons(aMergePolyPolygonB);
aMergePolyPolygonB = correctOrientations(aMergePolyPolygonB);
@@ -480,7 +487,7 @@ namespace basegfx::utils
// be solved again, they were solved in the preparation.
aRetval.append(aMergePolyPolygonA);
aRetval.append(aMergePolyPolygonB);
- aRetval = solveCrossovers(aRetval);
+ aRetval = solveCrossovers(aRetval, pPointLimit);
// now remove neutral polygons (closed, but no area). In a last
// step throw away all polygons which have a depth of less than 1