summaryrefslogtreecommitdiff
path: root/basegfx
diff options
context:
space:
mode:
Diffstat (limited to 'basegfx')
-rw-r--r--basegfx/source/polygon/b2dlinegeometry.cxx105
-rw-r--r--basegfx/source/polygon/b2dpolygoncutandtouch.cxx9
2 files changed, 75 insertions, 39 deletions
diff --git a/basegfx/source/polygon/b2dlinegeometry.cxx b/basegfx/source/polygon/b2dlinegeometry.cxx
index 0cda1036e13b..1a9264ab769e 100644
--- a/basegfx/source/polygon/b2dlinegeometry.cxx
+++ b/basegfx/source/polygon/b2dlinegeometry.cxx
@@ -352,13 +352,12 @@ namespace basegfx
// Unfortunately, while it would be geometrically correct to not add
// the in-between points EdgeEnd and EdgeStart, it leads to rounding
// errors when converting to integer polygon coordinates for painting
- const B2DVector aEdgeVector(rEdge.getEndPoint() - rEdge.getStartPoint());
-
if(rEdge.isBezier())
{
// prepare target and data common for upper and lower
B2DPolygon aBezierPolygon;
- const double fEdgeLength(aEdgeVector.getLength());
+ const B2DVector aPureEdgeVector(rEdge.getEndPoint() - rEdge.getStartPoint());
+ const double fEdgeLength(aPureEdgeVector.getLength());
const bool bIsEdgeLengthZero(fTools::equalZero(fEdgeLength));
const B2DVector aTangentA(rEdge.getTangent(0.0));
const B2DVector aTangentB(rEdge.getTangent(1.0));
@@ -441,7 +440,11 @@ namespace basegfx
}
else
{
- const B2DVector aPerpendEdgeVector(getNormalizedPerpendicular(aEdgeVector) * fHalfLineWidth);
+ // #i101491# emulate rEdge.getTangent call which applies a factor of 0.3 to the
+ // full-length edge vector to have numerically exactly the same results as in the
+ // createAreaGeometryForJoin implementation
+ const B2DVector aEdgeTangent((rEdge.getEndPoint() - rEdge.getStartPoint()) * 0.3);
+ const B2DVector aPerpendEdgeVector(getNormalizedPerpendicular(aEdgeTangent) * fHalfLineWidth);
B2DPolygon aEdgePolygon;
// create upper edge
@@ -495,45 +498,75 @@ namespace basegfx
}
}
- // create first polygon part for edge
- aEdgePolygon.append(aEndPoint);
- aEdgePolygon.append(rPoint);
- aEdgePolygon.append(aStartPoint);
-
- if(B2DLINEJOIN_MITER == eJoin)
+ switch(eJoin)
{
- // Look for the cut point between start point along rTangentPrev and
- // end point along rTangentEdge. -rTangentEdge should be used, but since
- // the cut value is used for interpolating along the first edge, the negation
- // is not needed since the same fCut will be found on the first edge.
- // If it exists, insert it to complete the mitered fill polygon.
- double fCutPos(0.0);
- tools::findCut(aStartPoint, rTangentPrev, aEndPoint, rTangentEdge, CUTFLAG_ALL, &fCutPos);
-
- if(0.0 != fCutPos)
+ case B2DLINEJOIN_MITER :
{
- const B2DPoint aCutPoint(interpolate(aStartPoint, aStartPoint + rTangentPrev, fCutPos));
- aEdgePolygon.append(aCutPoint);
- }
- }
- else if(B2DLINEJOIN_ROUND == eJoin)
- {
- // use tooling to add needed EllipseSegment
- double fAngleStart(atan2(rPerpendPrev.getY(), rPerpendPrev.getX()));
- double fAngleEnd(atan2(rPerpendEdge.getY(), rPerpendEdge.getX()));
+ aEdgePolygon.append(aEndPoint);
+ aEdgePolygon.append(rPoint);
+ aEdgePolygon.append(aStartPoint);
+
+ // Look for the cut point between start point along rTangentPrev and
+ // end point along rTangentEdge. -rTangentEdge should be used, but since
+ // the cut value is used for interpolating along the first edge, the negation
+ // is not needed since the same fCut will be found on the first edge.
+ // If it exists, insert it to complete the mitered fill polygon.
+ double fCutPos(0.0);
+ tools::findCut(aStartPoint, rTangentPrev, aEndPoint, rTangentEdge, CUTFLAG_ALL, &fCutPos);
+
+ if(0.0 != fCutPos)
+ {
+ const B2DPoint aCutPoint(interpolate(aStartPoint, aStartPoint + rTangentPrev, fCutPos));
+ aEdgePolygon.append(aCutPoint);
+ }
- // atan2 results are [-PI .. PI], consolidate to [0.0 .. 2PI]
- if(fAngleStart < 0.0)
- {
- fAngleStart += F_2PI;
+ break;
}
-
- if(fAngleEnd < 0.0)
+ case B2DLINEJOIN_ROUND :
{
- fAngleEnd += F_2PI;
+ // use tooling to add needed EllipseSegment
+ double fAngleStart(atan2(rPerpendPrev.getY(), rPerpendPrev.getX()));
+ double fAngleEnd(atan2(rPerpendEdge.getY(), rPerpendEdge.getX()));
+
+ // atan2 results are [-PI .. PI], consolidate to [0.0 .. 2PI]
+ if(fAngleStart < 0.0)
+ {
+ fAngleStart += F_2PI;
+ }
+
+ if(fAngleEnd < 0.0)
+ {
+ fAngleEnd += F_2PI;
+ }
+
+ const B2DPolygon aBow(tools::createPolygonFromEllipseSegment(rPoint, fHalfLineWidth, fHalfLineWidth, fAngleStart, fAngleEnd));
+
+ if(aBow.count() > 1)
+ {
+ // #i101491#
+ // use the original start/end positions; the ones from bow creation may be numerically
+ // different due to their different creation. To guarantee good merging quality with edges
+ // and edge roundings (and to reduce point count)
+ aEdgePolygon = aBow;
+ aEdgePolygon.setB2DPoint(0, aStartPoint);
+ aEdgePolygon.setB2DPoint(aEdgePolygon.count() - 1, aEndPoint);
+ aEdgePolygon.append(rPoint);
+
+ break;
+ }
+ else
+ {
+ // wanted fall-through to default
+ }
}
+ default: // B2DLINEJOIN_BEVEL
+ {
+ aEdgePolygon.append(aEndPoint);
+ aEdgePolygon.append(rPoint);
+ aEdgePolygon.append(aStartPoint);
- aEdgePolygon.append(tools::createPolygonFromEllipseSegment(rPoint, fHalfLineWidth, fHalfLineWidth, fAngleStart, fAngleEnd));
+ break;
+ }
}
// create last polygon part for edge
diff --git a/basegfx/source/polygon/b2dpolygoncutandtouch.cxx b/basegfx/source/polygon/b2dpolygoncutandtouch.cxx
index a1b7a69775ad..26016942717d 100644
--- a/basegfx/source/polygon/b2dpolygoncutandtouch.cxx
+++ b/basegfx/source/polygon/b2dpolygoncutandtouch.cxx
@@ -110,7 +110,10 @@ namespace basegfx
{
// #i76891# mergeTemporaryPointsAndPolygon redesigned to be able to correctly handle
// single edges with/without control points
- if(rTempPoints.size())
+ // #i101491# added counter for non-changing element count
+ const sal_uInt32 nTempPointCount(rTempPoints.size());
+
+ if(nTempPointCount)
{
B2DPolygon aRetval;
const sal_uInt32 nCount(rCandidate.count());
@@ -138,7 +141,7 @@ namespace basegfx
double fLeftStart(0.0);
// now add all points targeted to be at this index
- while(nNewInd < rTempPoints.size() && rTempPoints[nNewInd].getIndex() == a)
+ while(nNewInd < nTempPointCount && rTempPoints[nNewInd].getIndex() == a)
{
const temporaryPoint& rTempPoint = rTempPoints[nNewInd++];
@@ -160,7 +163,7 @@ namespace basegfx
else
{
// add all points targeted to be at this index
- while(nNewInd < rTempPoints.size() && rTempPoints[nNewInd].getIndex() == a)
+ while(nNewInd < nTempPointCount && rTempPoints[nNewInd].getIndex() == a)
{
const temporaryPoint& rTempPoint = rTempPoints[nNewInd++];
const B2DPoint aNewPoint(rTempPoint.getPoint());