From 62a9f7ae63a2af24b4f59a643baf9004c2b2fdd8 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Mon, 7 Dec 2020 06:53:05 -0500 Subject: [PATCH] Partial Fix #1960 to fix dashes which have zero widths --- src/livarot/Path.cpp | 8 -------- src/livarot/Path.h | 4 ++-- src/livarot/PathSimplify.cpp | 8 ++++---- src/path/path-outline.cpp | 2 +- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/livarot/Path.cpp b/src/livarot/Path.cpp index 03e17db7ee..d2bc4a3002 100644 --- a/src/livarot/Path.cpp +++ b/src/livarot/Path.cpp @@ -413,10 +413,6 @@ int Path::AddPoint(Geom::Point const &iPt, bool mvto) return AddPoint (iPt, -1, 0.0, mvto); } - if ( !mvto && !pts.empty() && pts.back().p == iPt ) { - return -1; - } - int const n = pts.size(); pts.emplace_back(mvto ? polyline_moveto : polyline_lineto, iPt); return n; @@ -441,10 +437,6 @@ int Path::AddPoint(Geom::Point const &iPt, int ip, double it, bool mvto) return AddPoint (iPt, mvto); } - if ( !mvto && !pts.empty() && pts.back().p == iPt ) { - return -1; - } - int const n = pts.size(); pts.emplace_back(mvto ? polyline_moveto : polyline_lineto, iPt, ip, it); return n; diff --git a/src/livarot/Path.h b/src/livarot/Path.h index 163d955409..9146304b01 100644 --- a/src/livarot/Path.h +++ b/src/livarot/Path.h @@ -167,7 +167,7 @@ public: double miter); // polyline to cubic bezier patches - void Simplify (double treshhold); + void Simplify (double treshhold, bool auto_close = true); // description simplification void Coalesce (double tresh); @@ -377,7 +377,7 @@ public: Geom::Point &origine,float width); - void DoSimplify(int off, int N, double treshhold); + void DoSimplify(int off, int N, double treshhold, bool auto_close = true); bool AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &res, int &worstP); static bool FitCubic(Geom::Point const &start, PathDescrCubicTo &res, diff --git a/src/livarot/PathSimplify.cpp b/src/livarot/PathSimplify.cpp index bf3e200dae..0b57fa5cc4 100644 --- a/src/livarot/PathSimplify.cpp +++ b/src/livarot/PathSimplify.cpp @@ -47,7 +47,7 @@ -void Path::Simplify(double treshhold) +void Path::Simplify(double treshhold, bool auto_close) { if (pts.size() <= 1) { return; @@ -65,7 +65,7 @@ void Path::Simplify(double treshhold) lastP++; } - DoSimplify(lastM, lastP - lastM, treshhold); + DoSimplify(lastM, lastP - lastM, treshhold, auto_close); lastM = lastP; } @@ -153,7 +153,7 @@ static double DistanceToCubic(Geom::Point const &start, PathDescrCubicTo res, Ge * Simplification on a subpath. */ -void Path::DoSimplify(int off, int N, double treshhold) +void Path::DoSimplify(int off, int N, double treshhold, bool auto_close) { // non-dichotomic method: grow an interval of points approximated by a curve, until you reach the treshhold, and repeat if (N <= 1) { @@ -229,7 +229,7 @@ void Path::DoSimplify(int off, int N, double treshhold) curP = lastP; } - if (Geom::LInfty(endToPt - moveToPt) < 0.00001) { + if (auto_close && Geom::LInfty(endToPt - moveToPt) < 0.00001) { Close(); } diff --git a/src/path/path-outline.cpp b/src/path/path-outline.cpp index 2b58944a58..bd83b925dc 100644 --- a/src/path/path-outline.cpp +++ b/src/path/path-outline.cpp @@ -147,7 +147,7 @@ item_find_paths(const SPItem *item, Geom::PathVector& fill, Geom::PathVector& st auto bounds = Geom::bounds_fast(pathv); if (bounds) { double size = Geom::L2(bounds->dimensions()); - origin->Simplify(size * 0.000005); // Polylines to Beziers + origin->Simplify(size * 0.000005, false); // Polylines to Beziers } } -- GitLab