20#include <osl/diagnose.h>
36 while(rCandidate.
count() > 1
46 OSL_ENSURE(
nIndex < rCandidate.
count(),
"getIndexOfPredecessor: Access to polygon out of range (!)");
61 const sal_uInt32 nPointCount(rCandidate.
count());
63 for(sal_uInt32
a(0);
a < nPointCount;
a++)
66 aRetval.
expand(aTestPoint);
75 const sal_uInt32 nPointCount(rCandidate.
count());
79 const sal_uInt32 nLoopCount(rCandidate.
isClosed() ? nPointCount : nPointCount - 1);
81 for(sal_uInt32
a(0);
a < nLoopCount;
a++)
86 const B3DVector aVector(aNextPoint - aCurrentPoint);
96 const std::vector<double>& rDotDashArray,
98 double fDotDashLength)
103 pLineTarget->
clear();
108 nullptr == pLineTarget
136 rTargetCallback(rLast);
144 rTargetCallback(rSnippet);
164 rTargetCallback(rLast);
169 rTargetCallback(rFirst);
175 const std::vector<double>& rDotDashArray,
177 double fDotDashLength)
179 const sal_uInt32 nPointCount(rCandidate.
count());
180 const sal_uInt32 nDotDashCount(rDotDashArray.size());
184 fDotDashLength = std::accumulate(rDotDashArray.begin(), rDotDashArray.end(), 0.0);
190 if(aLineTargetCallback)
192 aLineTargetCallback(rCandidate);
202 static const double fNumberOfAllowedSnippets(6553.5 * 2.0);
203 const double fAllowedLength((fNumberOfAllowedSnippets * fDotDashLength) /
double(rDotDashArray.size()));
205 std::vector<double> aDotDashArray(rDotDashArray);
207 if(fCandidateLength > fAllowedLength)
216 assert(
true &&
"applyLineDashing: potentially too expensive to do the requested dismantle - please consider stretched LineDash pattern (!)");
220 const double fFactor(fCandidateLength / fAllowedLength);
221 std::for_each(aDotDashArray.begin(), aDotDashArray.end(), [&fFactor](
double &f){ f *= fFactor; });
226 const bool bIsClosed(rCandidate.
isClosed());
227 const sal_uInt32 nEdgeCount(bIsClosed ? nPointCount : nPointCount - 1);
230 sal_uInt32 nDotDashIndex(0);
232 double fDotDashMovingLength(aDotDashArray[0]);
240 for(sal_uInt32
a(0);
a < nEdgeCount;
a++)
243 const sal_uInt32 nNextIndex((
a + 1) % nPointCount);
249 double fLastDotDashMovingLength(0.0);
255 if(!aSnippet.
count())
257 aSnippet.
append(
interpolate(aCurrentPoint, aNextPoint, fLastDotDashMovingLength / fEdgeLength));
260 aSnippet.
append(
interpolate(aCurrentPoint, aNextPoint, fDotDashMovingLength / fEdgeLength));
268 fLastDotDashMovingLength = fDotDashMovingLength;
269 fDotDashMovingLength += aDotDashArray[(++nDotDashIndex) % nDotDashCount];
276 if(!aSnippet.
count())
278 aSnippet.
append(
interpolate(aCurrentPoint, aNextPoint, fLastDotDashMovingLength / fEdgeLength));
281 aSnippet.
append(aNextPoint);
285 fDotDashMovingLength -= fEdgeLength;
289 aCurrentPoint = aNextPoint;
311 for(sal_uInt32
a(0);
a < aRetval.
count();
a++)
327 for(sal_uInt32
a(0);
a < aRetval.
count();
a++)
340 if(bChangeX || bChangeY)
344 const double fWidth(rRange.
getWidth());
345 const double fHeight(rRange.
getHeight());
348 const double fOne(1.0);
350 for(sal_uInt32
a(0);
a < aRetval.
count();
a++)
363 aTextureCoordinate.
setX(0.0);
371 aTextureCoordinate.
setY(fOne - ((aPoint.
getY() - rRange.
getMinY()) / fHeight));
375 aTextureCoordinate.
setY(fOne);
390 if(bChangeX || bChangeY)
394 const double fOne(1.0);
395 const sal_uInt32 nPointCount(aRetval.
count());
396 bool bPolarPoints(
false);
403 const double fXCenter(fOne - ((atan2(aPlaneCenter.
getZ(), aPlaneCenter.
getX()) + M_PI) / (2 * M_PI)));
405 for(
a = 0;
a < nPointCount;
a++)
408 const double fY(fOne - ((atan2(aVector.
getY(), aVector.
getXZLength()) + M_PI_2) / M_PI));
440 double fX(fOne - ((atan2(aVector.
getZ(), aVector.
getX()) + M_PI) / (2 * M_PI)));
443 if(fX > fXCenter + 0.5)
447 else if(fX < fXCenter - 0.5)
470 for(
a = 0;
a < nPointCount;
a++)
482 if(!bPrevPole && !bNextPole)
485 aTexCoor.
setX((aPrevTexCoor.
getX() + aNextTexCoor.
getX()) / 2.0);
520 const sal_uInt32 nPointCount(rCandidate.
count());
525 const double fAbsX(fabs(aPlaneNormal.
getX()));
526 const double fAbsY(fabs(aPlaneNormal.
getY()));
527 const double fAbsZ(fabs(aPlaneNormal.
getZ()));
529 if(fAbsX > fAbsY && fAbsX > fAbsZ)
533 for(sal_uInt32
a(0);
a < nPointCount;
a++)
535 const B3DPoint aPreviousPoint(aCurrentPoint);
542 if(bCompZA != bCompZB)
548 if(bCompYA == bCompYB)
557 const double fCompare(
558 aCurrentPoint.
getY() - (aCurrentPoint.
getZ() - rPoint.
getZ()) *
559 (aPreviousPoint.
getY() - aCurrentPoint.
getY()) /
560 (aPreviousPoint.
getZ() - aCurrentPoint.
getZ()));
570 else if(fAbsY > fAbsX && fAbsY > fAbsZ)
574 for(sal_uInt32
a(0);
a < nPointCount;
a++)
576 const B3DPoint aPreviousPoint(aCurrentPoint);
583 if(bCompZA != bCompZB)
589 if(bCompXA == bCompXB)
598 const double fCompare(
599 aCurrentPoint.
getX() - (aCurrentPoint.
getZ() - rPoint.
getZ()) *
600 (aPreviousPoint.
getX() - aCurrentPoint.
getX()) /
601 (aPreviousPoint.
getZ() - aCurrentPoint.
getZ()));
615 for(sal_uInt32
a(0);
a < nPointCount;
a++)
617 const B3DPoint aPreviousPoint(aCurrentPoint);
624 if(bCompYA != bCompYB)
630 if(bCompXA == bCompXB)
639 const double fCompare(
640 aCurrentPoint.
getX() - (aCurrentPoint.
getY() - rPoint.
getY()) *
641 (aPreviousPoint.
getX() - aCurrentPoint.
getX()) /
642 (aPreviousPoint.
getY() - aCurrentPoint.
getY()));
661 if(rCandidate.
equal(rStart) || rCandidate.
equal(rEnd))
666 else if(rStart.
equal(rEnd))
673 const B3DVector aEdgeVector(rEnd - rStart);
674 const B3DVector aTestVector(rCandidate - rStart);
678 double fParamTestOnCurr(0.0);
680 if(aEdgeVector.
getX() > aEdgeVector.
getY())
682 if(aEdgeVector.
getX() > aEdgeVector.
getZ())
685 fParamTestOnCurr = aTestVector.
getX() / aEdgeVector.
getX();
690 fParamTestOnCurr = aTestVector.
getZ() / aEdgeVector.
getZ();
695 if(aEdgeVector.
getY() > aEdgeVector.
getZ())
698 fParamTestOnCurr = aTestVector.
getY() / aEdgeVector.
getY();
703 fParamTestOnCurr = aTestVector.
getZ() / aEdgeVector.
getZ();
719 const sal_uInt32 nPointCount(rCandidate.
count());
723 const sal_uInt32 nLoopCount(rCandidate.
isClosed() ? nPointCount : nPointCount - 1);
726 for(sal_uInt32
a(0);
a < nLoopCount;
a++)
735 aCurrentPoint = aNextPoint;
750 const B3DVector aTestEdge(rEdgeEnd - rEdgeStart);
751 const double fScalarEdge(rPlaneNormal.
scalar(aTestEdge));
755 const B3DVector aCompareEdge(rPlanePoint - rEdgeStart);
756 const double fScalarCompare(rPlaneNormal.
scalar(aCompareEdge));
758 fCut = fScalarCompare / fScalarEdge;
769 const sal_uInt32 nPointCount(rCandidate.
count());
784 for(sal_uInt32
a(0);
a < nPointCount;
a++)
787 const bool bLastRun(
a + 1 == nPointCount);
788 const sal_uInt32 nNextIndex(bLastRun ? 0 :
a + 1);
793 const bool bPrevVertical(aPrevTuple.
getX() == aCurrTuple.
getX());
794 const bool bNextVertical(aNextTuple.
getX() == aCurrTuple.
getX());
795 const bool bPrevHorizontal(aPrevTuple.
getY() == aCurrTuple.
getY());
796 const bool bNextHorizontal(aNextTuple.
getY() == aCurrTuple.
getY());
797 const bool bSnapX(bPrevVertical || bNextVertical);
798 const bool bSnapY(bPrevHorizontal || bNextHorizontal);
803 bSnapX ? aCurrTuple.
getX() : aCurrPoint.
getX(),
804 bSnapY ? aCurrTuple.
getY() : aCurrPoint.
getY(),
813 aPrevTuple = aCurrTuple;
814 aCurrPoint = aNextPoint;
815 aCurrTuple = aNextTuple;
Base Point class with two double values.
Base Point class with three double values.
void append(const B3DPolygon &rPolygon, sal_uInt32 nCount=1)
void remove(sal_uInt32 nIndex, sal_uInt32 nCount=1)
void append(const B3DPoint &rPoint, sal_uInt32 nCount=1)
void setB3DPoint(sal_uInt32 nIndex, const B3DPoint &rValue)
void setTextureCoordinate(sal_uInt32 nIndex, const B2DPoint &rValue)
B3DPoint const & getB3DPoint(sal_uInt32 nIndex) const
bool areNormalsUsed() const
void setNormal(sal_uInt32 nIndex, const B3DVector &rValue)
B3DVector const & getNormal() const
void setClosed(bool bNew)
void removeDoublePoints()
B2DPoint const & getTextureCoordinate(sal_uInt32 nIndex) const
void expand(const B3DTuple &rTuple)
B3DPoint getCenter() const
bool equal(const B3DTuple &rTup) const
Base Point class with three double values.
double getLength() const
Calculate the length of this 3D Vector.
double getXZLength() const
Calculate the length in the XZ-Plane for this 3D Vector.
B3DVector & normalize()
Normalize this 3D Vector.
double scalar(const B3DVector &rVec) const
Calculate the Scalar product.
Base class for all Points/Vectors with three sal_Int32 values.
TYPE getX() const
Get X-Coordinate of 2D Tuple.
void setY(TYPE fY)
Set Y-Coordinate of 2D Tuple.
TYPE getY() const
Get Y-Coordinate of 2D Tuple.
void setX(TYPE fX)
Set X-Coordinate of 2D Tuple.
TYPE getX() const
Get X-Coordinate of 3D Tuple.
TYPE getZ() const
Get Z-Coordinate of 3D Tuple.
TYPE getY() const
Get Y-Coordinate of 3D Tuple.
bool isPointOnLine(const B2DPoint &rStart, const B2DPoint &rEnd, const B2DPoint &rCandidate, bool bWithPoints)
static void implHandleSnippet(const B2DPolygon &rSnippet, const std::function< void(const basegfx::B2DPolygon &rSnippet)> &rTargetCallback, B2DPolygon &rFirst, B2DPolygon &rLast)
B3DPolygon applyDefaultTextureCoordinatesSphere(const B3DPolygon &rCandidate, const B3DPoint &rCenter, bool bChangeX, bool bChangeY)
Create/replace texture coordinates for given 3d geometry with spherical one rCenter: the centre of th...
double getLength(const B2DPolygon &rCandidate)
get length of polygon
B2DPolygon interpolate(const B2DPolygon &rOld1, const B2DPolygon &rOld2, double t)
bool getCutBetweenLineAndPlane(const B3DVector &rPlaneNormal, const B3DPoint &rPlanePoint, const B3DPoint &rEdgeStart, const B3DPoint &rEdgeEnd, double &fCut)
void applyLineDashing(const B2DPolygon &rCandidate, const std::vector< double > &rDotDashArray, B2DPolyPolygon *pLineTarget, B2DPolyPolygon *pGapTarget, double fDotDashLength)
sal_uInt32 getIndexOfSuccessor(sal_uInt32 nIndex, const B2DPolygon &rCandidate)
bool isInside(const B2DPolygon &rCandidate, const B2DPoint &rPoint, bool bWithBorder)
B3DPolygon applyDefaultNormalsSphere(const B3DPolygon &rCandidate, const B3DPoint &rCenter)
Create/replace normals for given 3d geometry with default normals from given center to outside.
B2DPolygon snapPointsOfHorizontalOrVerticalEdges(const B2DPolygon &rCandidate)
snap some polygon coordinates to discrete coordinates
bool isPointOnPolygon(const B2DPolygon &rCandidate, const B2DPoint &rPoint, bool bWithPoints)
B3DPolygon invertNormals(const B3DPolygon &rCandidate)
invert normals for given 3d geometry.
B3DPolygon applyDefaultTextureCoordinatesParallel(const B3DPolygon &rCandidate, const B3DRange &rRange, bool bChangeX, bool bChangeY)
Create/replace texture coordinates for given 3d geometry with parallel projected one rRange: the full...
static void implHandleFirstLast(const std::function< void(const basegfx::B2DPolygon &rSnippet)> &rTargetCallback, B2DPolygon &rFirst, B2DPolygon &rLast)
void checkClosed(B2DPolygon &rCandidate)
Check if given polygon is closed.
B2DRange getRange(const B2DPolygon &rCandidate)
Get the range of a polygon.
bool areParallel(const B2DVector &rVecA, const B2DVector &rVecB)
Test two vectors which need not to be normalized for parallelism.
B2IRange fround(const B2DRange &rRange)
Round double to nearest integer for 2D range.