diff --git a/src/livarot/Path.cpp b/src/livarot/Path.cpp index 03e17db7ee12f31728c8d682089b84ee021b3c0f..d2bc4a3002a2868f7bf2e5ea7f6eb7094819e67a 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 163d955409cdb2c8b1cdd812f5e0c47772dc0a67..9146304b01772d618d3d97917eaa5184c044748e 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 bf3e200daed3a5b6d60def3ee1e584387e7e2035..0b57fa5cc4d0e171fee772067c5edfa0eac22e76 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 2b58944a58a986808a6a5b98067e30a5a0395f01..bd83b925dcdacfe8517af58f17487f1ee2c9e989 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 } }