diff options
Diffstat (limited to 'basegfx')
-rw-r--r-- | basegfx/source/polygon/b2dpolygontools.cxx | 15 | ||||
-rw-r--r-- | basegfx/source/polygon/b2dpolypolygoncutter.cxx | 36 |
2 files changed, 44 insertions, 7 deletions
diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx index c194a38dc9d2..1cb61585e2b4 100644 --- a/basegfx/source/polygon/b2dpolygontools.cxx +++ b/basegfx/source/polygon/b2dpolygontools.cxx @@ -331,15 +331,15 @@ namespace basegfx::utils const B2DPoint aPreviousPoint(aCurrentPoint); aCurrentPoint = aCandidate.getB2DPoint(a); - // cross-over in Y? - const bool bCompYA(fTools::more(aPreviousPoint.getY(), rPoint.getY())); - const bool bCompYB(fTools::more(aCurrentPoint.getY(), rPoint.getY())); + // cross-over in Y? tdf#130150 use full precision, no need for epsilon + const bool bCompYA(aPreviousPoint.getY() > rPoint.getY()); + const bool bCompYB(aCurrentPoint.getY() > rPoint.getY()); if(bCompYA != bCompYB) { - // cross-over in X? - const bool bCompXA(fTools::more(aPreviousPoint.getX(), rPoint.getX())); - const bool bCompXB(fTools::more(aCurrentPoint.getX(), rPoint.getX())); + // cross-over in X? tdf#130150 use full precision, no need for epsilon + const bool bCompXA(aPreviousPoint.getX() > rPoint.getX()); + const bool bCompXB(aCurrentPoint.getX() > rPoint.getX()); if(bCompXA == bCompXB) { @@ -355,7 +355,8 @@ namespace basegfx::utils (aPreviousPoint.getX() - aCurrentPoint.getX()) / (aPreviousPoint.getY() - aCurrentPoint.getY())); - if(fTools::more(fCompare, rPoint.getX())) + // tdf#130150 use full precision, no need for epsilon + if(fCompare > rPoint.getX()) { bRetval = !bRetval; } diff --git a/basegfx/source/polygon/b2dpolypolygoncutter.cxx b/basegfx/source/polygon/b2dpolypolygoncutter.cxx index ad185f47f336..6263c78a1ef5 100644 --- a/basegfx/source/polygon/b2dpolypolygoncutter.cxx +++ b/basegfx/source/polygon/b2dpolypolygoncutter.cxx @@ -984,6 +984,42 @@ namespace basegfx::utils } else { + // tdf#130150 shortcut & precision: If both are simple ranges, + // solve based on ranges + if(basegfx::utils::isRectangle(rCandidateA) && basegfx::utils::isRectangle(rCandidateB)) + { + // *if* both are ranges, AND always can be solved + const basegfx::B2DRange aRangeA(rCandidateA.getB2DRange()); + const basegfx::B2DRange aRangeB(rCandidateB.getB2DRange()); + + if(aRangeA.isInside(aRangeB)) + { + // 2nd completely inside 1st -> 2nd is result of AND + return rCandidateB; + } + + if(aRangeB.isInside(aRangeA)) + { + // 2nd completely inside 1st -> 2nd is result of AND + return rCandidateA; + } + + // solve by intersection + basegfx::B2DRange aIntersect(aRangeA); + aIntersect.intersect(aRangeB); + + if(aIntersect.isEmpty()) + { + // no overlap -> empty polygon as result of AND + return B2DPolyPolygon(); + } + + // create polygon result + return B2DPolyPolygon( + basegfx::utils::createPolygonFromRect( + aIntersect)); + } + // concatenate polygons, solve crossovers and throw away all sub-polygons // with a depth of < 1. This means to keep all polygons where at least two // polygons do overlap. |