1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
25 #include <basegfx/point/b2dpoint.hxx>
26 #include <basegfx/vector/b2dvector.hxx>
27 #include <basegfx/range/b2drectangle.hxx>
28 #include <basegfx/polygon/b3dpolygon.hxx>
29 #include <basegfx/polygon/b2dpolygontriangulator.hxx>
30 #include <com/sun/star/drawing/PointSequence.hpp>
31 #include <com/sun/star/drawing/FlagSequence.hpp>
32 #include <basegfx/basegfxdllapi.h>
33 #include <o3tl/typed_flags_set.hxx>
36 namespace basegfx
{ class B2DPolyPolygon
; }
38 // Definitions for the cut flags used from the findCut methods
39 enum class CutFlagValue
47 ALL
= LINE
|START1
|START2
|END1
|END2
,
48 DEFAULT
= LINE
|START2
|END2
,
52 template<> struct typed_flags
<CutFlagValue
> : is_typed_flags
<CutFlagValue
, 0x1f> {};
61 namespace basegfx::utils
65 // open/close with point add/remove and control point corrections
66 BASEGFX_DLLPUBLIC
void openWithGeometryChange(B2DPolygon
& rCandidate
);
67 BASEGFX_DLLPUBLIC
void closeWithGeometryChange(B2DPolygon
& rCandidate
);
69 /** Check if given polygon is closed.
71 This is kind of a 'classic' method to support old polygon
72 definitions. Those old polygon definitions define the
73 closed state of the polygon using identical start and
74 endpoints. This method corrects this (removes double
75 start/end points) and sets the Closed()-state of the
78 BASEGFX_DLLPUBLIC
void checkClosed(B2DPolygon
& rCandidate
);
80 // Get successor and predecessor indices. Returning the same index means there
81 // is none. Same for successor.
82 BASEGFX_DLLPUBLIC sal_uInt32
getIndexOfPredecessor(sal_uInt32 nIndex
, const B2DPolygon
& rCandidate
);
83 BASEGFX_DLLPUBLIC sal_uInt32
getIndexOfSuccessor(sal_uInt32 nIndex
, const B2DPolygon
& rCandidate
);
85 // Get orientation of Polygon
86 BASEGFX_DLLPUBLIC B2VectorOrientation
getOrientation(const B2DPolygon
& rCandidate
);
88 // isInside tests for B2dPoint and other B2dPolygon. On border is not inside as long as
89 // not true is given in bWithBorder flag.
90 BASEGFX_DLLPUBLIC
bool isInside(const B2DPolygon
& rCandidate
, const B2DPoint
& rPoint
, bool bWithBorder
= false);
91 BASEGFX_DLLPUBLIC
bool isInside(const B2DPolygon
& rCandidate
, const B2DPolygon
& rPolygon
, bool bWithBorder
= false);
93 /** Get the range of a polygon
95 This method creates the outer range of the subdivided bezier curve.
96 For detailed discussion see B2DPolygon::getB2DRange()
99 The B2DPolygon possibly containing bezier segments
102 The outer range of the bezier curve
104 BASEGFX_DLLPUBLIC B2DRange
getRange(const B2DPolygon
& rCandidate
);
106 // get signed area of polygon
107 BASEGFX_DLLPUBLIC
double getSignedArea(const B2DPolygon
& rCandidate
);
109 // get area of polygon
110 BASEGFX_DLLPUBLIC
double getArea(const B2DPolygon
& rCandidate
);
112 /** get length of polygon edge from point nIndex to nIndex + 1 */
113 BASEGFX_DLLPUBLIC
double getEdgeLength(const B2DPolygon
& rCandidate
, sal_uInt32 nIndex
);
115 /** get length of polygon */
116 BASEGFX_DLLPUBLIC
double getLength(const B2DPolygon
& rCandidate
);
118 // get position on polygon for absolute given distance. If
119 // length is given, it is assumed the correct polygon length, if 0.0 it is calculated
120 // using getLength(...)
121 BASEGFX_DLLPUBLIC B2DPoint
getPositionAbsolute(const B2DPolygon
& rCandidate
, double fDistance
, double fLength
= 0.0);
123 // get position on polygon for relative given distance in range [0.0 .. 1.0]. If
124 // length is given, it is assumed the correct polygon length, if 0.0 it is calculated
125 // using getLength(...)
126 BASEGFX_DLLPUBLIC B2DPoint
getPositionRelative(const B2DPolygon
& rCandidate
, double fDistance
, double fLength
= 0.0);
128 // get a snippet from given polygon for absolute distances. The polygon is assumed
129 // to be opened (not closed). fFrom and fTo need to be in range [0.0 .. fLength], where
130 // fTo >= fFrom. If length is given, it is assumed the correct polygon length,
131 // if 0.0 it is calculated using getLength(...)
132 BASEGFX_DLLPUBLIC B2DPolygon
getSnippetAbsolute(const B2DPolygon
& rCandidate
, double fFrom
, double fTo
, double fLength
= 0.0);
134 // Continuity check for point with given index
135 BASEGFX_DLLPUBLIC B2VectorContinuity
getContinuityInPoint(const B2DPolygon
& rCandidate
, sal_uInt32 nIndex
);
137 // Subdivide all contained curves. Use distanceBound value if given.
138 BASEGFX_DLLPUBLIC B2DPolygon
adaptiveSubdivideByDistance(const B2DPolygon
& rCandidate
, double fDistanceBound
, int nRecurseLimit
= 30);
140 // Subdivide all contained curves. Use angleBound value if given.
141 BASEGFX_DLLPUBLIC B2DPolygon
adaptiveSubdivideByAngle(const B2DPolygon
& rCandidate
, double fAngleBound
= 0.0);
143 // This version works with two points and vectors to define the
144 // edges for the cut test.
145 BASEGFX_DLLPUBLIC CutFlagValue
findCut(
146 const B2DPoint
& rEdge1Start
, const B2DVector
& rEdge1Delta
,
147 const B2DPoint
& rEdge2Start
, const B2DVector
& rEdge2Delta
,
148 CutFlagValue aCutFlags
= CutFlagValue::DEFAULT
,
149 double* pCut1
= nullptr, double* pCut2
= nullptr);
151 // test if point is on the given edge in range ]0.0..1.0[ without
152 // the start/end points. If so, return true and put the parameter
153 // value in pCut (if provided)
154 BASEGFX_DLLPUBLIC
bool isPointOnEdge(
155 const B2DPoint
& rPoint
,
156 const B2DPoint
& rEdgeStart
,
157 const B2DVector
& rEdgeDelta
,
158 double* pCut
= nullptr);
160 /** Apply given LineDashing to given polygon
162 This method is used to cut down line polygons to the needed
163 pieces when a dashing needs to be applied.
164 It is now capable of keeping contained bezier segments.
165 It is also capable of delivering line and non-line portions
166 depending on what target polygons You provide. This is useful
167 e.g. for dashed lines with two colors.
168 If the last and the first snippet in one of the results have
169 a common start/end ppoint, they will be merged to achieve as
170 view as needed result line snippets. This is also relevant for
171 further processing the results.
174 The polygon based on which the snippets will be created.
177 The line pattern given as array of length values
180 The target for line snippets, e.g. the first entry will be
181 a line segment with length rDotDashArray[0]. The given
182 polygon will be emptied as preparation.
185 The target for gap snippets, e.g. the first entry will be
186 a line segment with length rDotDashArray[1]. The given
187 polygon will be emptied as preparation.
189 @param fFullDashDotLen
190 The summed-up length of the rDotDashArray. If zero, it will
191 be calculated internally.
193 There is now a 2nd version that allows to provide callback
194 functions that get called when a snippet of a line/gap is
195 produced and needs to be added. This allows to use it like
196 a 'pipeline'. When using this (e.g. the 1st version uses
197 this internally to guarantee the same algorithm is used)
198 it is not needed to accumulate a potentially huge number
199 of polygons in the result-polyPolygons, but e.g. consume
200 them directly in the caller. Example is rendering a
201 dashed line but without creating the potentially huge amount
203 The 2nd version will also merge first/last line/gap snippets
204 if the input polygon is closed and the start/end-points match
205 accordingly - at the cost that this will be delivered last.
207 BASEGFX_DLLPUBLIC
void applyLineDashing(
208 const B2DPolygon
& rCandidate
,
209 const std::vector
<double>& rDotDashArray
,
210 const std::function
<void(const basegfx::B2DPolygon
& rSnippet
)>& rLineTargetCallback
,
211 const std::function
<void(const basegfx::B2DPolygon
& rSnippet
)>& rGapTargetCallback
= std::function
<void(const basegfx::B2DPolygon
&)>(),
212 double fDotDashLength
= 0.0);
213 BASEGFX_DLLPUBLIC
void applyLineDashing(
214 const B2DPolygon
& rCandidate
,
215 const ::std::vector
<double>& rDotDashArray
,
216 B2DPolyPolygon
* pLineTarget
,
217 B2DPolyPolygon
* pGapTarget
= nullptr,
218 double fDotDashLength
= 0.0);
220 // test if point is inside epsilon-range around an edge defined
221 // by the two given points. Can be used for HitTesting. The epsilon-range
222 // is defined to be the rectangle centered to the given edge, using height
223 // 2 x fDistance, and the circle around both points with radius fDistance.
224 BASEGFX_DLLPUBLIC
bool isInEpsilonRange(const B2DPoint
& rEdgeStart
, const B2DPoint
& rEdgeEnd
, const B2DPoint
& rTestPosition
, double fDistance
);
226 // test if point is inside epsilon-range around the given Polygon. Can be used
227 // for HitTesting. The epsilon-range is defined to be the rectangle centered
228 // to the given edge, using height 2 x fDistance, and the circle around both points
229 // with radius fDistance.
230 BASEGFX_DLLPUBLIC
bool isInEpsilonRange(const B2DPolygon
& rCandidate
, const B2DPoint
& rTestPosition
, double fDistance
);
232 /** Create a polygon from a rectangle.
235 The rectangle which describes the polygon size
239 Radius of the edge rounding, relative to the rectangle size. 0.0 means no
240 rounding, 1.0 will lead to an ellipse
242 BASEGFX_DLLPUBLIC B2DPolygon
createPolygonFromRect( const B2DRectangle
& rRect
, double fRadiusX
, double fRadiusY
);
244 /** Create a polygon from a rectangle.
246 BASEGFX_DLLPUBLIC B2DPolygon
createPolygonFromRect( const B2DRectangle
& rRect
);
248 /** Create the unit polygon
250 BASEGFX_DLLPUBLIC B2DPolygon
const & createUnitPolygon();
252 /** Create a circle polygon with given radius.
254 This method creates a circle approximation consisting of
255 12 cubic bezier segments, which approximate the given
256 circle with an error of less than 0.5 percent.
259 Center point of the circle
264 BASEGFX_DLLPUBLIC B2DPolygon
createPolygonFromCircle( const B2DPoint
& rCenter
, double fRadius
);
266 /// create half circle centered on (0,0) from [0 .. M_PI]
267 B2DPolygon
const & createHalfUnitCircle();
269 /** create a polygon which describes the unit circle and close it
271 @param nStartQuadrant
272 To be able to rebuild the old behaviour where the circles started at bottom,
273 this parameter is used. Default is 0 which is the first quadrant and the
274 polygon's start point will be the rightmost one. When using e.g. 1, the
275 first created quadrant will start at the YMax-position (with Y down on screens,
276 this is the lowest one). This is needed since when lines are dashed, toe old
277 geometry started at bottom point, else it would look different.
279 BASEGFX_DLLPUBLIC B2DPolygon
const & createPolygonFromUnitCircle(sal_uInt32 nStartQuadrant
= 0);
281 /** Create an ellipse polygon with given radii.
283 This method creates an ellipse approximation consisting of
284 12 cubic bezier segments, which approximate the given
285 ellipse with an error of less than 0.5 percent.
288 Center point of the circle
291 Radius of the ellipse in X direction
294 Radius of the ellipse in Y direction
296 @param nStartQuadrant
297 With Y down on screens, 0 = 3 o'clock, 1 = 6 o'clock, 2 = 9 o'clock, 3 = 12 o'clock
299 BASEGFX_DLLPUBLIC B2DPolygon
createPolygonFromEllipse( const B2DPoint
& rCenter
, double fRadiusX
, double fRadiusY
, sal_uInt32 nStartQuadrant
= 0);
301 /** Create a unit ellipse polygon with the given angles, from start to end
303 BASEGFX_DLLPUBLIC B2DPolygon
createPolygonFromEllipseSegment( const B2DPoint
& rCenter
, double fRadiusX
, double fRadiusY
, double fStart
, double fEnd
);
305 BASEGFX_DLLPUBLIC B2DPolygon
createPolygonFromUnitEllipseSegment( double fStart
, double fEnd
);
307 /** Predicate whether a given polygon is a rectangle.
312 @return true, if the polygon describes a rectangle
313 (polygon is closed, and the points are either cw or ccw
314 enumerations of a rectangle's vertices). Note that
315 intermediate points and duplicate points are ignored.
317 BASEGFX_DLLPUBLIC
bool isRectangle( const B2DPolygon
& rPoly
);
319 // create 3d polygon from given 2d polygon. The given fZCoordinate is used to expand the
321 BASEGFX_DLLPUBLIC B3DPolygon
createB3DPolygonFromB2DPolygon(const B2DPolygon
& rCandidate
, double fZCoordinate
= 0.0);
323 // create 2d tools::PolyPolygon from given 3d PolyPolygon. All coordinates are transformed using the given
324 // matrix and the resulting x,y is used to form the new polygon.
325 BASEGFX_DLLPUBLIC B2DPolygon
createB2DPolygonFromB3DPolygon(const B3DPolygon
& rCandidate
, const B3DHomMatrix
& rMat
);
327 // calculate the smallest distance to given edge and return. The relative position on the edge is returned in Cut.
328 // That position is in the range [0.0 .. 1.0] and the returned distance is adapted accordingly to the start or end
330 BASEGFX_DLLPUBLIC
double getSmallestDistancePointToEdge(const B2DPoint
& rPointA
, const B2DPoint
& rPointB
, const B2DPoint
& rTestPoint
, double& rCut
);
332 // for each contained edge calculate the smallest distance. Return the index to the smallest
333 // edge in rEdgeIndex. The relative position on the edge is returned in rCut.
334 // If nothing was found (e.g. empty input plygon), DBL_MAX is returned.
335 BASEGFX_DLLPUBLIC
double getSmallestDistancePointToPolygon(const B2DPolygon
& rCandidate
, const B2DPoint
& rTestPoint
, sal_uInt32
& rEdgeIndex
, double& rCut
);
337 // distort single point. rOriginal describes the original range, where the given points describe the distorted corresponding points.
338 BASEGFX_DLLPUBLIC B2DPoint
distort(const B2DPoint
& rCandidate
, const B2DRange
& rOriginal
, const B2DPoint
& rTopLeft
, const B2DPoint
& rTopRight
, const B2DPoint
& rBottomLeft
, const B2DPoint
& rBottomRight
);
340 // distort polygon. rOriginal describes the original range, where the given points describe the distorted corresponding points.
341 BASEGFX_DLLPUBLIC B2DPolygon
distort(const B2DPolygon
& rCandidate
, const B2DRange
& rOriginal
, const B2DPoint
& rTopLeft
, const B2DPoint
& rTopRight
, const B2DPoint
& rBottomLeft
, const B2DPoint
& rBottomRight
);
343 // expand all segments (which are not yet) to curve segments. This is done with setting the control
344 // vectors on the 1/3 resp. 2/3 distances on each segment.
345 BASEGFX_DLLPUBLIC B2DPolygon
expandToCurve(const B2DPolygon
& rCandidate
);
347 // expand given segment to curve segment. This is done with setting the control
348 // vectors on the 1/3 resp. 2/3 distances. The return value describes if a change took place.
349 BASEGFX_DLLPUBLIC
bool expandToCurveInPoint(B2DPolygon
& rCandidate
, sal_uInt32 nIndex
);
351 // set continuity for given index. If not a curve, nothing will change. Non-curve points are not changed, too.
352 // The return value describes if a change took place.
353 BASEGFX_DLLPUBLIC
bool setContinuityInPoint(B2DPolygon
& rCandidate
, sal_uInt32 nIndex
, B2VectorContinuity eContinuity
);
355 // test if polygon contains neutral points. A neutral point is one whose orientation is neutral
356 // e.g. positioned on the edge of its predecessor and successor
357 BASEGFX_DLLPUBLIC
bool hasNeutralPoints(const B2DPolygon
& rCandidate
);
359 // remove neutral points. A neutral point is one whose orientation is neutral
360 // e.g. positioned on the edge of its predecessor and successor
361 BASEGFX_DLLPUBLIC B2DPolygon
removeNeutralPoints(const B2DPolygon
& rCandidate
);
363 // tests if polygon is convex
364 BASEGFX_DLLPUBLIC
bool isConvex(const B2DPolygon
& rCandidate
);
366 // calculates the orientation at edge nIndex
367 BASEGFX_DLLPUBLIC B2VectorOrientation
getOrientationForIndex(const B2DPolygon
& rCandidate
, sal_uInt32 nIndex
);
369 // calculates if given point is on given line, taking care of the numerical epsilon
370 BASEGFX_DLLPUBLIC
bool isPointOnLine(const B2DPoint
& rStart
, const B2DPoint
& rEnd
, const B2DPoint
& rCandidate
, bool bWithPoints
);
372 // calculates if given point is on given polygon, taking care of the numerical epsilon. Uses
373 // isPointOnLine internally
374 BASEGFX_DLLPUBLIC
bool isPointOnPolygon(const B2DPolygon
& rCandidate
, const B2DPoint
& rPoint
, bool bWithPoints
= true);
376 // test if candidate is inside triangle
377 BASEGFX_DLLPUBLIC
bool isPointInTriangle(const B2DPoint
& rA
, const B2DPoint
& rB
, const B2DPoint
& rC
, const B2DPoint
& rCandidate
, bool bWithBorder
);
379 // test if candidateA and candidateB are on the same side of the given line
380 bool arePointsOnSameSideOfLine(const B2DPoint
& rStart
, const B2DPoint
& rEnd
, const B2DPoint
& rCandidateA
, const B2DPoint
& rCandidateB
, bool bWithLine
);
382 // add triangles for given rCandidate to rTarget. For each triangle, 3 points will be added to rCandidate.
383 // All triangles will go from the start point of rCandidate to two consecutive points, building (rCandidate.count() - 2)
386 const B2DPolygon
& rCandidate
,
387 triangulator::B2DTriangleVector
& rTarget
);
389 // grow for polygon. Move all geometry in each point in the direction of the normal in that point
390 // with the given amount. Value may be negative.
391 BASEGFX_DLLPUBLIC B2DPolygon
growInNormalDirection(const B2DPolygon
& rCandidate
, double fValue
);
393 // force all sub-polygons to a point count of nSegments
394 BASEGFX_DLLPUBLIC B2DPolygon
reSegmentPolygon(const B2DPolygon
& rCandidate
, sal_uInt32 nSegments
);
396 // create polygon state at t from 0.0 to 1.0 between the two polygons. Both polygons must have the same
397 // organisation, e.g. same amount of points
398 BASEGFX_DLLPUBLIC B2DPolygon
interpolate(const B2DPolygon
& rOld1
, const B2DPolygon
& rOld2
, double t
);
400 // #i76891# Try to remove existing curve segments if they are simply edges
401 BASEGFX_DLLPUBLIC B2DPolygon
simplifyCurveSegments(const B2DPolygon
& rCandidate
);
403 // makes the given indexed point the new polygon start point. To do that, the points in the
404 // polygon will be rotated. This is only valid for closed polygons, for non-closed ones
405 // an assertion will be triggered
406 BASEGFX_DLLPUBLIC B2DPolygon
makeStartPoint(const B2DPolygon
& rCandidate
, sal_uInt32 nIndexOfNewStatPoint
);
408 /** create edges of given length along given B2DPolygon
411 The polygon to move along. Points at the given polygon are created, starting
412 at position fStart and stopping at less or equal to fEnd. The closed state is
414 The polygon is subdivided if curve segments are included. That subdivision is the base
415 for the newly created points.
416 If the source is closed, the indirectly existing last edge may NOT have the
418 If the source is open, all edges will have the given length. You may use the last
419 point of the original when You want to add the last edge Yourself.
422 The length of the created edges. If less or equal zero, an empty polygon is returned.
425 The start distance for the first to be generated point. Use 0.0 to get the
426 original start point. Negative values are truncated to 0.0.
429 The maximum distance for the last point. No more points behind this distance will be created.
430 Use 0.0 to process the whole polygon. Negative values are truncated to 0.0. It also
431 needs to be more or equal to fStart, else it is truncated to fStart.
434 The newly created polygon
436 B2DPolygon
createEdgesOfGivenLength(const B2DPolygon
& rCandidate
, double fLength
, double fStart
= 0.0, double fEnd
= 0.0);
438 /** Create Waveline along given polygon
439 The implementation is based on createEdgesOfGivenLength and creates a curve
440 segment with the given dimensions for each created line segment. The polygon
441 is treated as if opened (closed state will be ignored) and only for whole
442 edges a curve segment will be created (no rest handling)
445 The polygon along which the waveline will be created
448 The length of a single waveline curve segment
451 The height of the waveline (amplitude)
453 BASEGFX_DLLPUBLIC B2DPolygon
createWaveline(const B2DPolygon
& rCandidate
, double fWaveWidth
, double fWaveHeight
);
455 /** snap some polygon coordinates to discrete coordinates
457 This method allows to snap some polygon points to discrete (integer) values
458 which equals e.g. a snap to discrete coordinates. It will snap points of
459 horizontal and vertical edges
465 The modified version of the source polygon
467 BASEGFX_DLLPUBLIC B2DPolygon
snapPointsOfHorizontalOrVerticalEdges(const B2DPolygon
& rCandidate
);
469 /// get the tangent with which the given point is entered seen from the previous
470 /// polygon path data. Take into account all stuff like closed state, zero-length edges and others.
471 BASEGFX_DLLPUBLIC B2DVector
getTangentEnteringPoint(const B2DPolygon
& rCandidate
, sal_uInt32 nIndex
);
473 /// get the tangent with which the given point is left seen from the following
474 /// polygon path data. Take into account all stuff like closed state, zero-length edges and others.
475 BASEGFX_DLLPUBLIC B2DVector
getTangentLeavingPoint(const B2DPolygon
& rCandidate
, sal_uInt32 nIndex
);
477 /// converters for css::drawing::PointSequence
478 BASEGFX_DLLPUBLIC B2DPolygon
UnoPointSequenceToB2DPolygon(
479 const css::drawing::PointSequence
& rPointSequenceSource
);
480 BASEGFX_DLLPUBLIC
void B2DPolygonToUnoPointSequence(
481 const B2DPolygon
& rPolygon
,
482 css::drawing::PointSequence
& rPointSequenceRetval
);
484 /* converters for css::drawing::PointSequence and
485 css::drawing::FlagSequence to B2DPolygon (curved polygons)
487 B2DPolygon
UnoPolygonBezierCoordsToB2DPolygon(
488 const css::drawing::PointSequence
& rPointSequenceSource
,
489 const css::drawing::FlagSequence
& rFlagSequenceSource
);
490 void B2DPolygonToUnoPolygonBezierCoords(
491 const B2DPolygon
& rPolyPolygon
,
492 css::drawing::PointSequence
& rPointSequenceRetval
,
493 css::drawing::FlagSequence
& rFlagSequenceRetval
);
495 /** Read poly-polygon from SVG.
497 This function imports a poly-polygon from an SVG points
498 attribute (a plain list of coordinate pairs).
501 The output polygon. Note that svg:points can only define a
504 @param rSvgPointsAttribute
505 A valid SVG points attribute string
507 @return true, if the string was successfully parsed
509 BASEGFX_DLLPUBLIC
bool importFromSvgPoints( B2DPolygon
& o_rPoly
,
510 std::u16string_view rSvgPointsAttribute
);
512 /** Write poly-polygon to SVG.
514 This function imports a non-bezier polygon to SVG points
515 (a plain list of coordinate pairs).
518 The polygon to export
520 @param rSvgPointsAttribute
521 A valid SVG points attribute string
523 @return true, if the string was successfully parsed
525 BASEGFX_DLLPUBLIC OUString
exportToSvgPoints( const B2DPolygon
& rPoly
);
527 /** Reduces the number of points using the Ramer-Douglas-Peucker (RDP) algorithm. If the input
528 polygon has control points or less than three points, the input polygon is returned
529 unchanged. Otherwise, a simplified polygon is returned. If the input polygon is closed,
530 the caller is expected to ensure that the first and last points of the polygon are
531 identical. The polygon is treated as open in this case. Closing the result polygon is not
532 performed here, but left to the caller.
535 The source polygon from which the reduced polygon is generated
538 The tolerance for the RDP algorithm.
541 A newly created polygon with reduced point count.
543 BASEGFX_DLLPUBLIC B2DPolygon
createSimplifiedPolygon(const B2DPolygon
& rCandidate
,
544 const double fTolerance
);
546 } // end of namespace basegfx::utils
548 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */