diff options
Diffstat (limited to 'basegfx/source/polygon/b3dpolygontools.cxx')
-rw-r--r-- | basegfx/source/polygon/b3dpolygontools.cxx | 42 |
1 files changed, 16 insertions, 26 deletions
diff --git a/basegfx/source/polygon/b3dpolygontools.cxx b/basegfx/source/polygon/b3dpolygontools.cxx index 19f885b2e826..968624e0f28b 100644 --- a/basegfx/source/polygon/b3dpolygontools.cxx +++ b/basegfx/source/polygon/b3dpolygontools.cxx @@ -173,25 +173,22 @@ namespace basegfx::utils void applyLineDashing( const B3DPolygon& rCandidate, const std::vector<double>& rDotDashArray, - std::function<void(const basegfx::B3DPolygon& rSnippet)> aLineTargetCallback, + const std::function<void(const basegfx::B3DPolygon& rSnippet)>& rLineTargetCallback, double fDotDashLength) { const sal_uInt32 nPointCount(rCandidate.count()); const sal_uInt32 nDotDashCount(rDotDashArray.size()); - if(fTools::lessOrEqual(fDotDashLength, 0.0)) + if(fDotDashLength <= 0.0) { fDotDashLength = std::accumulate(rDotDashArray.begin(), rDotDashArray.end(), 0.0); } - if(fTools::lessOrEqual(fDotDashLength, 0.0) || !aLineTargetCallback || !nPointCount) + if(fDotDashLength <= 0.0 || !rLineTargetCallback || !nPointCount) { // parameters make no sense, just add source to targets - if(aLineTargetCallback) - { - aLineTargetCallback(rCandidate); - } - + if (rLineTargetCallback) + rLineTargetCallback(rCandidate); return; } @@ -199,7 +196,7 @@ namespace basegfx::utils // we want to create a maximum of fNumberOfAllowedSnippets. In 3D // use less for fNumberOfAllowedSnippets, ca. 6553.6, double due to line & gap. // Less in 3D due to potentially blowing up to rounded line segments. - static double fNumberOfAllowedSnippets(6553.5 * 2.0); + static const double fNumberOfAllowedSnippets(6553.5 * 2.0); const double fAllowedLength((fNumberOfAllowedSnippets * fDotDashLength) / double(rDotDashArray.size())); const double fCandidateLength(basegfx::utils::getLength(rCandidate)); std::vector<double> aDotDashArray(rDotDashArray); @@ -219,7 +216,6 @@ namespace basegfx::utils // to enlarge these as needed const double fFactor(fCandidateLength / fAllowedLength); std::for_each(aDotDashArray.begin(), aDotDashArray.end(), [&fFactor](double &f){ f *= fFactor; }); - fDotDashLength *= fFactor; } // prepare current edge's start @@ -251,9 +247,7 @@ namespace basegfx::utils while(fTools::less(fDotDashMovingLength, fEdgeLength)) { // new split is inside edge, create and append snippet [fLastDotDashMovingLength, fDotDashMovingLength] - const bool bHandleLine(bIsLine && aLineTargetCallback); - - if(bHandleLine) + if(bIsLine) { if(!aSnippet.count()) { @@ -262,7 +256,7 @@ namespace basegfx::utils aSnippet.append(interpolate(aCurrentPoint, aNextPoint, fDotDashMovingLength / fEdgeLength)); - implHandleSnippet(aSnippet, aLineTargetCallback, aFirstLine, aLastLine); + implHandleSnippet(aSnippet, rLineTargetCallback, aFirstLine, aLastLine); aSnippet.clear(); } @@ -274,9 +268,7 @@ namespace basegfx::utils } // append snippet [fLastDotDashMovingLength, fEdgeLength] - const bool bHandleLine(bIsLine && aLineTargetCallback); - - if(bHandleLine) + if(bIsLine) { if(!aSnippet.count()) { @@ -297,17 +289,15 @@ namespace basegfx::utils // append last intermediate results (if exists) if(aSnippet.count()) { - const bool bHandleLine(bIsLine && aLineTargetCallback); - - if(bHandleLine) + if(bIsLine) { - implHandleSnippet(aSnippet, aLineTargetCallback, aFirstLine, aLastLine); + implHandleSnippet(aSnippet, rLineTargetCallback, aFirstLine, aLastLine); } } - if(bIsClosed && aLineTargetCallback) + if(bIsClosed) { - implHandleFirstLast(aLineTargetCallback, aFirstLine, aLastLine); + implHandleFirstLast(rLineTargetCallback, aFirstLine, aLastLine); } } @@ -407,12 +397,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)) @@ -444,7 +434,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) |