summaryrefslogtreecommitdiff
path: root/basegfx
diff options
context:
space:
mode:
Diffstat (limited to 'basegfx')
-rw-r--r--basegfx/Library_basegfx.mk1
-rw-r--r--basegfx/source/curve/b2dcubicbezier.cxx6
-rw-r--r--basegfx/source/inc/hommatrixtemplate.hxx28
-rw-r--r--basegfx/source/matrix/b2dhommatrixtools.cxx6
-rw-r--r--basegfx/source/matrix/b3dhommatrix.cxx4
-rw-r--r--basegfx/source/polygon/b2dlinegeometry.cxx34
-rw-r--r--basegfx/source/polygon/b2dpolygon.cxx251
-rw-r--r--basegfx/source/polygon/b2dpolygontools.cxx162
-rw-r--r--basegfx/source/polygon/b2dpolygontriangulator.cxx28
-rw-r--r--basegfx/source/polygon/b2dpolypolygon.cxx20
-rw-r--r--basegfx/source/polygon/b2dpolypolygoncutter.cxx74
-rw-r--r--basegfx/source/polygon/b2dtrapezoid.cxx42
-rw-r--r--basegfx/source/polygon/b3dpolygon.cxx35
-rw-r--r--basegfx/source/polygon/b3dpolygontools.cxx6
-rw-r--r--basegfx/source/polygon/b3dpolypolygon.cxx11
-rw-r--r--basegfx/source/polygon/b3dpolypolygontools.cxx16
-rw-r--r--basegfx/source/range/b2drangeclipper.cxx1
-rw-r--r--basegfx/source/tools/unopolypolygon.cxx34
-rw-r--r--basegfx/source/workbench/bezierclip.hxx2
-rw-r--r--basegfx/test/B2DHomMatrixTest.cxx14
20 files changed, 382 insertions, 393 deletions
diff --git a/basegfx/Library_basegfx.mk b/basegfx/Library_basegfx.mk
index 8359969ae80c..2f9830d0dcfd 100644
--- a/basegfx/Library_basegfx.mk
+++ b/basegfx/Library_basegfx.mk
@@ -16,6 +16,7 @@ $(eval $(call gb_Library_set_precompiled_header,basegfx,basegfx/inc/pch/precompi
$(eval $(call gb_Library_use_sdk_api,basegfx))
$(eval $(call gb_Library_use_libraries,basegfx,\
+ comphelper \
cppu \
cppuhelper \
sal \
diff --git a/basegfx/source/curve/b2dcubicbezier.cxx b/basegfx/source/curve/b2dcubicbezier.cxx
index 046f0cf30e17..a04c17568b38 100644
--- a/basegfx/source/curve/b2dcubicbezier.cxx
+++ b/basegfx/source/curve/b2dcubicbezier.cxx
@@ -66,7 +66,7 @@ namespace basegfx
const double fCurrentAngle(aLeft.angle(aRight));
- if(fabs(fCurrentAngle) > (F_PI - fAngleBound))
+ if(fabs(fCurrentAngle) > (M_PI - fAngleBound))
{
// end recursion
nMaxRecursionDepth = 0;
@@ -203,7 +203,7 @@ namespace basegfx
const B2DVector aLeftLeft(bLeftEqualZero ? aS2L - aS1L : aS1L - rfPA); // #i72104#
const B2DVector aRightLeft(aS2L - aS3C);
const double fCurrentAngleLeft(aLeftLeft.angle(aRightLeft));
- bAngleIsSmallerLeft = (fabs(fCurrentAngleLeft) > (F_PI - rfAngleBound));
+ bAngleIsSmallerLeft = (fabs(fCurrentAngleLeft) > (M_PI - rfAngleBound));
}
// test right
@@ -213,7 +213,7 @@ namespace basegfx
const B2DVector aLeftRight(aS2R - aS3C);
const B2DVector aRightRight(bRightEqualZero ? aS2R - aS1R : aS1R - rfPB); // #i72104#
const double fCurrentAngleRight(aLeftRight.angle(aRightRight));
- bAngleIsSmallerRight = (fabs(fCurrentAngleRight) > (F_PI - rfAngleBound));
+ bAngleIsSmallerRight = (fabs(fCurrentAngleRight) > (M_PI - rfAngleBound));
}
if(bAngleIsSmallerLeft && bAngleIsSmallerRight)
diff --git a/basegfx/source/inc/hommatrixtemplate.hxx b/basegfx/source/inc/hommatrixtemplate.hxx
index 44f7cd8027cf..a80df114c3e3 100644
--- a/basegfx/source/inc/hommatrixtemplate.hxx
+++ b/basegfx/source/inc/hommatrixtemplate.hxx
@@ -174,26 +174,26 @@ namespace basegfx::internal
void testLastLine()
{
- if(mpLine)
- {
- bool bNecessary(false);
+ if(!mpLine)
+ return;
- for(sal_uInt16 a(0);!bNecessary && a < RowSize; a++)
- {
- const double fDefault(implGetDefaultValue((RowSize - 1), a));
- const double fLineValue(mpLine->get(a));
+ bool bNecessary(false);
- if(!::basegfx::fTools::equal(fDefault, fLineValue))
- {
- bNecessary = true;
- }
- }
+ for(sal_uInt16 a(0);!bNecessary && a < RowSize; a++)
+ {
+ const double fDefault(implGetDefaultValue((RowSize - 1), a));
+ const double fLineValue(mpLine->get(a));
- if(!bNecessary)
+ if(!::basegfx::fTools::equal(fDefault, fLineValue))
{
- mpLine.reset();
+ bNecessary = true;
}
}
+
+ if(!bNecessary)
+ {
+ mpLine.reset();
+ }
}
// Left-upper decomposition
diff --git a/basegfx/source/matrix/b2dhommatrixtools.cxx b/basegfx/source/matrix/b2dhommatrixtools.cxx
index 72256688c0b2..7fb6bbe0cb84 100644
--- a/basegfx/source/matrix/b2dhommatrixtools.cxx
+++ b/basegfx/source/matrix/b2dhommatrixtools.cxx
@@ -26,11 +26,11 @@ namespace basegfx::utils
{
void createSinCosOrthogonal(double& o_rSin, double& o_rCos, double fRadiant)
{
- if( fTools::equalZero( fmod( fRadiant, F_PI2 ) ) )
+ if( fTools::equalZero( fmod( fRadiant, M_PI_2 ) ) )
{
// determine quadrant
const sal_Int32 nQuad(
- (4 + fround( 4/F_2PI*fmod( fRadiant, F_2PI ) )) % 4 );
+ (4 + fround( M_2_PI*fmod( fRadiant, 2 * M_PI ) )) % 4 );
switch( nQuad )
{
case 0: // -2pi,0,2pi
@@ -355,7 +355,7 @@ namespace basegfx::utils
return aRetval;
}
- BASEGFX_DLLPUBLIC B2DHomMatrix createRotateAroundCenterKeepAspectRatioStayInsideRange(
+ B2DHomMatrix createRotateAroundCenterKeepAspectRatioStayInsideRange(
const basegfx::B2DRange& rTargetRange,
double fRotate)
{
diff --git a/basegfx/source/matrix/b3dhommatrix.cxx b/basegfx/source/matrix/b3dhommatrix.cxx
index 1382ff3c4a0f..3605767d681d 100644
--- a/basegfx/source/matrix/b3dhommatrix.cxx
+++ b/basegfx/source/matrix/b3dhommatrix.cxx
@@ -507,13 +507,13 @@ namespace basegfx
if( ::basegfx::fTools::equal( aCol0.getZ(), 1.0 )
|| aCol0.getZ() > 1.0 )
{
- fy = -F_PI/2.0;
+ fy = -M_PI/2.0;
cy = 0.0;
}
else if( ::basegfx::fTools::equal( aCol0.getZ(), -1.0 )
|| aCol0.getZ() < -1.0 )
{
- fy = F_PI/2.0;
+ fy = M_PI/2.0;
cy = 0.0;
}
else
diff --git a/basegfx/source/polygon/b2dlinegeometry.cxx b/basegfx/source/polygon/b2dlinegeometry.cxx
index 4bba7cb009f9..6dda8f9e7e1f 100644
--- a/basegfx/source/polygon/b2dlinegeometry.cxx
+++ b/basegfx/source/polygon/b2dlinegeometry.cxx
@@ -103,7 +103,7 @@ namespace basegfx::utils
// from that vector, take the needed rotation and add rotate for arrow to transformation
const B2DVector aTargetDirection(aHead - aTail);
- const double fRotation(atan2(aTargetDirection.getY(), aTargetDirection.getX()) + F_PI2);
+ const double fRotation(atan2(aTargetDirection.getY(), aTargetDirection.getX()) + M_PI_2);
// rotate around docking position
aArrowTransform.rotate(fRotation);
@@ -389,7 +389,7 @@ namespace basegfx
utils::createScaleShearXRotateTranslateB2DHomMatrix(
fHalfLineWidth, fHalfLineWidth,
0.0,
- atan2(aTangentA.getY(), aTangentA.getX()) + F_PI2,
+ atan2(aTangentA.getY(), aTangentA.getX()) + M_PI_2,
rEdge.getStartPoint().getX(), rEdge.getStartPoint().getY()));
aBezierPolygon.append(aStartPolygon);
}
@@ -452,7 +452,7 @@ namespace basegfx
utils::createScaleShearXRotateTranslateB2DHomMatrix(
fHalfLineWidth, fHalfLineWidth,
0.0,
- atan2(aTangentB.getY(), aTangentB.getX()) - F_PI2,
+ atan2(aTangentB.getY(), aTangentB.getX()) - M_PI_2,
rEdge.getEndPoint().getX(), rEdge.getEndPoint().getY()));
aBezierPolygon.append(aEndPolygon);
}
@@ -604,7 +604,7 @@ namespace basegfx
utils::createScaleShearXRotateTranslateB2DHomMatrix(
fHalfLineWidth, fHalfLineWidth,
0.0,
- fAngle + F_PI2,
+ fAngle + M_PI_2,
rEdge.getStartPoint().getX(), rEdge.getStartPoint().getY()));
}
else
@@ -642,7 +642,7 @@ namespace basegfx
utils::createScaleShearXRotateTranslateB2DHomMatrix(
fHalfLineWidth, fHalfLineWidth,
0.0,
- fAngle - F_PI2,
+ fAngle - M_PI_2,
rEdge.getEndPoint().getX(), rEdge.getEndPoint().getY()));
aEdgePolygon.append(aEndPolygon);
}
@@ -710,7 +710,7 @@ namespace basegfx
{
const double fAngle(fabs(rPerpendPrev.angle(rPerpendEdge)));
- if((F_PI - fAngle) < fMiterMinimumAngle)
+ if((M_PI - fAngle) < fMiterMinimumAngle)
{
// fallback to bevel
eJoin = B2DLineJoin::Bevel;
@@ -771,12 +771,12 @@ namespace basegfx
// atan2 results are [-PI .. PI], consolidate to [0.0 .. 2PI]
if(fAngleStart < 0.0)
{
- fAngleStart += F_2PI;
+ fAngleStart += 2 * M_PI;
}
if(fAngleEnd < 0.0)
{
- fAngleEnd += F_2PI;
+ fAngleEnd += 2 * M_PI;
}
const B2DPolygon aBow(utils::createPolygonFromEllipseSegment(rPoint, fHalfLineWidth, fHalfLineWidth, fAngleStart, fAngleEnd));
@@ -851,13 +851,13 @@ namespace basegfx
double fMiterMinimumAngle,
basegfx::triangulator::B2DTriangleVector* pTriangles)
{
- if(fMaxAllowedAngle > F_PI2)
+ if(fMaxAllowedAngle > M_PI_2)
{
- fMaxAllowedAngle = F_PI2;
+ fMaxAllowedAngle = M_PI_2;
}
- else if(fMaxAllowedAngle < 0.01 * F_PI2)
+ else if(fMaxAllowedAngle < 0.01 * M_PI_2)
{
- fMaxAllowedAngle = 0.01 * F_PI2;
+ fMaxAllowedAngle = 0.01 * M_PI_2;
}
if(fMaxPartOfEdge > 1.0)
@@ -869,13 +869,13 @@ namespace basegfx
fMaxPartOfEdge = 0.01;
}
- if(fMiterMinimumAngle > F_PI)
+ if(fMiterMinimumAngle > M_PI)
{
- fMiterMinimumAngle = F_PI;
+ fMiterMinimumAngle = M_PI;
}
- else if(fMiterMinimumAngle < 0.01 * F_PI)
+ else if(fMiterMinimumAngle < 0.01 * M_PI)
{
- fMiterMinimumAngle = 0.01 * F_PI;
+ fMiterMinimumAngle = 0.01 * M_PI;
}
B2DPolygon aCandidate(rCandidate);
@@ -935,7 +935,7 @@ namespace basegfx
{
const double fAngle(fabs(aTangentPrev.angle(aTangentEdge)));
- if(fTools::equal(fAngle, F_PI))
+ if(fTools::equal(fAngle, M_PI))
{
// for half-circle production, fallback to positive
// orientation
diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx
index 7276208cd326..3c85a2666d25 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -556,22 +556,22 @@ class ImplB2DPolygon
private:
// The point vector. This vector exists always and defines the
// count of members.
- CoordinateDataArray2D maPoints;
+ CoordinateDataArray2D maPoints;
// The control point vectors. This vectors are created on demand
// and may be zero.
- std::unique_ptr< ControlVectorArray2D > mpControlVector;
+ std::optional< ControlVectorArray2D > moControlVector;
// buffered data for e.g. default subdivision and range
std::unique_ptr< ImplBufferedData > mpBufferedData;
// flag which decides if this polygon is opened or closed
- bool mbIsClosed;
+ bool mbIsClosed;
public:
const basegfx::B2DPolygon& getDefaultAdaptiveSubdivision(const basegfx::B2DPolygon& rSource) const
{
- if(!mpControlVector || !mpControlVector->isUsed())
+ if(!moControlVector || !moControlVector->isUsed())
{
return rSource;
}
@@ -604,9 +604,9 @@ public:
mbIsClosed(rToBeCopied.mbIsClosed)
{
// complete initialization using copy
- if(rToBeCopied.mpControlVector && rToBeCopied.mpControlVector->isUsed())
+ if(rToBeCopied.moControlVector && rToBeCopied.moControlVector->isUsed())
{
- mpControlVector.reset( new ControlVectorArray2D(*rToBeCopied.mpControlVector) );
+ moControlVector.emplace( *rToBeCopied.moControlVector );
}
}
@@ -615,12 +615,12 @@ public:
mbIsClosed(rToBeCopied.mbIsClosed)
{
// complete initialization using partly copy
- if(rToBeCopied.mpControlVector && rToBeCopied.mpControlVector->isUsed())
+ if(rToBeCopied.moControlVector && rToBeCopied.moControlVector->isUsed())
{
- mpControlVector.reset( new ControlVectorArray2D(*rToBeCopied.mpControlVector, nIndex, nCount) );
+ moControlVector.emplace( *rToBeCopied.moControlVector, nIndex, nCount );
- if(!mpControlVector->isUsed())
- mpControlVector.reset();
+ if(!moControlVector->isUsed())
+ moControlVector.reset();
}
}
@@ -628,16 +628,16 @@ public:
{
if (this != &rOther)
{
- mpControlVector.reset();
+ moControlVector.reset();
mpBufferedData.reset();
maPoints = rOther.maPoints;
mbIsClosed = rOther.mbIsClosed;
- if (rOther.mpControlVector && rOther.mpControlVector->isUsed())
+ if (rOther.moControlVector && rOther.moControlVector->isUsed())
{
- mpControlVector.reset( new ControlVectorArray2D(*rOther.mpControlVector) );
+ moControlVector.emplace( *rOther.moControlVector );
- if(!mpControlVector->isUsed())
- mpControlVector.reset();
+ if(!moControlVector->isUsed())
+ moControlVector.reset();
}
}
return *this;
@@ -664,41 +664,34 @@ public:
bool operator==(const ImplB2DPolygon& rCandidate) const
{
- if(mbIsClosed == rCandidate.mbIsClosed)
+ if(mbIsClosed != rCandidate.mbIsClosed)
+ return false;
+ if(!(maPoints == rCandidate.maPoints))
+ return false;
+ bool bControlVectorsAreEqual(true);
+
+ if(moControlVector)
{
- if(maPoints == rCandidate.maPoints)
+ if(rCandidate.moControlVector)
{
- bool bControlVectorsAreEqual(true);
-
- if(mpControlVector)
- {
- if(rCandidate.mpControlVector)
- {
- bControlVectorsAreEqual = ((*mpControlVector) == (*rCandidate.mpControlVector));
- }
- else
- {
- // candidate has no control vector, so it's assumed all unused.
- bControlVectorsAreEqual = !mpControlVector->isUsed();
- }
- }
- else
- {
- if(rCandidate.mpControlVector)
- {
- // we have no control vector, so it's assumed all unused.
- bControlVectorsAreEqual = !rCandidate.mpControlVector->isUsed();
- }
- }
-
- if(bControlVectorsAreEqual)
- {
- return true;
- }
+ bControlVectorsAreEqual = ((*moControlVector) == (*rCandidate.moControlVector));
+ }
+ else
+ {
+ // candidate has no control vector, so it's assumed all unused.
+ bControlVectorsAreEqual = !moControlVector->isUsed();
+ }
+ }
+ else
+ {
+ if(rCandidate.moControlVector)
+ {
+ // we have no control vector, so it's assumed all unused.
+ bControlVectorsAreEqual = !rCandidate.moControlVector->isUsed();
}
}
- return false;
+ return bControlVectorsAreEqual;
}
const basegfx::B2DPoint& getPoint(sal_uInt32 nIndex) const
@@ -723,10 +716,10 @@ public:
const CoordinateData2D aCoordinate(rPoint);
maPoints.append(aCoordinate);
- if(mpControlVector)
+ if(moControlVector)
{
const ControlVectorPair2D aVectorPair;
- mpControlVector->append(aVectorPair);
+ moControlVector->append(aVectorPair);
}
}
@@ -738,19 +731,19 @@ public:
CoordinateData2D aCoordinate(rPoint);
maPoints.insert(nIndex, aCoordinate, nCount);
- if(mpControlVector)
+ if(moControlVector)
{
ControlVectorPair2D aVectorPair;
- mpControlVector->insert(nIndex, aVectorPair, nCount);
+ moControlVector->insert(nIndex, aVectorPair, nCount);
}
}
}
const basegfx::B2DVector& getPrevControlVector(sal_uInt32 nIndex) const
{
- if(mpControlVector)
+ if(moControlVector)
{
- return mpControlVector->getPrevVector(nIndex);
+ return moControlVector->getPrevVector(nIndex);
}
else
{
@@ -760,30 +753,30 @@ public:
void setPrevControlVector(sal_uInt32 nIndex, const basegfx::B2DVector& rValue)
{
- if(!mpControlVector)
+ if(!moControlVector)
{
if(!rValue.equalZero())
{
mpBufferedData.reset();
- mpControlVector.reset( new ControlVectorArray2D(maPoints.count()) );
- mpControlVector->setPrevVector(nIndex, rValue);
+ moControlVector.emplace(maPoints.count());
+ moControlVector->setPrevVector(nIndex, rValue);
}
}
else
{
mpBufferedData.reset();
- mpControlVector->setPrevVector(nIndex, rValue);
+ moControlVector->setPrevVector(nIndex, rValue);
- if(!mpControlVector->isUsed())
- mpControlVector.reset();
+ if(!moControlVector->isUsed())
+ moControlVector.reset();
}
}
const basegfx::B2DVector& getNextControlVector(sal_uInt32 nIndex) const
{
- if(mpControlVector)
+ if(moControlVector)
{
- return mpControlVector->getNextVector(nIndex);
+ return moControlVector->getNextVector(nIndex);
}
else
{
@@ -793,34 +786,34 @@ public:
void setNextControlVector(sal_uInt32 nIndex, const basegfx::B2DVector& rValue)
{
- if(!mpControlVector)
+ if(!moControlVector)
{
if(!rValue.equalZero())
{
mpBufferedData.reset();
- mpControlVector.reset( new ControlVectorArray2D(maPoints.count()) );
- mpControlVector->setNextVector(nIndex, rValue);
+ moControlVector.emplace(maPoints.count());
+ moControlVector->setNextVector(nIndex, rValue);
}
}
else
{
mpBufferedData.reset();
- mpControlVector->setNextVector(nIndex, rValue);
+ moControlVector->setNextVector(nIndex, rValue);
- if(!mpControlVector->isUsed())
- mpControlVector.reset();
+ if(!moControlVector->isUsed())
+ moControlVector.reset();
}
}
bool areControlPointsUsed() const
{
- return (mpControlVector && mpControlVector->isUsed());
+ return (moControlVector && moControlVector->isUsed());
}
void resetControlVectors()
{
mpBufferedData.reset();
- mpControlVector.reset();
+ moControlVector.reset();
}
void setControlVectors(sal_uInt32 nIndex, const basegfx::B2DVector& rPrev, const basegfx::B2DVector& rNext)
@@ -852,24 +845,24 @@ public:
mpBufferedData.reset();
- if(rSource.mpControlVector && rSource.mpControlVector->isUsed() && !mpControlVector)
+ if(rSource.moControlVector && rSource.moControlVector->isUsed() && !moControlVector)
{
- mpControlVector.reset( new ControlVectorArray2D(maPoints.count()) );
+ moControlVector.emplace(maPoints.count());
}
maPoints.insert(nIndex, rSource.maPoints);
- if(rSource.mpControlVector)
+ if(rSource.moControlVector)
{
- mpControlVector->insert(nIndex, *rSource.mpControlVector);
+ moControlVector->insert(nIndex, *rSource.moControlVector);
- if(!mpControlVector->isUsed())
- mpControlVector.reset();
+ if(!moControlVector->isUsed())
+ moControlVector.reset();
}
- else if(mpControlVector)
+ else if(moControlVector)
{
ControlVectorPair2D aVectorPair;
- mpControlVector->insert(nIndex, aVectorPair, nCount);
+ moControlVector->insert(nIndex, aVectorPair, nCount);
}
}
@@ -881,12 +874,12 @@ public:
mpBufferedData.reset();
maPoints.remove(nIndex, nCount);
- if(mpControlVector)
+ if(moControlVector)
{
- mpControlVector->remove(nIndex, nCount);
+ moControlVector->remove(nIndex, nCount);
- if(!mpControlVector->isUsed())
- mpControlVector.reset();
+ if(!moControlVector->isUsed())
+ moControlVector.reset();
}
}
@@ -900,10 +893,10 @@ public:
// flip points
maPoints.flip(mbIsClosed);
- if(mpControlVector)
+ if(moControlVector)
{
// flip control vector
- mpControlVector->flip(mbIsClosed);
+ moControlVector->flip(mbIsClosed);
}
}
@@ -916,9 +909,9 @@ public:
if(maPoints.getCoordinate(0) == maPoints.getCoordinate(nIndex))
{
- if(mpControlVector)
+ if(moControlVector)
{
- if(mpControlVector->getNextVector(nIndex).equalZero() && mpControlVector->getPrevVector(0).equalZero())
+ if(moControlVector->getNextVector(nIndex).equalZero() && moControlVector->getPrevVector(0).equalZero())
{
return true;
}
@@ -935,9 +928,9 @@ public:
{
if(maPoints.getCoordinate(a) == maPoints.getCoordinate(a + 1))
{
- if(mpControlVector)
+ if(moControlVector)
{
- if(mpControlVector->getNextVector(a).equalZero() && mpControlVector->getPrevVector(a + 1).equalZero())
+ if(moControlVector->getNextVector(a).equalZero() && moControlVector->getPrevVector(a + 1).equalZero())
{
return true;
}
@@ -960,7 +953,7 @@ public:
mpBufferedData.reset();
- if(mpControlVector)
+ if(moControlVector)
{
bool bRemove;
@@ -974,9 +967,9 @@ public:
if(maPoints.getCoordinate(0) == maPoints.getCoordinate(nIndex))
{
- if(mpControlVector)
+ if(moControlVector)
{
- if(mpControlVector->getNextVector(nIndex).equalZero() && mpControlVector->getPrevVector(0).equalZero())
+ if(moControlVector->getNextVector(nIndex).equalZero() && moControlVector->getPrevVector(0).equalZero())
{
bRemove = true;
}
@@ -992,9 +985,9 @@ public:
{
const sal_uInt32 nIndex(maPoints.count() - 1);
- if(mpControlVector && !mpControlVector->getPrevVector(nIndex).equalZero())
+ if(moControlVector && !moControlVector->getPrevVector(nIndex).equalZero())
{
- mpControlVector->setPrevVector(0, mpControlVector->getPrevVector(nIndex));
+ moControlVector->setPrevVector(0, moControlVector->getPrevVector(nIndex));
}
remove(nIndex, 1);
@@ -1012,7 +1005,7 @@ public:
{
mpBufferedData.reset();
- if(mpControlVector)
+ if(moControlVector)
{
sal_uInt32 nIndex(0);
@@ -1022,9 +1015,9 @@ public:
{
bool bRemove(maPoints.getCoordinate(nIndex) == maPoints.getCoordinate(nIndex + 1));
- if(bRemove && mpControlVector)
+ if(bRemove && moControlVector)
{
- if(!mpControlVector->getNextVector(nIndex).equalZero() || !mpControlVector->getPrevVector(nIndex + 1).equalZero())
+ if(!moControlVector->getNextVector(nIndex).equalZero() || !moControlVector->getPrevVector(nIndex + 1).equalZero())
{
bRemove = false;
}
@@ -1032,9 +1025,9 @@ public:
if(bRemove)
{
- if(mpControlVector && !mpControlVector->getPrevVector(nIndex).equalZero())
+ if(moControlVector && !moControlVector->getPrevVector(nIndex).equalZero())
{
- mpControlVector->setPrevVector(nIndex + 1, mpControlVector->getPrevVector(nIndex));
+ moControlVector->setPrevVector(nIndex + 1, moControlVector->getPrevVector(nIndex));
}
// if next is same as index and the control vectors are unused, delete index
@@ -1057,27 +1050,27 @@ public:
{
mpBufferedData.reset();
- if(mpControlVector)
+ if(moControlVector)
{
for(sal_uInt32 a(0); a < maPoints.count(); a++)
{
basegfx::B2DPoint aCandidate = maPoints.getCoordinate(a);
- if(mpControlVector->isUsed())
+ if(moControlVector->isUsed())
{
- const basegfx::B2DVector& rPrevVector(mpControlVector->getPrevVector(a));
- const basegfx::B2DVector& rNextVector(mpControlVector->getNextVector(a));
+ const basegfx::B2DVector& rPrevVector(moControlVector->getPrevVector(a));
+ const basegfx::B2DVector& rNextVector(moControlVector->getNextVector(a));
if(!rPrevVector.equalZero())
{
basegfx::B2DVector aPrevVector(rMatrix * rPrevVector);
- mpControlVector->setPrevVector(a, aPrevVector);
+ moControlVector->setPrevVector(a, aPrevVector);
}
if(!rNextVector.equalZero())
{
basegfx::B2DVector aNextVector(rMatrix * rNextVector);
- mpControlVector->setNextVector(a, aNextVector);
+ moControlVector->setNextVector(a, aNextVector);
}
}
@@ -1085,8 +1078,8 @@ public:
maPoints.setCoordinate(a, aCandidate);
}
- if(!mpControlVector->isUsed())
- mpControlVector.reset();
+ if(!moControlVector->isUsed())
+ moControlVector.reset();
}
else
{
@@ -1177,9 +1170,9 @@ namespace basegfx
void B2DPolygon::setB2DPoint(sal_uInt32 nIndex, const B2DPoint& rValue)
{
- OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B2DPolygon access outside range (!)");
+ OSL_ENSURE(nIndex < std::as_const(mpPolygon)->count(), "B2DPolygon access outside range (!)");
- if(std::as_const(*mpPolygon).getPoint(nIndex) != rValue)
+ if(std::as_const(mpPolygon)->getPoint(nIndex) != rValue)
{
mpPolygon->setPoint(nIndex, rValue);
}
@@ -1192,7 +1185,7 @@ namespace basegfx
void B2DPolygon::insert(sal_uInt32 nIndex, const B2DPoint& rPoint, sal_uInt32 nCount)
{
- OSL_ENSURE(nIndex <= std::as_const(*mpPolygon).count(), "B2DPolygon Insert outside range (!)");
+ OSL_ENSURE(nIndex <= std::as_const(mpPolygon)->count(), "B2DPolygon Insert outside range (!)");
if(nCount)
{
@@ -1204,7 +1197,7 @@ namespace basegfx
{
if(nCount)
{
- mpPolygon->insert(std::as_const(*mpPolygon).count(), rPoint, nCount);
+ mpPolygon->insert(std::as_const(mpPolygon)->count(), rPoint, nCount);
}
}
@@ -1243,10 +1236,10 @@ namespace basegfx
void B2DPolygon::setPrevControlPoint(sal_uInt32 nIndex, const B2DPoint& rValue)
{
- OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B2DPolygon access outside range (!)");
- const basegfx::B2DVector aNewVector(rValue - std::as_const(*mpPolygon).getPoint(nIndex));
+ OSL_ENSURE(nIndex < std::as_const(mpPolygon)->count(), "B2DPolygon access outside range (!)");
+ const basegfx::B2DVector aNewVector(rValue - std::as_const(mpPolygon)->getPoint(nIndex));
- if(std::as_const(*mpPolygon).getPrevControlVector(nIndex) != aNewVector)
+ if(std::as_const(mpPolygon)->getPrevControlVector(nIndex) != aNewVector)
{
mpPolygon->setPrevControlVector(nIndex, aNewVector);
}
@@ -1254,10 +1247,10 @@ namespace basegfx
void B2DPolygon::setNextControlPoint(sal_uInt32 nIndex, const B2DPoint& rValue)
{
- OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B2DPolygon access outside range (!)");
- const basegfx::B2DVector aNewVector(rValue - std::as_const(*mpPolygon).getPoint(nIndex));
+ OSL_ENSURE(nIndex < std::as_const(mpPolygon)->count(), "B2DPolygon access outside range (!)");
+ const basegfx::B2DVector aNewVector(rValue - std::as_const(mpPolygon)->getPoint(nIndex));
- if(std::as_const(*mpPolygon).getNextControlVector(nIndex) != aNewVector)
+ if(std::as_const(mpPolygon)->getNextControlVector(nIndex) != aNewVector)
{
mpPolygon->setNextControlVector(nIndex, aNewVector);
}
@@ -1265,12 +1258,12 @@ namespace basegfx
void B2DPolygon::setControlPoints(sal_uInt32 nIndex, const basegfx::B2DPoint& rPrev, const basegfx::B2DPoint& rNext)
{
- OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B2DPolygon access outside range (!)");
- const B2DPoint aPoint(std::as_const(*mpPolygon).getPoint(nIndex));
+ OSL_ENSURE(nIndex < std::as_const(mpPolygon)->count(), "B2DPolygon access outside range (!)");
+ const B2DPoint aPoint(std::as_const(mpPolygon)->getPoint(nIndex));
const basegfx::B2DVector aNewPrev(rPrev - aPoint);
const basegfx::B2DVector aNewNext(rNext - aPoint);
- if(std::as_const(*mpPolygon).getPrevControlVector(nIndex) != aNewPrev || std::as_const(*mpPolygon).getNextControlVector(nIndex) != aNewNext)
+ if(std::as_const(mpPolygon)->getPrevControlVector(nIndex) != aNewPrev || std::as_const(mpPolygon)->getNextControlVector(nIndex) != aNewNext)
{
mpPolygon->setControlVectors(nIndex, aNewPrev, aNewNext);
}
@@ -1278,9 +1271,9 @@ namespace basegfx
void B2DPolygon::resetPrevControlPoint(sal_uInt32 nIndex)
{
- OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B2DPolygon access outside range (!)");
+ OSL_ENSURE(nIndex < std::as_const(mpPolygon)->count(), "B2DPolygon access outside range (!)");
- if(std::as_const(*mpPolygon).areControlPointsUsed() && !std::as_const(*mpPolygon).getPrevControlVector(nIndex).equalZero())
+ if(std::as_const(mpPolygon)->areControlPointsUsed() && !std::as_const(mpPolygon)->getPrevControlVector(nIndex).equalZero())
{
mpPolygon->setPrevControlVector(nIndex, B2DVector::getEmptyVector());
}
@@ -1288,9 +1281,9 @@ namespace basegfx
void B2DPolygon::resetNextControlPoint(sal_uInt32 nIndex)
{
- OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B2DPolygon access outside range (!)");
+ OSL_ENSURE(nIndex < std::as_const(mpPolygon)->count(), "B2DPolygon access outside range (!)");
- if(std::as_const(*mpPolygon).areControlPointsUsed() && !std::as_const(*mpPolygon).getNextControlVector(nIndex).equalZero())
+ if(std::as_const(mpPolygon)->areControlPointsUsed() && !std::as_const(mpPolygon)->getNextControlVector(nIndex).equalZero())
{
mpPolygon->setNextControlVector(nIndex, B2DVector::getEmptyVector());
}
@@ -1298,7 +1291,7 @@ namespace basegfx
void B2DPolygon::resetControlPoints()
{
- if(std::as_const(*mpPolygon).areControlPointsUsed())
+ if(std::as_const(mpPolygon)->areControlPointsUsed())
{
mpPolygon->resetControlVectors();
}
@@ -1309,12 +1302,12 @@ namespace basegfx
const B2DPoint& rPrevControlPoint,
const B2DPoint& rPoint)
{
- const B2DVector aNewNextVector(std::as_const(*mpPolygon).count() ? B2DVector(rNextControlPoint - std::as_const(*mpPolygon).getPoint(std::as_const(*mpPolygon).count() - 1)) : B2DVector::getEmptyVector());
+ const B2DVector aNewNextVector(std::as_const(mpPolygon)->count() ? B2DVector(rNextControlPoint - std::as_const(mpPolygon)->getPoint(std::as_const(mpPolygon)->count() - 1)) : B2DVector::getEmptyVector());
const B2DVector aNewPrevVector(rPrevControlPoint - rPoint);
if(aNewNextVector.equalZero() && aNewPrevVector.equalZero())
{
- mpPolygon->insert(std::as_const(*mpPolygon).count(), rPoint, 1);
+ mpPolygon->insert(std::as_const(mpPolygon)->count(), rPoint, 1);
}
else
{
@@ -1324,7 +1317,7 @@ namespace basegfx
void B2DPolygon::appendQuadraticBezierSegment(const B2DPoint& rControlPoint, const B2DPoint& rPoint)
{
- if (std::as_const(*mpPolygon).count() == 0)
+ if (std::as_const(mpPolygon)->count() == 0)
{
mpPolygon->append(rPoint);
const double nX((rControlPoint.getX() * 2.0 + rPoint.getX()) / 3.0);
@@ -1333,7 +1326,7 @@ namespace basegfx
}
else
{
- const B2DPoint aPreviousPoint(std::as_const(*mpPolygon).getPoint(std::as_const(*mpPolygon).count() - 1));
+ const B2DPoint aPreviousPoint(std::as_const(mpPolygon)->getPoint(std::as_const(mpPolygon)->count() - 1));
const double nX1((rControlPoint.getX() * 2.0 + aPreviousPoint.getX()) / 3.0);
const double nY1((rControlPoint.getY() * 2.0 + aPreviousPoint.getY()) / 3.0);
@@ -1436,19 +1429,19 @@ namespace basegfx
if(nIndex == 0 && nCount == rPoly.count())
{
- mpPolygon->insert(std::as_const(*mpPolygon).count(), *rPoly.mpPolygon);
+ mpPolygon->insert(std::as_const(mpPolygon)->count(), *rPoly.mpPolygon);
}
else
{
OSL_ENSURE(nIndex + nCount <= rPoly.mpPolygon->count(), "B2DPolygon Append outside range (!)");
ImplB2DPolygon aTempPoly(*rPoly.mpPolygon, nIndex, nCount);
- mpPolygon->insert(std::as_const(*mpPolygon).count(), aTempPoly);
+ mpPolygon->insert(std::as_const(mpPolygon)->count(), aTempPoly);
}
}
void B2DPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount)
{
- OSL_ENSURE(nIndex + nCount <= std::as_const(*mpPolygon).count(), "B2DPolygon Remove outside range (!)");
+ OSL_ENSURE(nIndex + nCount <= std::as_const(mpPolygon)->count(), "B2DPolygon Remove outside range (!)");
if(nCount)
{
@@ -1498,7 +1491,7 @@ namespace basegfx
void B2DPolygon::transform(const B2DHomMatrix& rMatrix)
{
- if(std::as_const(*mpPolygon).count() && !rMatrix.isIdentity())
+ if(std::as_const(mpPolygon)->count() && !rMatrix.isIdentity())
{
mpPolygon->transform(rMatrix);
}
diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx
index d4644a6f0606..c6eb3cf5b28b 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -1530,36 +1530,36 @@ namespace basegfx::utils
const B2DPolygon& aCandidate(rCandidate.getDefaultAdaptiveSubdivision());
const sal_uInt32 nPointCount(aCandidate.count());
- if(nPointCount)
- {
- const sal_uInt32 nEdgeCount(aCandidate.isClosed() ? nPointCount : nPointCount - 1);
- B2DPoint aCurrent(aCandidate.getB2DPoint(0));
-
- if(nEdgeCount)
- {
- // edges
- for(sal_uInt32 a(0); a < nEdgeCount; a++)
- {
- const sal_uInt32 nNextIndex((a + 1) % nPointCount);
- const B2DPoint aNext(aCandidate.getB2DPoint(nNextIndex));
+ if(!nPointCount)
+ return false;
- if(isInEpsilonRange(aCurrent, aNext, rTestPosition, fDistance))
- {
- return true;
- }
+ const sal_uInt32 nEdgeCount(aCandidate.isClosed() ? nPointCount : nPointCount - 1);
+ B2DPoint aCurrent(aCandidate.getB2DPoint(0));
- // prepare next step
- aCurrent = aNext;
- }
- }
- else
+ if(nEdgeCount)
+ {
+ // edges
+ for(sal_uInt32 a(0); a < nEdgeCount; a++)
{
- // no edges, but points -> not closed. Check single point. Just
- // use isInEpsilonRange with twice the same point, it handles those well
- if(isInEpsilonRange(aCurrent, aCurrent, rTestPosition, fDistance))
+ const sal_uInt32 nNextIndex((a + 1) % nPointCount);
+ const B2DPoint aNext(aCandidate.getB2DPoint(nNextIndex));
+
+ if(isInEpsilonRange(aCurrent, aNext, rTestPosition, fDistance))
{
return true;
}
+
+ // prepare next step
+ aCurrent = aNext;
+ }
+ }
+ else
+ {
+ // no edges, but points -> not closed. Check single point. Just
+ // use isInEpsilonRange with twice the same point, it handles those well
+ if(isInEpsilonRange(aCurrent, aCurrent, rTestPosition, fDistance))
+ {
+ return true;
}
}
@@ -1572,8 +1572,8 @@ namespace basegfx::utils
// and alternatives read document "ApproxCircleInfo.odt", attachment of bug tdf#121425.
static double impDistanceBezierPointToControl(double fAngle)
{
- SAL_WARN_IF(fAngle < 0 || fAngle > F_PI2,"basegfx","angle not suitable for approximate circle");
- if (0 <= fAngle && fAngle <= F_PI2)
+ SAL_WARN_IF(fAngle < 0 || fAngle > M_PI_2,"basegfx","angle not suitable for approximate circle");
+ if (0 <= fAngle && fAngle <= M_PI_2)
{
return 4.0/3.0 * ( tan(fAngle/4.0));
}
@@ -1624,7 +1624,7 @@ namespace basegfx::utils
B2DPolygon aRetval;
const double fBowX((rRect.getWidth() / 2.0) * fRadiusX);
const double fBowY((rRect.getHeight() / 2.0) * fRadiusY);
- const double fKappa(impDistanceBezierPointToControl(F_PI2));
+ const double fKappa(impDistanceBezierPointToControl(M_PI_2));
// create start point at bottom center
if(!rtl::math::approxEqual(fOne, fRadiusX))
@@ -1723,8 +1723,8 @@ namespace basegfx::utils
static B2DPolygon impCreateUnitCircle(sal_uInt32 nStartQuadrant)
{
B2DPolygon aUnitCircle;
- const double fSegmentKappa = impDistanceBezierPointToControl(F_PI2 / STEPSPERQUARTER);
- const B2DHomMatrix aRotateMatrix(createRotateB2DHomMatrix(F_PI2 / STEPSPERQUARTER));
+ const double fSegmentKappa = impDistanceBezierPointToControl(M_PI_2 / STEPSPERQUARTER);
+ const B2DHomMatrix aRotateMatrix(createRotateB2DHomMatrix(M_PI_2 / STEPSPERQUARTER));
B2DPoint aPoint(1.0, 0.0);
B2DPoint aForward(1.0, fSegmentKappa);
@@ -1732,7 +1732,7 @@ namespace basegfx::utils
if(nStartQuadrant != 0)
{
- const B2DHomMatrix aQuadrantMatrix(createRotateB2DHomMatrix(F_PI2 * (nStartQuadrant % 4)));
+ const B2DHomMatrix aQuadrantMatrix(createRotateB2DHomMatrix(M_PI_2 * (nStartQuadrant % 4)));
aPoint *= aQuadrantMatrix;
aBackward *= aQuadrantMatrix;
aForward *= aQuadrantMatrix;
@@ -1758,8 +1758,8 @@ namespace basegfx::utils
{
static auto const singleton = [] {
B2DPolygon aUnitHalfCircle;
- const double fSegmentKappa(impDistanceBezierPointToControl(F_PI2 / STEPSPERQUARTER));
- const B2DHomMatrix aRotateMatrix(createRotateB2DHomMatrix(F_PI2 / STEPSPERQUARTER));
+ const double fSegmentKappa(impDistanceBezierPointToControl(M_PI_2 / STEPSPERQUARTER));
+ const B2DHomMatrix aRotateMatrix(createRotateB2DHomMatrix(M_PI_2 / STEPSPERQUARTER));
B2DPoint aPoint(1.0, 0.0);
B2DPoint aForward(1.0, fSegmentKappa);
B2DPoint aBackward(1.0, -fSegmentKappa);
@@ -1822,14 +1822,14 @@ namespace basegfx::utils
{
B2DPolygon aRetval;
- // truncate fStart, fEnd to a range of [0.0 .. F_2PI[ where F_2PI
+ // truncate fStart, fEnd to a range of [0.0 .. 2PI[ where 2PI
// falls back to 0.0 to ensure a unique definition
if(fTools::less(fStart, 0.0))
{
fStart = 0.0;
}
- if(fTools::moreOrEqual(fStart, F_2PI))
+ if(fTools::moreOrEqual(fStart, 2 * M_PI))
{
fStart = 0.0;
}
@@ -1839,7 +1839,7 @@ namespace basegfx::utils
fEnd = 0.0;
}
- if(fTools::moreOrEqual(fEnd, F_2PI))
+ if(fTools::moreOrEqual(fEnd, 2 * M_PI))
{
fEnd = 0.0;
}
@@ -1852,7 +1852,7 @@ namespace basegfx::utils
else
{
const sal_uInt32 nSegments(STEPSPERQUARTER * 4);
- const double fAnglePerSegment(F_PI2 / STEPSPERQUARTER);
+ const double fAnglePerSegment(M_PI_2 / STEPSPERQUARTER);
const sal_uInt32 nStartSegment(sal_uInt32(fStart / fAnglePerSegment) % nSegments);
const sal_uInt32 nEndSegment(sal_uInt32(fEnd / fAnglePerSegment) % nSegments);
const double fSegmentKappa(impDistanceBezierPointToControl(fAnglePerSegment));
@@ -1933,29 +1933,29 @@ namespace basegfx::utils
OSL_ENSURE(!rCandidate.areControlPointsUsed(), "hasNeutralPoints: ATM works not for curves (!)");
const sal_uInt32 nPointCount(rCandidate.count());
- if(nPointCount > 2)
+ if(nPointCount <= 2)
+ return false;
+
+ B2DPoint aPrevPoint(rCandidate.getB2DPoint(nPointCount - 1));
+ B2DPoint aCurrPoint(rCandidate.getB2DPoint(0));
+
+ for(sal_uInt32 a(0); a < nPointCount; a++)
{
- B2DPoint aPrevPoint(rCandidate.getB2DPoint(nPointCount - 1));
- B2DPoint aCurrPoint(rCandidate.getB2DPoint(0));
+ const B2DPoint aNextPoint(rCandidate.getB2DPoint((a + 1) % nPointCount));
+ const B2DVector aPrevVec(aPrevPoint - aCurrPoint);
+ const B2DVector aNextVec(aNextPoint - aCurrPoint);
+ const B2VectorOrientation aOrientation(getOrientation(aNextVec, aPrevVec));
- for(sal_uInt32 a(0); a < nPointCount; a++)
+ if(aOrientation == B2VectorOrientation::Neutral)
{
- const B2DPoint aNextPoint(rCandidate.getB2DPoint((a + 1) % nPointCount));
- const B2DVector aPrevVec(aPrevPoint - aCurrPoint);
- const B2DVector aNextVec(aNextPoint - aCurrPoint);
- const B2VectorOrientation aOrientation(getOrientation(aNextVec, aPrevVec));
-
- if(aOrientation == B2VectorOrientation::Neutral)
- {
- // current has neutral orientation
- return true;
- }
- else
- {
- // prepare next
- aPrevPoint = aCurrPoint;
- aCurrPoint = aNextPoint;
- }
+ // current has neutral orientation
+ return true;
+ }
+ else
+ {
+ // prepare next
+ aPrevPoint = aCurrPoint;
+ aCurrPoint = aNextPoint;
}
}
@@ -2015,37 +2015,37 @@ namespace basegfx::utils
OSL_ENSURE(!rCandidate.areControlPointsUsed(), "isConvex: ATM works not for curves (!)");
const sal_uInt32 nPointCount(rCandidate.count());
- if(nPointCount > 2)
+ if(nPointCount <= 2)
+ return true;
+
+ const B2DPoint aPrevPoint(rCandidate.getB2DPoint(nPointCount - 1));
+ B2DPoint aCurrPoint(rCandidate.getB2DPoint(0));
+ B2DVector aCurrVec(aPrevPoint - aCurrPoint);
+ B2VectorOrientation aOrientation(B2VectorOrientation::Neutral);
+
+ for(sal_uInt32 a(0); a < nPointCount; a++)
{
- const B2DPoint aPrevPoint(rCandidate.getB2DPoint(nPointCount - 1));
- B2DPoint aCurrPoint(rCandidate.getB2DPoint(0));
- B2DVector aCurrVec(aPrevPoint - aCurrPoint);
- B2VectorOrientation aOrientation(B2VectorOrientation::Neutral);
+ const B2DPoint aNextPoint(rCandidate.getB2DPoint((a + 1) % nPointCount));
+ const B2DVector aNextVec(aNextPoint - aCurrPoint);
+ const B2VectorOrientation aCurrentOrientation(getOrientation(aNextVec, aCurrVec));
- for(sal_uInt32 a(0); a < nPointCount; a++)
+ if(aOrientation == B2VectorOrientation::Neutral)
{
- const B2DPoint aNextPoint(rCandidate.getB2DPoint((a + 1) % nPointCount));
- const B2DVector aNextVec(aNextPoint - aCurrPoint);
- const B2VectorOrientation aCurrentOrientation(getOrientation(aNextVec, aCurrVec));
-
- if(aOrientation == B2VectorOrientation::Neutral)
- {
- // set start value, maybe neutral again
- aOrientation = aCurrentOrientation;
- }
- else
+ // set start value, maybe neutral again
+ aOrientation = aCurrentOrientation;
+ }
+ else
+ {
+ if(aCurrentOrientation != B2VectorOrientation::Neutral && aCurrentOrientation != aOrientation)
{
- if(aCurrentOrientation != B2VectorOrientation::Neutral && aCurrentOrientation != aOrientation)
- {
- // different orientations found, that's it
- return false;
- }
+ // different orientations found, that's it
+ return false;
}
-
- // prepare next
- aCurrPoint = aNextPoint;
- aCurrVec = -aNextVec;
}
+
+ // prepare next
+ aCurrPoint = aNextPoint;
+ aCurrVec = -aNextVec;
}
return true;
diff --git a/basegfx/source/polygon/b2dpolygontriangulator.cxx b/basegfx/source/polygon/b2dpolygontriangulator.cxx
index 880b1b5c310c..5fbd3960e585 100644
--- a/basegfx/source/polygon/b2dpolygontriangulator.cxx
+++ b/basegfx/source/polygon/b2dpolygontriangulator.cxx
@@ -180,23 +180,23 @@ namespace basegfx
bool Triangulator::CheckPointInTriangle(EdgeEntry* pEdgeA, EdgeEntry const * pEdgeB, const B2DPoint& rTestPoint)
{
// inside triangle or on edge?
- if(utils::isPointInTriangle(pEdgeA->getStart(), pEdgeA->getEnd(), pEdgeB->getEnd(), rTestPoint, true))
+ if(!utils::isPointInTriangle(pEdgeA->getStart(), pEdgeA->getEnd(), pEdgeB->getEnd(), rTestPoint, true))
+ return true;
+
+ // but not on point
+ if(!rTestPoint.equal(pEdgeA->getEnd()) && !rTestPoint.equal(pEdgeB->getEnd()))
{
- // but not on point
- if(!rTestPoint.equal(pEdgeA->getEnd()) && !rTestPoint.equal(pEdgeB->getEnd()))
- {
- // found point in triangle -> split triangle inserting two edges
- EdgeEntry* pStart = new EdgeEntry(pEdgeA->getStart(), rTestPoint);
- EdgeEntry* pEnd = new EdgeEntry(*pStart);
- maNewEdgeEntries.emplace_back(pStart);
- maNewEdgeEntries.emplace_back(pEnd);
+ // found point in triangle -> split triangle inserting two edges
+ EdgeEntry* pStart = new EdgeEntry(pEdgeA->getStart(), rTestPoint);
+ EdgeEntry* pEnd = new EdgeEntry(*pStart);
+ maNewEdgeEntries.emplace_back(pStart);
+ maNewEdgeEntries.emplace_back(pEnd);
- pStart->setNext(pEnd);
- pEnd->setNext(pEdgeA->getNext());
- pEdgeA->setNext(pStart);
+ pStart->setNext(pEnd);
+ pEnd->setNext(pEdgeA->getNext());
+ pEdgeA->setNext(pStart);
- return false;
- }
+ return false;
}
return true;
diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx
index 34ff30877ea8..4fd12bde4a10 100644
--- a/basegfx/source/polygon/b2dpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dpolypolygon.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <utility>
+
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <osl/diagnose.h>
#include <basegfx/polygon/b2dpolygon.hxx>
@@ -249,7 +253,7 @@ namespace basegfx
void B2DPolyPolygon::setB2DPolygon(sal_uInt32 nIndex, const B2DPolygon& rPolygon)
{
- OSL_ENSURE(nIndex < std::as_const(*mpPolyPolygon).count(), "B2DPolyPolygon access outside range (!)");
+ OSL_ENSURE(nIndex < std::as_const(mpPolyPolygon)->count(), "B2DPolyPolygon access outside range (!)");
if(getB2DPolygon(nIndex) != rPolygon)
mpPolyPolygon->setB2DPolygon(nIndex, rPolygon);
@@ -272,7 +276,7 @@ namespace basegfx
void B2DPolyPolygon::insert(sal_uInt32 nIndex, const B2DPolygon& rPolygon, sal_uInt32 nCount)
{
- OSL_ENSURE(nIndex <= std::as_const(*mpPolyPolygon).count(), "B2DPolyPolygon Insert outside range (!)");
+ OSL_ENSURE(nIndex <= std::as_const(mpPolyPolygon)->count(), "B2DPolyPolygon Insert outside range (!)");
if(nCount)
mpPolyPolygon->insert(nIndex, rPolygon, nCount);
@@ -281,7 +285,7 @@ namespace basegfx
void B2DPolyPolygon::append(const B2DPolygon& rPolygon, sal_uInt32 nCount)
{
if(nCount)
- mpPolyPolygon->insert(std::as_const(*mpPolyPolygon).count(), rPolygon, nCount);
+ mpPolyPolygon->insert(std::as_const(mpPolyPolygon)->count(), rPolygon, nCount);
}
B2DPolyPolygon B2DPolyPolygon::getDefaultAdaptiveSubdivision() const
@@ -310,7 +314,7 @@ namespace basegfx
void B2DPolyPolygon::insert(sal_uInt32 nIndex, const B2DPolyPolygon& rPolyPolygon)
{
- OSL_ENSURE(nIndex <= std::as_const(*mpPolyPolygon).count(), "B2DPolyPolygon Insert outside range (!)");
+ OSL_ENSURE(nIndex <= std::as_const(mpPolyPolygon)->count(), "B2DPolyPolygon Insert outside range (!)");
if(rPolyPolygon.count())
mpPolyPolygon->insert(nIndex, rPolyPolygon);
@@ -319,12 +323,12 @@ namespace basegfx
void B2DPolyPolygon::append(const B2DPolyPolygon& rPolyPolygon)
{
if(rPolyPolygon.count())
- mpPolyPolygon->insert(std::as_const(*mpPolyPolygon).count(), rPolyPolygon);
+ mpPolyPolygon->insert(std::as_const(mpPolyPolygon)->count(), rPolyPolygon);
}
void B2DPolyPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount)
{
- OSL_ENSURE(nIndex + nCount <= std::as_const(*mpPolyPolygon).count(), "B2DPolyPolygon Remove outside range (!)");
+ OSL_ENSURE(nIndex + nCount <= std::as_const(mpPolyPolygon)->count(), "B2DPolyPolygon Remove outside range (!)");
if(nCount)
mpPolyPolygon->remove(nIndex, nCount);
@@ -360,7 +364,7 @@ namespace basegfx
void B2DPolyPolygon::flip()
{
- if(std::as_const(*mpPolyPolygon).count())
+ if(std::as_const(mpPolyPolygon)->count())
{
mpPolyPolygon->flip();
}
@@ -389,7 +393,7 @@ namespace basegfx
void B2DPolyPolygon::transform(const B2DHomMatrix& rMatrix)
{
- if(std::as_const(*mpPolyPolygon).count() && !rMatrix.isIdentity())
+ if(std::as_const(mpPolyPolygon)->count() && !rMatrix.isIdentity())
{
mpPolyPolygon->transform(rMatrix);
}
diff --git a/basegfx/source/polygon/b2dpolypolygoncutter.cxx b/basegfx/source/polygon/b2dpolypolygoncutter.cxx
index 9d3cd7b450df..ac1e10660607 100644
--- a/basegfx/source/polygon/b2dpolypolygoncutter.cxx
+++ b/basegfx/source/polygon/b2dpolypolygoncutter.cxx
@@ -1067,81 +1067,77 @@ namespace basegfx::utils
}
}
- B2DPolyPolygon mergeToSinglePolyPolygon(B2DPolyPolygonVector&& rInput)
+ B2DPolyPolygon mergeToSinglePolyPolygon(const B2DPolyPolygonVector& rInput)
{
- B2DPolyPolygonVector aInput(std::move(rInput));
+ if(rInput.empty())
+ return B2DPolyPolygon();
// first step: prepareForPolygonOperation and simple merge of non-overlapping
// PolyPolygons for speedup; this is possible for the wanted OR-operation
- if(!aInput.empty())
+ B2DPolyPolygonVector aResult;
+ aResult.reserve(rInput.size());
+
+ for(const basegfx::B2DPolyPolygon & a : rInput)
{
- B2DPolyPolygonVector aResult;
- aResult.reserve(aInput.size());
+ const basegfx::B2DPolyPolygon aCandidate(prepareForPolygonOperation(a));
- for(const basegfx::B2DPolyPolygon & a : aInput)
+ if(!aResult.empty())
{
- const basegfx::B2DPolyPolygon aCandidate(prepareForPolygonOperation(a));
+ const B2DRange aCandidateRange(aCandidate.getB2DRange());
+ bool bCouldMergeSimple(false);
- if(!aResult.empty())
+ for(auto & b: aResult)
{
- const B2DRange aCandidateRange(aCandidate.getB2DRange());
- bool bCouldMergeSimple(false);
-
- for(auto & b: aResult)
- {
- basegfx::B2DPolyPolygon aTarget(b);
- const B2DRange aTargetRange(aTarget.getB2DRange());
-
- if(!aCandidateRange.overlaps(aTargetRange))
- {
- aTarget.append(aCandidate);
- b = aTarget;
- bCouldMergeSimple = true;
- break;
- }
- }
+ basegfx::B2DPolyPolygon aTarget(b);
+ const B2DRange aTargetRange(aTarget.getB2DRange());
- if(!bCouldMergeSimple)
+ if(!aCandidateRange.overlaps(aTargetRange))
{
- aResult.push_back(aCandidate);
+ aTarget.append(aCandidate);
+ b = aTarget;
+ bCouldMergeSimple = true;
+ break;
}
}
- else
+
+ if(!bCouldMergeSimple)
{
aResult.push_back(aCandidate);
}
}
-
- aInput = aResult;
+ else
+ {
+ aResult.push_back(aCandidate);
+ }
}
// second step: melt pairwise to a single PolyPolygon
- while(aInput.size() > 1)
+ while(aResult.size() > 1)
{
- B2DPolyPolygonVector aResult;
- aResult.reserve((aInput.size() / 2) + 1);
+ B2DPolyPolygonVector aResult2;
+ aResult2.reserve((aResult.size() / 2) + 1);
- for(size_t a(0); a < aInput.size(); a += 2)
+ for(size_t a(0); a < aResult.size(); a += 2)
{
- if(a + 1 < aInput.size())
+ if(a + 1 < aResult.size())
{
// a pair for processing
- aResult.push_back(solvePolygonOperationOr(aInput[a], aInput[a + 1]));
+ aResult2.push_back(solvePolygonOperationOr(aResult[a], aResult[a + 1]));
}
else
{
// last single PolyPolygon; copy to target to not lose it
- aResult.push_back(aInput[a]);
+ aResult2.push_back(aResult[a]);
}
}
- aInput = aResult;
+ aResult = aResult2;
}
// third step: get result
- if(aInput.size() == 1)
+ if(aResult.size() == 1)
{
- return aInput[0];
+ return aResult[0];
}
return B2DPolyPolygon();
diff --git a/basegfx/source/polygon/b2dtrapezoid.cxx b/basegfx/source/polygon/b2dtrapezoid.cxx
index 12dbd66fdf9e..b7991dbf55d4 100644
--- a/basegfx/source/polygon/b2dtrapezoid.cxx
+++ b/basegfx/source/polygon/b2dtrapezoid.cxx
@@ -91,7 +91,7 @@ namespace basegfx::trapezoidhelper
// get radiant; has to be in the range ]0.0 .. pi[, thus scale to full
// sal_uInt32 range for maximum precision
- const double fRadiant(atan2(getDeltaY(), getDeltaX()) * (SAL_MAX_UINT32 / F_PI));
+ const double fRadiant(atan2(getDeltaY(), getDeltaX()) * (SAL_MAX_UINT32 / M_PI));
// convert to sal_uInt32 value
const_cast< TrDeEdgeEntry* >(this)->mnSortValue = sal_uInt32(fRadiant);
@@ -395,28 +395,26 @@ namespace basegfx::trapezoidhelper
aEdgeB.getStart(), aDeltaB,
CutFlagValue::LINE,
&fCutA,
- &fCutB) != CutFlagValue::NONE)
- {
- // use a simple metric (length criteria) for choosing the numerically
- // better cut
- const double fSimpleLengthA(aDeltaA.getX() + aDeltaA.getY());
- const double fSimpleLengthB(aDeltaB.getX() + aDeltaB.getY());
- const bool bAIsLonger(fSimpleLengthA > fSimpleLengthB);
- B2DPoint* pNewPoint = bAIsLonger
- ? maNewPoints.allocatePoint(aEdgeA.getStart() + (fCutA * aDeltaA))
- : maNewPoints.allocatePoint(aEdgeB.getStart() + (fCutB * aDeltaB));
-
- // try to split both edges
- bool bRetval = splitEdgeAtGivenPoint(aEdgeA, *pNewPoint, aCurrent);
- bRetval |= splitEdgeAtGivenPoint(aEdgeB, *pNewPoint, aCurrent);
-
- if(!bRetval)
- maNewPoints.freeIfLast(pNewPoint);
-
- return bRetval;
- }
+ &fCutB) == CutFlagValue::NONE)
+ return false;
+
+ // use a simple metric (length criteria) for choosing the numerically
+ // better cut
+ const double fSimpleLengthA(aDeltaA.getX() + aDeltaA.getY());
+ const double fSimpleLengthB(aDeltaB.getX() + aDeltaB.getY());
+ const bool bAIsLonger(fSimpleLengthA > fSimpleLengthB);
+ B2DPoint* pNewPoint = bAIsLonger
+ ? maNewPoints.allocatePoint(aEdgeA.getStart() + (fCutA * aDeltaA))
+ : maNewPoints.allocatePoint(aEdgeB.getStart() + (fCutB * aDeltaB));
+
+ // try to split both edges
+ bool bRetval = splitEdgeAtGivenPoint(aEdgeA, *pNewPoint, aCurrent);
+ bRetval |= splitEdgeAtGivenPoint(aEdgeB, *pNewPoint, aCurrent);
+
+ if(!bRetval)
+ maNewPoints.freeIfLast(pNewPoint);
- return false;
+ return bRetval;
}
void solveHorizontalEdges(TrDeSimpleEdges& rTrDeSimpleEdges)
diff --git a/basegfx/source/polygon/b3dpolygon.cxx b/basegfx/source/polygon/b3dpolygon.cxx
index dac943c79049..c1ee4b08345a 100644
--- a/basegfx/source/polygon/b3dpolygon.cxx
+++ b/basegfx/source/polygon/b3dpolygon.cxx
@@ -26,6 +26,7 @@
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <cassert>
#include <memory>
+#include <utility>
#include <vector>
#include <algorithm>
@@ -1431,7 +1432,7 @@ namespace basegfx
void B3DPolygon::setB3DPoint(sal_uInt32 nIndex, const basegfx::B3DPoint& rValue)
{
- OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B3DPolygon access outside range (!)");
+ OSL_ENSURE(nIndex < std::as_const(mpPolygon)->count(), "B3DPolygon access outside range (!)");
if(getB3DPoint(nIndex) != rValue)
mpPolygon->setPoint(nIndex, rValue);
@@ -1446,9 +1447,9 @@ namespace basegfx
void B3DPolygon::setBColor(sal_uInt32 nIndex, const BColor& rValue)
{
- OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B3DPolygon access outside range (!)");
+ OSL_ENSURE(nIndex < std::as_const(mpPolygon)->count(), "B3DPolygon access outside range (!)");
- if(std::as_const(*mpPolygon).getBColor(nIndex) != rValue)
+ if(std::as_const(mpPolygon)->getBColor(nIndex) != rValue)
mpPolygon->setBColor(nIndex, rValue);
}
@@ -1459,7 +1460,7 @@ namespace basegfx
void B3DPolygon::clearBColors()
{
- if(std::as_const(*mpPolygon).areBColorsUsed())
+ if(std::as_const(mpPolygon)->areBColorsUsed())
mpPolygon->clearBColors();
}
@@ -1477,15 +1478,15 @@ namespace basegfx
void B3DPolygon::setNormal(sal_uInt32 nIndex, const B3DVector& rValue)
{
- OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B3DPolygon access outside range (!)");
+ OSL_ENSURE(nIndex < std::as_const(mpPolygon)->count(), "B3DPolygon access outside range (!)");
- if(std::as_const(*mpPolygon).getNormal(nIndex) != rValue)
+ if(std::as_const(mpPolygon)->getNormal(nIndex) != rValue)
mpPolygon->setNormal(nIndex, rValue);
}
void B3DPolygon::transformNormals(const B3DHomMatrix& rMatrix)
{
- if(std::as_const(*mpPolygon).areNormalsUsed() && !rMatrix.isIdentity())
+ if(std::as_const(mpPolygon)->areNormalsUsed() && !rMatrix.isIdentity())
mpPolygon->transformNormals(rMatrix);
}
@@ -1496,7 +1497,7 @@ namespace basegfx
void B3DPolygon::clearNormals()
{
- if(std::as_const(*mpPolygon).areNormalsUsed())
+ if(std::as_const(mpPolygon)->areNormalsUsed())
mpPolygon->clearNormals();
}
@@ -1509,15 +1510,15 @@ namespace basegfx
void B3DPolygon::setTextureCoordinate(sal_uInt32 nIndex, const B2DPoint& rValue)
{
- OSL_ENSURE(nIndex < std::as_const(*mpPolygon).count(), "B3DPolygon access outside range (!)");
+ OSL_ENSURE(nIndex < std::as_const(mpPolygon)->count(), "B3DPolygon access outside range (!)");
- if(std::as_const(*mpPolygon).getTextureCoordinate(nIndex) != rValue)
+ if(std::as_const(mpPolygon)->getTextureCoordinate(nIndex) != rValue)
mpPolygon->setTextureCoordinate(nIndex, rValue);
}
void B3DPolygon::transformTextureCoordinates(const B2DHomMatrix& rMatrix)
{
- if(std::as_const(*mpPolygon).areTextureCoordinatesUsed() && !rMatrix.isIdentity())
+ if(std::as_const(mpPolygon)->areTextureCoordinatesUsed() && !rMatrix.isIdentity())
mpPolygon->transformTextureCoordinates(rMatrix);
}
@@ -1528,14 +1529,14 @@ namespace basegfx
void B3DPolygon::clearTextureCoordinates()
{
- if(std::as_const(*mpPolygon).areTextureCoordinatesUsed())
+ if(std::as_const(mpPolygon)->areTextureCoordinatesUsed())
mpPolygon->clearTextureCoordinates();
}
void B3DPolygon::append(const basegfx::B3DPoint& rPoint, sal_uInt32 nCount)
{
if(nCount)
- mpPolygon->insert(std::as_const(*mpPolygon).count(), rPoint, nCount);
+ mpPolygon->insert(std::as_const(mpPolygon)->count(), rPoint, nCount);
}
void B3DPolygon::append(const B3DPolygon& rPoly, sal_uInt32 nIndex, sal_uInt32 nCount)
@@ -1550,19 +1551,19 @@ namespace basegfx
if(nIndex == 0 && nCount == rPoly.count())
{
- mpPolygon->insert(std::as_const(*mpPolygon).count(), *rPoly.mpPolygon);
+ mpPolygon->insert(std::as_const(mpPolygon)->count(), *rPoly.mpPolygon);
}
else
{
OSL_ENSURE(nIndex + nCount <= rPoly.mpPolygon->count(), "B3DPolygon Append outside range (!)");
ImplB3DPolygon aTempPoly(*rPoly.mpPolygon, nIndex, nCount);
- mpPolygon->insert(std::as_const(*mpPolygon).count(), aTempPoly);
+ mpPolygon->insert(std::as_const(mpPolygon)->count(), aTempPoly);
}
}
void B3DPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount)
{
- OSL_ENSURE(nIndex + nCount <= std::as_const(*mpPolygon).count(), "B3DPolygon Remove outside range (!)");
+ OSL_ENSURE(nIndex + nCount <= std::as_const(mpPolygon)->count(), "B3DPolygon Remove outside range (!)");
if(nCount)
mpPolygon->remove(nIndex, nCount);
@@ -1606,7 +1607,7 @@ namespace basegfx
void B3DPolygon::transform(const basegfx::B3DHomMatrix& rMatrix)
{
- if(std::as_const(*mpPolygon).count() && !rMatrix.isIdentity())
+ if(std::as_const(mpPolygon)->count() && !rMatrix.isIdentity())
{
mpPolygon->transform(rMatrix);
}
diff --git a/basegfx/source/polygon/b3dpolygontools.cxx b/basegfx/source/polygon/b3dpolygontools.cxx
index 377b05802986..a1f65bef2f48 100644
--- a/basegfx/source/polygon/b3dpolygontools.cxx
+++ b/basegfx/source/polygon/b3dpolygontools.cxx
@@ -401,12 +401,12 @@ namespace basegfx::utils
// transitions which value to choose
const B3DRange aPlaneRange(getRange(rCandidate));
const B3DPoint aPlaneCenter(aPlaneRange.getCenter() - rCenter);
- const double fXCenter(fOne - ((atan2(aPlaneCenter.getZ(), aPlaneCenter.getX()) + F_PI) / F_2PI));
+ const double fXCenter(fOne - ((atan2(aPlaneCenter.getZ(), aPlaneCenter.getX()) + M_PI) / (2 * M_PI)));
for(a = 0; a < nPointCount; a++)
{
const B3DVector aVector(aRetval.getB3DPoint(a) - rCenter);
- const double fY(fOne - ((atan2(aVector.getY(), aVector.getXZLength()) + F_PI2) / F_PI));
+ const double fY(fOne - ((atan2(aVector.getY(), aVector.getXZLength()) + M_PI_2) / M_PI));
B2DPoint aTexCoor(aRetval.getTextureCoordinate(a));
if(fTools::equalZero(fY))
@@ -438,7 +438,7 @@ namespace basegfx::utils
}
else
{
- double fX(fOne - ((atan2(aVector.getZ(), aVector.getX()) + F_PI) / F_2PI));
+ double fX(fOne - ((atan2(aVector.getZ(), aVector.getX()) + M_PI) / (2 * M_PI)));
// correct cartesian point coordinate dependent from center value
if(fX > fXCenter + 0.5)
diff --git a/basegfx/source/polygon/b3dpolypolygon.cxx b/basegfx/source/polygon/b3dpolypolygon.cxx
index 4104d2fc29fe..017906eef5b8 100644
--- a/basegfx/source/polygon/b3dpolypolygon.cxx
+++ b/basegfx/source/polygon/b3dpolypolygon.cxx
@@ -22,6 +22,7 @@
#include <basegfx/polygon/b3dpolygon.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/matrix/b3dhommatrix.hxx>
+#include <utility>
#include <vector>
class ImplB3DPolyPolygon
@@ -241,7 +242,7 @@ namespace basegfx
void B3DPolyPolygon::setB3DPolygon(sal_uInt32 nIndex, const B3DPolygon& rPolygon)
{
- OSL_ENSURE(nIndex < std::as_const(*mpPolyPolygon).count(), "B3DPolyPolygon access outside range (!)");
+ OSL_ENSURE(nIndex < std::as_const(mpPolyPolygon)->count(), "B3DPolyPolygon access outside range (!)");
if(getB3DPolygon(nIndex) != rPolygon)
mpPolyPolygon->setB3DPolygon(nIndex, rPolygon);
@@ -319,18 +320,18 @@ namespace basegfx
void B3DPolyPolygon::append(const B3DPolygon& rPolygon, sal_uInt32 nCount)
{
if(nCount)
- mpPolyPolygon->insert(std::as_const(*mpPolyPolygon).count(), rPolygon, nCount);
+ mpPolyPolygon->insert(std::as_const(mpPolyPolygon)->count(), rPolygon, nCount);
}
void B3DPolyPolygon::append(const B3DPolyPolygon& rPolyPolygon)
{
if(rPolyPolygon.count())
- mpPolyPolygon->insert(std::as_const(*mpPolyPolygon).count(), rPolyPolygon);
+ mpPolyPolygon->insert(std::as_const(mpPolyPolygon)->count(), rPolyPolygon);
}
void B3DPolyPolygon::remove(sal_uInt32 nIndex, sal_uInt32 nCount)
{
- OSL_ENSURE(nIndex + nCount <= std::as_const(*mpPolyPolygon).count(), "B3DPolyPolygon Remove outside range (!)");
+ OSL_ENSURE(nIndex + nCount <= std::as_const(mpPolyPolygon)->count(), "B3DPolyPolygon Remove outside range (!)");
if(nCount)
mpPolyPolygon->remove(nIndex, nCount);
@@ -369,7 +370,7 @@ namespace basegfx
void B3DPolyPolygon::transform(const B3DHomMatrix& rMatrix)
{
- if(std::as_const(*mpPolyPolygon).count() && !rMatrix.isIdentity())
+ if(std::as_const(mpPolyPolygon)->count() && !rMatrix.isIdentity())
{
mpPolyPolygon->transform(rMatrix);
}
diff --git a/basegfx/source/polygon/b3dpolypolygontools.cxx b/basegfx/source/polygon/b3dpolypolygontools.cxx
index ad2dd5bb7979..62ddd3ae771f 100644
--- a/basegfx/source/polygon/b3dpolypolygontools.cxx
+++ b/basegfx/source/polygon/b3dpolypolygontools.cxx
@@ -200,7 +200,7 @@ namespace basegfx::utils
}
// helper for getting the 3D Point from given cartesian coordinates. fHor is defined from
- // [F_PI2 .. -F_PI2], fVer from [0.0 .. F_2PI]
+ // [M_PI_2 .. -M_PI_2], fVer from [0.0 .. 2PI]
static B3DPoint getPointFromCartesian(double fHor, double fVer)
{
const double fCosVer(cos(fVer));
@@ -217,7 +217,7 @@ namespace basegfx::utils
if(!nHorSeg)
{
- nHorSeg = fround(fabs(fHorStop - fHorStart) / (F_2PI / 24.0));
+ nHorSeg = fround(fabs(fHorStop - fHorStart) / (M_PI / 12.0));
}
// min/max limitations
@@ -225,7 +225,7 @@ namespace basegfx::utils
if(!nVerSeg)
{
- nVerSeg = fround(fabs(fVerStop - fVerStart) / (F_2PI / 24.0));
+ nVerSeg = fround(fabs(fVerStop - fVerStart) / (M_PI / 12.0));
}
// min/max limitations
@@ -234,9 +234,9 @@ namespace basegfx::utils
// create constants
const double fVerDiffPerStep((fVerStop - fVerStart) / static_cast<double>(nVerSeg));
const double fHorDiffPerStep((fHorStop - fHorStart) / static_cast<double>(nHorSeg));
- bool bHorClosed(fTools::equal(fHorStop - fHorStart, F_2PI));
- bool bVerFromTop(fTools::equal(fVerStart, F_PI2));
- bool bVerToBottom(fTools::equal(fVerStop, -F_PI2));
+ bool bHorClosed(fTools::equal(fHorStop - fHorStart, 2 * M_PI));
+ bool bVerFromTop(fTools::equal(fVerStart, M_PI_2));
+ bool bVerToBottom(fTools::equal(fVerStop, -M_PI_2));
// create horizontal rings
const sal_uInt32 nLoopVerInit(bVerFromTop ? 1 : 0);
@@ -316,7 +316,7 @@ namespace basegfx::utils
if(!nHorSeg)
{
- nHorSeg = fround(fabs(fHorStop - fHorStart) / (F_2PI / 24.0));
+ nHorSeg = fround(fabs(fHorStop - fHorStart) / (M_PI / 12.0));
}
// min/max limitations
@@ -324,7 +324,7 @@ namespace basegfx::utils
if(!nVerSeg)
{
- nVerSeg = fround(fabs(fVerStop - fVerStart) / (F_2PI / 24.0));
+ nVerSeg = fround(fabs(fVerStop - fVerStart) / (M_PI / 12.0));
}
// min/max limitations
diff --git a/basegfx/source/range/b2drangeclipper.cxx b/basegfx/source/range/b2drangeclipper.cxx
index d371011f0361..401ff20caa1d 100644
--- a/basegfx/source/range/b2drangeclipper.cxx
+++ b/basegfx/source/range/b2drangeclipper.cxx
@@ -19,7 +19,6 @@
#include <osl/diagnose.h>
-#include <basegfx/tuple/b2dtuple.hxx>
#include <basegfx/range/b2drange.hxx>
#include <basegfx/range/b2drangeclipper.hxx>
#include <basegfx/polygon/b2dpolypolygon.hxx>
diff --git a/basegfx/source/tools/unopolypolygon.cxx b/basegfx/source/tools/unopolypolygon.cxx
index 0d1696783c9f..48b3372d5526 100644
--- a/basegfx/source/tools/unopolypolygon.cxx
+++ b/basegfx/source/tools/unopolypolygon.cxx
@@ -34,7 +34,6 @@ using namespace ::com::sun::star;
namespace basegfx::unotools
{
UnoPolyPolygon::UnoPolyPolygon( const B2DPolyPolygon& rPolyPoly ) :
- UnoPolyPolygonBase( m_aMutex ),
maPolyPoly( rPolyPoly ),
meFillRule( rendering::FillRule_EVEN_ODD )
{
@@ -46,7 +45,7 @@ namespace basegfx::unotools
const geometry::RealPoint2D& position,
const uno::Reference< rendering::XPolyPolygon2D >& polyPolygon )
{
- osl::MutexGuard const guard( m_aMutex );
+ std::unique_lock const guard( m_aMutex );
modifying();
// TODO(F1): Correctly fulfill the UNO API
@@ -124,14 +123,14 @@ namespace basegfx::unotools
sal_Int32 SAL_CALL UnoPolyPolygon::getNumberOfPolygons()
{
- osl::MutexGuard const guard( m_aMutex );
+ std::unique_lock const guard( m_aMutex );
return maPolyPoly.count();
}
sal_Int32 SAL_CALL UnoPolyPolygon::getNumberOfPolygonPoints(
sal_Int32 polygon )
{
- osl::MutexGuard const guard( m_aMutex );
+ std::unique_lock const guard( m_aMutex );
checkIndex( polygon );
return maPolyPoly.getB2DPolygon(polygon).count();
@@ -139,14 +138,14 @@ namespace basegfx::unotools
rendering::FillRule SAL_CALL UnoPolyPolygon::getFillRule()
{
- osl::MutexGuard const guard( m_aMutex );
+ std::unique_lock const guard( m_aMutex );
return meFillRule;
}
void SAL_CALL UnoPolyPolygon::setFillRule(
rendering::FillRule fillRule )
{
- osl::MutexGuard const guard( m_aMutex );
+ std::unique_lock const guard( m_aMutex );
modifying();
meFillRule = fillRule;
@@ -155,7 +154,7 @@ namespace basegfx::unotools
sal_Bool SAL_CALL UnoPolyPolygon::isClosed(
sal_Int32 index )
{
- osl::MutexGuard const guard( m_aMutex );
+ std::unique_lock const guard( m_aMutex );
checkIndex( index );
return maPolyPoly.getB2DPolygon(index).isClosed();
@@ -165,7 +164,7 @@ namespace basegfx::unotools
sal_Int32 index,
sal_Bool closedState )
{
- osl::MutexGuard const guard( m_aMutex );
+ std::unique_lock const guard( m_aMutex );
modifying();
if( index == -1 )
@@ -192,8 +191,6 @@ namespace basegfx::unotools
sal_Int32 nPointIndex,
sal_Int32 nNumberOfPoints )
{
- osl::MutexGuard const guard( m_aMutex );
-
return unotools::pointSequenceSequenceFromB2DPolyPolygon(
getSubsetPolyPolygon( nPolygonIndex,
nNumberOfPolygons,
@@ -205,7 +202,7 @@ namespace basegfx::unotools
const uno::Sequence< uno::Sequence< geometry::RealPoint2D > >& points,
sal_Int32 nPolygonIndex )
{
- osl::MutexGuard const guard( m_aMutex );
+ std::unique_lock const guard( m_aMutex );
modifying();
const B2DPolyPolygon& rNewPolyPoly(
@@ -227,7 +224,7 @@ namespace basegfx::unotools
sal_Int32 nPolygonIndex,
sal_Int32 nPointIndex )
{
- osl::MutexGuard const guard( m_aMutex );
+ std::unique_lock const guard( m_aMutex );
checkIndex( nPolygonIndex );
const B2DPolygon& rPoly( maPolyPoly.getB2DPolygon( nPolygonIndex ) );
@@ -243,7 +240,7 @@ namespace basegfx::unotools
sal_Int32 nPolygonIndex,
sal_Int32 nPointIndex )
{
- osl::MutexGuard const guard( m_aMutex );
+ std::unique_lock const guard( m_aMutex );
checkIndex( nPolygonIndex );
modifying();
@@ -263,7 +260,6 @@ namespace basegfx::unotools
sal_Int32 nPointIndex,
sal_Int32 nNumberOfPoints )
{
- osl::MutexGuard const guard( m_aMutex );
return unotools::bezierSequenceSequenceFromB2DPolyPolygon(
getSubsetPolyPolygon( nPolygonIndex,
nNumberOfPolygons,
@@ -275,7 +271,7 @@ namespace basegfx::unotools
const uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > >& points,
sal_Int32 nPolygonIndex )
{
- osl::MutexGuard const guard( m_aMutex );
+ std::unique_lock const guard( m_aMutex );
modifying();
const B2DPolyPolygon& rNewPolyPoly(
unotools::polyPolygonFromBezier2DSequenceSequence( points ) );
@@ -295,7 +291,7 @@ namespace basegfx::unotools
geometry::RealBezierSegment2D SAL_CALL UnoPolyPolygon::getBezierSegment( sal_Int32 nPolygonIndex,
sal_Int32 nPointIndex )
{
- osl::MutexGuard const guard( m_aMutex );
+ std::unique_lock const guard( m_aMutex );
checkIndex( nPolygonIndex );
const B2DPolygon& rPoly( maPolyPoly.getB2DPolygon( nPolygonIndex ) );
@@ -320,7 +316,7 @@ namespace basegfx::unotools
sal_Int32 nPolygonIndex,
sal_Int32 nPointIndex )
{
- osl::MutexGuard const guard( m_aMutex );
+ std::unique_lock const guard( m_aMutex );
checkIndex( nPolygonIndex );
modifying();
@@ -347,7 +343,7 @@ namespace basegfx::unotools
sal_Int32 nPointIndex,
sal_Int32 nNumberOfPoints ) const
{
- osl::MutexGuard const guard( m_aMutex );
+ std::unique_lock const guard( m_aMutex );
checkIndex( nPolygonIndex );
const sal_Int32 nPolyCount( maPolyPoly.count() );
@@ -441,7 +437,7 @@ namespace basegfx::unotools
B2DPolyPolygon UnoPolyPolygon::getPolyPolygon() const
{
- osl::MutexGuard const guard( m_aMutex );
+ std::unique_lock const guard( m_aMutex );
// detach result from us
B2DPolyPolygon aRet( maPolyPoly );
diff --git a/basegfx/source/workbench/bezierclip.hxx b/basegfx/source/workbench/bezierclip.hxx
index 36d2f89a893f..54cceb414f33 100644
--- a/basegfx/source/workbench/bezierclip.hxx
+++ b/basegfx/source/workbench/bezierclip.hxx
@@ -73,7 +73,7 @@ template <typename NumType> NumType absval( NumType x )
Polygon2D convexHull( const Polygon2D& rPoly );
// TODO: find proper epsilon here (try std::numeric_limits<NumType>::epsilon()?)!
-#define DBL_EPSILON 1.0e-100
+constexpr auto DBL_EPSILON = 1.0e-100;
/* little approximate comparisons */
template <typename NumType> bool tolZero( NumType n ) { return fabs(n) < DBL_EPSILON; }
diff --git a/basegfx/test/B2DHomMatrixTest.cxx b/basegfx/test/B2DHomMatrixTest.cxx
index 04201ca19c0c..bd6b1f8c8029 100644
--- a/basegfx/test/B2DHomMatrixTest.cxx
+++ b/basegfx/test/B2DHomMatrixTest.cxx
@@ -159,7 +159,7 @@ public:
void rotate()
{
B2DHomMatrix mat;
- mat.rotate(F_PI2);
+ mat.rotate(M_PI_2);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("rotate pi/2 yields exact matrix", 0.0, mat.get(0, 0),
1E-12);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("rotate pi/2 yields exact matrix", -1.0, mat.get(0, 1),
@@ -172,7 +172,7 @@ public:
1E-12);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("rotate pi/2 yields exact matrix", 0.0, mat.get(1, 2),
1E-12);
- mat.rotate(F_PI2);
+ mat.rotate(M_PI_2);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("rotate pi yields exact matrix", -1.0, mat.get(0, 0),
1E-12);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("rotate pi yields exact matrix", 0.0, mat.get(0, 1),
@@ -185,7 +185,7 @@ public:
1E-12);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("rotate pi yields exact matrix", 0.0, mat.get(1, 2),
1E-12);
- mat.rotate(F_PI2);
+ mat.rotate(M_PI_2);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("rotate 3/2 pi yields exact matrix", 0.0,
mat.get(0, 0), 1E-12);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("rotate 3/2 pi yields exact matrix", 1.0,
@@ -198,7 +198,7 @@ public:
mat.get(1, 1), 1E-12);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("rotate 3/2 pi yields exact matrix", 0.0,
mat.get(1, 2), 1E-12);
- mat.rotate(F_PI2);
+ mat.rotate(M_PI_2);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("rotate 2 pi yields exact matrix", 1.0, mat.get(0, 0),
1E-12);
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("rotate 2 pi yields exact matrix", 0.0, mat.get(0, 1),
@@ -334,7 +334,7 @@ public:
// are just the two rightmost values and uncritical
static const double fSX(10.0);
static const double fSY(12.0);
- static const double fR(F_PI4);
+ static const double fR(M_PI_4);
static const double fS(deg2rad(15.0));
// check all possible scaling combinations
@@ -429,7 +429,7 @@ public:
// cover special case of 180 degree rotation
B2DHomMatrix aTest
- = utils::createScaleShearXRotateTranslateB2DHomMatrix(6425, 3938, 0, F_PI, 10482, 4921);
+ = utils::createScaleShearXRotateTranslateB2DHomMatrix(6425, 3938, 0, M_PI, 10482, 4921);
// decompose that matrix
B2DTuple aDScale;
B2DTuple aDTrans;
@@ -442,7 +442,7 @@ public:
1E-12);
CPPUNIT_ASSERT_EQUAL_MESSAGE("decompose: error test J1", 10482.0, aDTrans.getX());
CPPUNIT_ASSERT_EQUAL_MESSAGE("decompose: error test J1", 4921.0, aDTrans.getY());
- CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("decompose: error test J1", F_PI, fDRot, 1E-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("decompose: error test J1", M_PI, fDRot, 1E-12);
}
void testCreate_abcdef()