21#include <osl/diagnose.h>
22#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
27#include <rtl/math.hxx>
45 for(sal_uInt32 b(0); b <
nCount; b++)
58 const bool bShallBeHole((nDepth & 0x00000001) == 1);
83 for(sal_uInt32 b(0); b <
nCount; b++)
122 for(
auto const& rPolygon : rCandidate)
124 if(rPolygon.areControlPointsUsed())
148 for(
auto const& rPolygon : rCandidate)
150 if(rPolygon.areControlPointsUsed())
170 if(rCandidate.
count() == 1)
176 sal_Int32 nInsideCount = std::count_if(rCandidate.
begin(), rCandidate.
end(), [rPoint, bWithBorder](
B2DPolygon polygon){ return isInside(polygon, rPoint, bWithBorder); });
178 return (nInsideCount % 2);
186 for(
auto const& rPolygon : rCandidate)
198 for(
auto const& rPolygon : rCandidate)
213 if(fFullDashDotLen == 0.0 && !rDotDashArray.empty())
216 fFullDashDotLen = std::accumulate(rDotDashArray.begin(), rDotDashArray.end(), 0.0);
219 if(!(rCandidate.
count() && fFullDashDotLen > 0.0))
224 for(
auto const& rPolygon : rCandidate)
229 pLineTarget ? &aLineTarget :
nullptr,
235 pLineTarget->
append(aLineTarget);
242 for(
auto const& rPolygon : rCandidate)
257 for(
auto const& rPolygon : rCandidate)
269 for(
auto const& rPolygon : rCandidate)
279 double fRetval(DBL_MAX);
280 const double fZero(0.0);
281 const sal_uInt32 nPolygonCount(rCandidate.
count());
283 for(sal_uInt32
a(0);
a < nPolygonCount;
a++)
286 sal_uInt32 nNewEdgeIndex;
290 if(fRetval == DBL_MAX || fNewDistance < fRetval)
292 fRetval = fNewDistance;
294 rEdgeIndex = nNewEdgeIndex;
313 for(
auto const& rPolygon : rCandidate)
315 aRetval.
append(
distort(rPolygon, rOriginal, rTopLeft, rTopRight, rBottomLeft, rBottomRight));
325 for(
auto const& rPolygon : rCandidate)
339 for(
auto const& rPolygon : rCandidate)
356 for(
auto const& rPolygon : rCandidate)
366 OSL_ENSURE(rOld1.
count() == rOld2.
count(),
"B2DPolyPolygon interpolate: Different geometry (!)");
369 for(sal_uInt32
a(0);
a < rOld1.
count();
a++)
380 if( rPoly.
count() != 1 )
393 for(
auto const& rPolygon : rCandidate)
410 for(
auto const& rPolygon : rCandidate)
422 const double fTotalSize=1.0;
423 const double fPosMiddleSegment=0.6;
424 const double fSegmentEndChopHoriz=0.08;
425 const double fSegmentEndChopVert =0.04;
429 const double fLeft=0.0;
430 const double fRight=fTotalSize;
431 const double fTop=0.0;
432 const double fMiddle=fPosMiddleSegment;
433 const double fBottom=fTotalSize;
445 static const double corners[] =
467 static const int numbers[] =
484 static const int index2corner[] =
500 else if( nNumber ==
'E' )
504 else if( nNumber ==
'.' )
508 fSegmentEndChopHoriz));
513 nNumber=std::clamp<sal_uInt32>(nNumber,
'0',
'9') -
'0';
517 const size_t sliceSize=std::size(numbers)/12;
518 const int* pCurrSegment=numbers + nNumber*sliceSize;
519 for(
size_t i=0;
i<sliceSize;
i++, pCurrSegment++)
521 if( !(*pCurrSegment ^
int(bLitSegments)) )
524 aCurrSegment.
clear();
526 corners[index2corner[j]+1] );
528 corners[index2corner[j+1]+1]);
530 if( rtl::math::approxEqual(
start.getX(),
end.getX()) )
533 end.setY(
end.getY()-fSegmentEndChopVert);
537 start.setX(
start.getX()+fSegmentEndChopHoriz);
538 end.setX(
end.getX()-fSegmentEndChopHoriz);
544 aRes.
append(aCurrSegment);
553 const css::drawing::PointSequenceSequence& rPointSequenceSequenceSource)
556 aRetval.
reserve(rPointSequenceSequenceSource.getLength());
557 const css::drawing::PointSequence* pPointSequence = rPointSequenceSequenceSource.getConstArray();
558 const css::drawing::PointSequence* pPointSeqEnd = pPointSequence + rPointSequenceSequenceSource.getLength();
560 for(;pPointSequence != pPointSeqEnd; pPointSequence++)
563 aRetval.
append(aNewPolygon);
571 css::drawing::PointSequenceSequence& rPointSequenceSequenceRetval)
577 rPointSequenceSequenceRetval.realloc(
nCount);
578 css::drawing::PointSequence* pPointSequence = rPointSequenceSequenceRetval.getArray();
580 for(
auto const& rPolygon : rPolyPolygon)
588 rPointSequenceSequenceRetval.realloc(0);
595 const css::drawing::PolyPolygonBezierCoords& rPolyPolygonBezierCoordsSource)
598 const sal_uInt32 nSequenceCount(
static_cast<sal_uInt32
>(rPolyPolygonBezierCoordsSource.Coordinates.getLength()));
602 OSL_ENSURE(nSequenceCount ==
static_cast<sal_uInt32
>(rPolyPolygonBezierCoordsSource.Flags.getLength()),
603 "UnoPolyPolygonBezierCoordsToB2DPolyPolygon: unequal number of Points and Flags (!)");
604 const css::drawing::PointSequence* pPointSequence = rPolyPolygonBezierCoordsSource.Coordinates.getConstArray();
605 const css::drawing::FlagSequence* pFlagSequence = rPolyPolygonBezierCoordsSource.Flags.getConstArray();
607 for(sal_uInt32
a(0);
a < nSequenceCount;
a++)
615 aRetval.
append(aNewPolygon);
624 css::drawing::PolyPolygonBezierCoords& rPolyPolygonBezierCoordsRetval)
631 rPolyPolygonBezierCoordsRetval.Coordinates.realloc(
static_cast<sal_Int32
>(
nCount));
632 rPolyPolygonBezierCoordsRetval.Flags.realloc(
static_cast<sal_Int32
>(
nCount));
635 css::drawing::PointSequence* pPointSequence = rPolyPolygonBezierCoordsRetval.Coordinates.getArray();
636 css::drawing::FlagSequence* pFlagSequence = rPolyPolygonBezierCoordsRetval.Flags.getArray();
638 for(
auto const& rSource : rPolyPolygon)
650 rPolyPolygonBezierCoordsRetval.Coordinates.realloc(0);
651 rPolyPolygonBezierCoordsRetval.Flags.realloc(0);
Base Point class with two double values.
B2DPolygon const & getB2DPolygon(sal_uInt32 nIndex) const
const B2DPolygon * begin() const
void append(const B2DPolygon &rPolygon, sal_uInt32 nCount=1)
void setB2DPolygon(sal_uInt32 nIndex, const B2DPolygon &rPolygon)
bool areControlPointsUsed() const
const B2DPolygon * end() const
void reserve(sal_uInt32 nCount)
void clear()
clear all points
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
void flip()
flip polygon direction
A two-dimensional interval over doubles.
void append(const B3DPolygon &rPolygon, sal_uInt32 nCount=1)
void expand(const Tuple2D< TYPE > &rTuple)
add point to the set, expanding as necessary
double getArea(const B2DPolygon &rCandidate)
B2DPolyPolygon reSegmentPolyPolygon(const B2DPolyPolygon &rCandidate, sal_uInt32 nSegments)
B2DPolygon reSegmentPolygon(const B2DPolygon &rCandidate, sal_uInt32 nSegments)
void B2DPolyPolygonToUnoPointSequenceSequence(const B2DPolyPolygon &rPolyPolygon, css::drawing::PointSequenceSequence &rPointSequenceSequenceRetval)
B3DPolyPolygon createB3DPolyPolygonFromB2DPolyPolygon(const B2DPolyPolygon &rCandidate, double fZCoordinate)
B2DPolygon UnoPointSequenceToB2DPolygon(const css::drawing::PointSequence &rPointSequenceSource)
converters for css::drawing::PointSequence
B2DPolygon interpolate(const B2DPolygon &rOld1, const B2DPolygon &rOld2, double t)
B2DPolygon expandToCurve(const B2DPolygon &rCandidate)
B2DPolygon growInNormalDirection(const B2DPolygon &rCandidate, double fValue)
B2DPolygon adaptiveSubdivideByDistance(const B2DPolygon &rCandidate, double fDistanceBound, int nRecurseLimit)
void applyLineDashing(const B2DPolygon &rCandidate, const std::vector< double > &rDotDashArray, B2DPolyPolygon *pLineTarget, B2DPolyPolygon *pGapTarget, double fDotDashLength)
B2VectorOrientation getOrientation(const B2DPolygon &rCandidate)
B2DPolyPolygon createB2DPolyPolygonFromB3DPolyPolygon(const B3DPolyPolygon &rCandidate, const B3DHomMatrix &rMat)
double getSignedArea(const B2DPolygon &rCandidate)
bool isInside(const B2DPolygon &rCandidate, const B2DPoint &rPoint, bool bWithBorder)
B2DPolyPolygon correctOutmostPolygon(const B2DPolyPolygon &rCandidate)
B2DPoint distort(const B2DPoint &rCandidate, const B2DRange &rOriginal, const B2DPoint &rTopLeft, const B2DPoint &rTopRight, const B2DPoint &rBottomLeft, const B2DPoint &rBottomRight)
B2DPolygon adaptiveSubdivideByAngle(const B2DPolygon &rCandidate, double fAngleBound)
B2DPolyPolygon correctOrientations(const B2DPolyPolygon &rCandidate)
B3DPolygon createB3DPolygonFromB2DPolygon(const B2DPolygon &rCandidate, double fZCoordinate)
void B2DPolygonToUnoPolygonBezierCoords(const B2DPolygon &rPolygon, css::drawing::PointSequence &rPointSequenceRetval, css::drawing::FlagSequence &rFlagSequenceRetval)
B2DPolygon snapPointsOfHorizontalOrVerticalEdges(const B2DPolygon &rCandidate)
snap some polygon coordinates to discrete coordinates
B2DPolygon createPolygonFromCircle(const B2DPoint &rCenter, double fRadius)
Create a circle polygon with given radius.
bool isInEpsilonRange(const B2DPoint &rEdgeStart, const B2DPoint &rEdgeEnd, const B2DPoint &rTestPosition, double fDistance)
B2DPolygon createB2DPolygonFromB3DPolygon(const B3DPolygon &rCandidate, const B3DHomMatrix &rMat)
bool isRectangle(const B2DPolygon &rPoly)
Predicate whether a given polygon is a rectangle.
B2DPolyPolygon createSevenSegmentPolyPolygon(char nNumber, bool bLitSegments)
Creates polypolygon for seven-segment display number.
B2DPolyPolygon UnoPointSequenceSequenceToB2DPolyPolygon(const css::drawing::PointSequenceSequence &rPointSequenceSequenceSource)
converters for css::drawing::PointSequence
void B2DPolygonToUnoPointSequence(const B2DPolygon &rPolygon, css::drawing::PointSequence &rPointSequenceRetval)
double getSmallestDistancePointToPolygon(const B2DPolygon &rCandidate, const B2DPoint &rTestPoint, sal_uInt32 &rEdgeIndex, double &rCut)
B2DPolygon simplifyCurveSegments(const B2DPolygon &rCandidate)
void B2DPolyPolygonToUnoPolyPolygonBezierCoords(const B2DPolyPolygon &rPolyPolygon, css::drawing::PolyPolygonBezierCoords &rPolyPolygonBezierCoordsRetval)
B2DPolygon UnoPolygonBezierCoordsToB2DPolygon(const css::drawing::PointSequence &rPointSequenceSource, const css::drawing::FlagSequence &rFlagSequenceSource)
B2DPolyPolygon UnoPolyPolygonBezierCoordsToB2DPolyPolygon(const css::drawing::PolyPolygonBezierCoords &rPolyPolygonBezierCoordsSource)
converters for css::drawing::PolyPolygonBezierCoords (curved polygons)
B2DRange getRange(const B2DPolygon &rCandidate)
Get the range of a polygon.
double getSmallestDistancePointToPolyPolygon(const B2DPolyPolygon &rCandidate, const B2DPoint &rTestPoint, sal_uInt32 &rPolygonIndex, sal_uInt32 &rEdgeIndex, double &rCut)
B2VectorOrientation
Descriptor for the mathematical orientations of two 2D Vectors.
@ Neutral
mathematically neutral, thus parallel
@ Negative
mathematically negative oriented