summaryrefslogtreecommitdiff
path: root/include/basegfx
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2023-08-17 19:30:56 +0200
committerRegina Henschel <rb.henschel@t-online.de>2023-08-24 17:54:46 +0200
commit44c0f2da567b49ef8a539958a834f1bc841c2003 (patch)
treec8b75a17fc2c6a04d493d67d9370c4394ff41be7 /include/basegfx
parent85d26674284bacff8f90de662b583d4d4291e65d (diff)
tdf#112687 Simplify polylines from slideshow annotations
Drawing with 'mouse as pen' in a slideshow creates hundreds of points. By commit 631964a2ce1da3fbbeb53a5550c0e6728ba644aa they are at least already combines to a polyline. The patch here now reduces the amount of points in such polyline to a reasonable number. If at some point the drawings in the slideshow are improved, this can be removed. The reduction is performed using the Douglas-Peucker algorithm. I have added the method to b2dpolygontools because I think it could be useful in other contexts. Change-Id: I9224ec3546d4442da8bc348aea8ce7b88fcc46dc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155811 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'include/basegfx')
-rw-r--r--include/basegfx/polygon/b2dpolygontools.hxx19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/basegfx/polygon/b2dpolygontools.hxx b/include/basegfx/polygon/b2dpolygontools.hxx
index d5aa092ed9cb..2f73b76d33c6 100644
--- a/include/basegfx/polygon/b2dpolygontools.hxx
+++ b/include/basegfx/polygon/b2dpolygontools.hxx
@@ -524,6 +524,25 @@ namespace basegfx::utils
*/
BASEGFX_DLLPUBLIC OUString exportToSvgPoints( const B2DPolygon& rPoly );
+ /** Reduces the number of points using the Ramer-Douglas-Peucker (RDP) algorithm. If the input
+ polygon has control points or less than three points, the input polygon is returned
+ unchanged. Otherwise, a simplified polygon is returned. If the input polygon is closed,
+ the caller is expected to ensure that the first and last points of the polygon are
+ identical. The polygon is treated as open in this case. Closing the result polygon is not
+ performed here, but left to the caller.
+
+ @param rCandidate
+ The source polygon from which the reduced polygon is generated
+
+ @param fTolerance
+ The tolerance for the RDP algorithm.
+
+ @return
+ A newly created polygon with reduced point count.
+ */
+ BASEGFX_DLLPUBLIC B2DPolygon createSimplifiedPolygon(const B2DPolygon& rCandidate,
+ const double fTolerance);
+
} // end of namespace basegfx::utils
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */