35class CoordinateDataArray2D
38 std::vector<basegfx::B2DPoint> maVector;
41 explicit CoordinateDataArray2D(sal_uInt32 nCount)
46 CoordinateDataArray2D(
const CoordinateDataArray2D& rOriginal, sal_uInt32 nIndex, sal_uInt32 nCount)
51 sal_uInt32
count()
const
53 return maVector.size();
56 bool operator==(
const CoordinateDataArray2D& rCandidate)
const
58 return (maVector == rCandidate.maVector);
63 assert(nIndex < maVector.size());
69 assert(nIndex < maVector.size());
73 void reserve(sal_uInt32 nCount)
75 maVector.reserve(nCount);
80 maVector.push_back(rValue);
83 void insert(sal_uInt32 nIndex,
const basegfx::B2DPoint& rValue, sal_uInt32 nCount)
86 assert(nIndex <= maVector.size());
88 maVector.insert(maVector.begin() + nIndex, nCount, rValue);
91 void insert(sal_uInt32 nIndex,
const CoordinateDataArray2D& rSource)
93 assert(rSource.maVector.size() > 0);
94 assert(nIndex <= maVector.size());
96 auto aIndex = maVector.begin();
98 auto aStart = rSource.maVector.cbegin();
99 auto aEnd = rSource.maVector.cend();
100 maVector.insert(aIndex, aStart, aEnd);
103 void remove(sal_uInt32 nIndex, sal_uInt32 nCount)
106 assert(nIndex + nCount <= maVector.size());
108 const auto aStart = maVector.begin() +
nIndex;
109 const auto aEnd = aStart +
nCount;
110 maVector.erase(aStart, aEnd);
113 void flip(
bool bIsClosed)
115 assert(maVector.size() > 1);
119 const sal_uInt32 nHalfSize(bIsClosed ? (maVector.size() - 1) >> 1 : maVector.size() >> 1);
120 auto aStart = bIsClosed ? maVector.begin() + 1 : maVector.begin();
121 auto aEnd = maVector.end() - 1;
123 for(sal_uInt32
a(0);
a < nHalfSize;
a++)
125 std::swap(*aStart, *aEnd);
131 void removeDoublePointsAtBeginEnd()
135 while((maVector.size() > 1) && (maVector[0] == maVector[maVector.size() - 1]))
141 void removeDoublePointsWholeTrack()
147 while((maVector.size() > 1) && (nIndex <= maVector.size() - 2))
149 if(maVector[nIndex] == maVector[nIndex + 1])
152 maVector.erase(maVector.begin() + (nIndex + 1));
164 for (
auto& point : maVector)
171class ControlVectorPair2D
177 explicit ControlVectorPair2D() {}
186 if(rValue != maPrevVector)
187 maPrevVector = rValue;
197 if(rValue != maNextVector)
198 maNextVector = rValue;
201 bool operator==(
const ControlVectorPair2D& rData)
const
203 return (maPrevVector == rData.getPrevVector() && maNextVector == rData.getNextVector());
208 std::swap(maPrevVector, maNextVector);
212class ControlVectorArray2D
214 typedef std::vector< ControlVectorPair2D > ControlVectorPair2DVector;
216 ControlVectorPair2DVector maVector;
217 sal_uInt32 mnUsedVectors;
220 explicit ControlVectorArray2D(sal_uInt32 nCount)
225 ControlVectorArray2D(
const ControlVectorArray2D& rOriginal, sal_uInt32 nIndex, sal_uInt32 nCount)
228 assert(nIndex + nCount <= rOriginal.maVector.size());
229 auto aStart(rOriginal.maVector.begin() + nIndex);
230 auto aEnd(aStart + nCount);
231 maVector.reserve(nCount);
233 for(; aStart != aEnd; ++aStart)
235 if(!aStart->getPrevVector().equalZero())
238 if(!aStart->getNextVector().equalZero())
241 maVector.push_back(*aStart);
245 bool operator==(
const ControlVectorArray2D& rCandidate)
const
247 return (maVector == rCandidate.maVector);
252 return (mnUsedVectors != 0);
257 assert(nIndex < maVector.size());
258 return maVector[
nIndex].getPrevVector();
263 bool bWasUsed(mnUsedVectors && !maVector[nIndex].getPrevVector().
equalZero());
270 maVector[
nIndex].setPrevVector(rValue);
282 maVector[
nIndex].setPrevVector(rValue);
290 assert(nIndex < maVector.size());
291 return maVector[
nIndex].getNextVector();
296 bool bWasUsed(mnUsedVectors && !maVector[nIndex].getNextVector().
equalZero());
303 maVector[
nIndex].setNextVector(rValue);
315 maVector[
nIndex].setNextVector(rValue);
321 void append(
const ControlVectorPair2D& rValue)
323 maVector.push_back(rValue);
325 if(!rValue.getPrevVector().equalZero())
328 if(!rValue.getNextVector().equalZero())
332 void insert(sal_uInt32 nIndex,
const ControlVectorPair2D& rValue, sal_uInt32 nCount)
335 assert(nIndex <= maVector.size());
338 maVector.insert(maVector.begin() + nIndex, nCount, rValue);
340 if(!rValue.getPrevVector().equalZero())
343 if(!rValue.getNextVector().equalZero())
347 void insert(sal_uInt32 nIndex,
const ControlVectorArray2D& rSource)
349 assert(rSource.maVector.size() > 0);
350 assert(nIndex <= maVector.size());
353 ControlVectorPair2DVector::iterator
aIndex(maVector.begin() + nIndex);
354 ControlVectorPair2DVector::const_iterator aStart(rSource.maVector.begin());
355 ControlVectorPair2DVector::const_iterator aEnd(rSource.maVector.end());
356 maVector.insert(aIndex, aStart, aEnd);
358 for(; aStart != aEnd; ++aStart)
360 if(!aStart->getPrevVector().equalZero())
363 if(!aStart->getNextVector().equalZero())
368 void remove(sal_uInt32 nIndex, sal_uInt32 nCount)
371 assert(nIndex + nCount <= maVector.size());
373 const ControlVectorPair2DVector::iterator aDeleteStart(maVector.begin() + nIndex);
374 const ControlVectorPair2DVector::iterator aDeleteEnd(aDeleteStart + nCount);
375 ControlVectorPair2DVector::const_iterator aStart(aDeleteStart);
377 for(; mnUsedVectors && aStart != aDeleteEnd; ++aStart)
379 if(!aStart->getPrevVector().equalZero())
382 if(mnUsedVectors && !aStart->getNextVector().equalZero())
387 maVector.erase(aDeleteStart, aDeleteEnd);
390 void flip(
bool bIsClosed)
392 assert(maVector.size() > 1);
396 const sal_uInt32 nHalfSize(bIsClosed ? (maVector.size() - 1) >> 1 : maVector.size() >> 1);
397 ControlVectorPair2DVector::iterator aStart(bIsClosed ? maVector.begin() + 1 : maVector.begin());
398 ControlVectorPair2DVector::iterator aEnd(maVector.end() - 1);
400 for(sal_uInt32
a(0);
a < nHalfSize;
a++)
407 std::swap(*aStart, *aEnd);
422 maVector.begin()->flip();
431 mutable std::optional< basegfx::B2DPolygon > mpDefaultSubdivision;
434 mutable std::optional< basegfx::B2DRange > moB2DRange;
443 if(!mpDefaultSubdivision)
448 return *mpDefaultSubdivision;
456 const sal_uInt32 nPointCount(rSource.
count());
460 for(sal_uInt32
a(0);
a < nPointCount;
a++)
467 const sal_uInt32 nEdgeCount(rSource.
isClosed() ? nPointCount : nPointCount - 1);
474 for(sal_uInt32 b(0); b < nEdgeCount; b++)
476 const sal_uInt32 nNextIndex((b + 1) % nPointCount);
485 if(!aNewRange.
isInside(aBezierRangeWithControlPoints))
492 std::vector< double > aExtremas;
494 aExtremas.reserve(4);
497 const sal_uInt32 nExtremaCount(aExtremas.size());
499 for(sal_uInt32 c(0); c < nExtremaCount; c++)
513 moB2DRange = aNewRange;
641 bool bControlVectorsAreEqual(
true);
647 bControlVectorsAreEqual = ((*moControlVector) == (*rCandidate.
moControlVector));
664 return bControlVectorsAreEqual;
686 const auto aCoordinate = rPoint;
691 const ControlVectorPair2D aVectorPair;
700 auto aCoordinate = rPoint;
705 ControlVectorPair2D aVectorPair;
814 assert(rSource.
maPoints.count() > 0);
832 ControlVectorPair2D aVectorPair;
837 void remove(sal_uInt32 nIndex, sal_uInt32 nCount)
892 for(sal_uInt32
a(0);
a <
maPoints.count() - 1;
a++)
965 maPoints.removeDoublePointsAtBeginEnd();
1010 maPoints.removeDoublePointsWholeTrack();
1042 aCandidate *= rMatrix;
1121 return !(*
this == rPolygon);
1264 const B2DVector aNewPrevVector(rPrevControlPoint - rPoint);
1272 mpPolygon->appendBezierSegment(aNewNextVector, aNewPrevVector, rPoint);
1281 const double nX((rControlPoint.
getX() * 2.0 + rPoint.
getX()) / 3.0);
1282 const double nY((rControlPoint.
getY() * 2.0 + rPoint.
getY()) / 3.0);
1289 const double nX1((rControlPoint.
getX() * 2.0 + aPreviousPoint.
getX()) / 3.0);
1290 const double nY1((rControlPoint.
getY() * 2.0 + aPreviousPoint.
getY()) / 3.0);
1291 const double nX2((rControlPoint.
getX() * 2.0 + rPoint.
getX()) / 3.0);
1292 const double nY2((rControlPoint.
getY() * 2.0 + rPoint.
getY()) / 3.0);
1300 return mpPolygon->areControlPointsUsed();
1330 const bool bNextIndexValidWithoutClose(
nIndex + 1 <
count());
1332 if(bNextIndexValidWithoutClose ||
isClosed())
1334 const sal_uInt32 nNextIndex(bNextIndexValidWithoutClose ?
nIndex + 1 : 0);
1354 rTarget.setStartPoint(aPoint);
1356 rTarget.setControlPointA(aPoint);
1357 rTarget.setControlPointB(aPoint);
1363 return mpPolygon->getDefaultAdaptiveSubdivision(*
this);
1435 mpPolygon->removeDoublePointsAtBeginEnd();
1436 mpPolygon->removeDoublePointsWholeTrack();
1450 mpPolygon->addOrReplaceSystemDependentData(rData);
1455 return mpPolygon->getSystemDependentData(hash_code);
void setPoint(sal_uInt32 nIndex, const basegfx::B2DPoint &rValue)
ImplB2DPolygon & operator=(const ImplB2DPolygon &rOther)
void removeDoublePointsWholeTrack()
void setNextControlVector(sal_uInt32 nIndex, const basegfx::B2DVector &rValue)
void append(const basegfx::B2DPoint &rPoint)
const basegfx::B2DPoint & getPoint(sal_uInt32 nIndex) const
basegfx::SystemDependentData_SharedPtr getSystemDependentData(size_t hash_code) const
void addOrReplaceSystemDependentData(basegfx::SystemDependentData_SharedPtr &rData) const
void append(const ImplB2DPolygon &rSource)
void setControlVectors(sal_uInt32 nIndex, const basegfx::B2DVector &rPrev, const basegfx::B2DVector &rNext)
std::optional< ControlVectorArray2D > moControlVector
void removeDoublePointsAtBeginEnd()
void remove(sal_uInt32 nIndex, sal_uInt32 nCount)
const basegfx::B2DRange & getB2DRange(const basegfx::B2DPolygon &rSource) const
bool operator==(const ImplB2DPolygon &rCandidate) const
const basegfx::B2DVector & getPrevControlVector(sal_uInt32 nIndex) const
void reserve(sal_uInt32 nCount)
bool areControlPointsUsed() const
void appendBezierSegment(const basegfx::B2DVector &rNext, const basegfx::B2DVector &rPrev, const basegfx::B2DPoint &rPoint)
void resetControlVectors()
void setClosed(bool bNew)
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
ImplB2DPolygon(const ImplB2DPolygon &rToBeCopied)
void setPrevControlVector(sal_uInt32 nIndex, const basegfx::B2DVector &rValue)
ImplB2DPolygon(const ImplB2DPolygon &rToBeCopied, sal_uInt32 nIndex, sal_uInt32 nCount)
void insert(sal_uInt32 nIndex, const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
std::unique_ptr< ImplBufferedData > mpBufferedData
CoordinateDataArray2D maPoints
const basegfx::B2DPolygon & getDefaultAdaptiveSubdivision(const basegfx::B2DPolygon &rSource) const
const basegfx::B2DVector & getNextControlVector(sal_uInt32 nIndex) const
void transform(const basegfx::B2DHomMatrix &rMatrix)
bool hasDoublePoints() const
void setStartPoint(const B2DPoint &rValue)
SAL_DLLPRIVATE void getAllExtremumPositions(::std::vector< double > &rResults) const
Get all extremum pos of this segment.
void setControlPointA(const B2DPoint &rValue)
void setEndPoint(const B2DPoint &rValue)
B2DRange getRange() const
void setControlPointB(const B2DPoint &rValue)
B2DPoint interpolatePoint(double t) const
const B2DPoint & getEndPoint() const
Base Point class with two double values.
bool isPrevControlPointUsed(sal_uInt32 nIndex) const
const basegfx::B2DVector & getNextControlVector(sal_uInt32 nIndex) const
void setB2DPoint(sal_uInt32 nIndex, const basegfx::B2DPoint &rValue)
bool isNextControlPointUsed(sal_uInt32 nIndex) const
SystemDependentData_SharedPtr getSystemDependantDataInternal(size_t hash_code) const
B2DPolygon & operator=(const B2DPolygon &rPolygon)
assignment operator
void addOrReplaceSystemDependentDataInternal(SystemDependentData_SharedPtr &rData) const
void clear()
clear all points
void insert(sal_uInt32 nIndex, const basegfx::B2DPoint &rPoint, sal_uInt32 nCount=1)
Coordinate insert/append.
bool operator!=(const B2DPolygon &rPolygon) const
void resetNextControlPoint(sal_uInt32 nIndex)
void appendQuadraticBezierSegment(const basegfx::B2DPoint &rQuadControlPoint, const basegfx::B2DPoint &rPoint)
This is a shortcut to append a quadratic bezier segment.
void setPrevControlPoint(sal_uInt32 nIndex, const basegfx::B2DPoint &rValue)
bool operator==(const B2DPolygon &rPolygon) const
compare operators
bool isClosed() const
closed state interface
basegfx::B2DPoint const & getB2DPoint(sal_uInt32 nIndex) const
Coordinate interface.
void transform(const basegfx::B2DHomMatrix &rMatrix)
apply transformation given in matrix form
void getBezierSegment(sal_uInt32 nIndex, B2DCubicBezier &rTarget) const
bezier segment access
B2DPolygon()
diverse constructors
void setNextControlPoint(sal_uInt32 nIndex, const basegfx::B2DPoint &rValue)
basegfx::B2DPoint getPrevControlPoint(sal_uInt32 nIndex) const
Basic ControlPoint interface.
bool hasDoublePoints() const
test if Polygon has double points
void setControlPoints(sal_uInt32 nIndex, const basegfx::B2DPoint &rPrev, const basegfx::B2DPoint &rNext)
bool areControlPointsUsed() const
ControlPoint checks.
B2VectorContinuity getContinuityInPoint(sal_uInt32 nIndex) const
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
void reserve(sal_uInt32 nCount)
B2DRange const & getB2DRange() const
Get the B2DRange (Rectangle dimensions) of this B2DPolygon.
void removeDoublePoints()
remove double points, at the begin/end and follow-ups, too
void resetControlPoints()
sal_uInt32 count() const
member count
const basegfx::B2DVector & getPrevControlVector(sal_uInt32 nIndex) const
void setClosed(bool bNew)
void makeUnique()
unshare this polygon with all internally shared instances
B2DPolygon const & getDefaultAdaptiveSubdivision() const
Default adaptive subdivision access.
void resetPrevControlPoint(sal_uInt32 nIndex)
ControlPoint resets.
void remove(sal_uInt32 nIndex, sal_uInt32 nCount=1)
remove points
basegfx::B2DPoint getNextControlPoint(sal_uInt32 nIndex) const
void flip()
flip polygon direction
void appendBezierSegment(const basegfx::B2DPoint &rNextControlPoint, const basegfx::B2DPoint &rPrevControlPoint, const basegfx::B2DPoint &rPoint)
Bezier segment append with control points. The current last polygon point is implicitly taken as star...
A two-dimensional interval over doubles.
Base Point class with two double values.
static const B2DVector & getEmptyVector()
void expand(const Tuple2D< TYPE > &rTuple)
add point to the set, expanding as necessary
bool isInside(const Tuple2D< TYPE > &rTuple) const
yields true if given point is contained in set
TYPE getX() const
Get X-Coordinate of 2D Tuple.
TYPE getY() const
Get Y-Coordinate of 2D Tuple.
bool same_object(const cow_wrapper &rOther) const
value_type & make_unique()
std::deque< AttacherIndex_Impl > aIndex
B2DPolygon adaptiveSubdivideByAngle(const B2DPolygon &rCandidate, double fAngleBound)
B2VectorContinuity
Descriptor for the mathematical continuity of two 2D Vectors.
std::shared_ptr< SystemDependentData > SystemDependentData_SharedPtr
B2VectorContinuity getContinuity(const B2DVector &rBackVector, const B2DVector &rForwardVector)
Test continuity between given vectors.
static o3tl::cow_wrapper< ImplB2DPolygon > DEFAULT
OUStringBuffer & remove(OUStringBuffer &rIn, sal_Unicode c)
enumrange< T >::Iterator begin(enumrange< T >)
bool operator==(const XclFontData &rLeft, const XclFontData &rRight)