diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2015-05-09 17:57:41 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2015-05-09 17:57:41 +0000 |
| commit | 2fd30724472ab97df99c329e66310395a5c3bfa9 (patch) | |
| tree | 4a9fec24d3143e5e358978c173143b7779ff4ad3 /src | |
| parent | Fix eraser tool (diff) | |
| download | inkscape-2fd30724472ab97df99c329e66310395a5c3bfa9.tar.gz inkscape-2fd30724472ab97df99c329e66310395a5c3bfa9.zip | |
Update to 2Geom r2360. Fixes taper stroke LPE.
(bzr r14059.2.13)
Diffstat (limited to 'src')
| -rw-r--r-- | src/2geom/path.cpp | 40 | ||||
| -rw-r--r-- | src/2geom/path.h | 11 |
2 files changed, 46 insertions, 5 deletions
diff --git a/src/2geom/path.cpp b/src/2geom/path.cpp index e38835776..8cba316f5 100644 --- a/src/2geom/path.cpp +++ b/src/2geom/path.cpp @@ -36,6 +36,7 @@ #include <2geom/pathvector.h> #include <2geom/transforms.h> #include <2geom/convex-hull.h> +#include <2geom/svg-path-writer.h> #include <algorithm> #include <limits> @@ -689,14 +690,37 @@ Path Path::reversed() const { typedef std::reverse_iterator<Sequence::const_iterator> RIter; - Path ret; - ret._curves->pop_back(); // this also deletes the closing segment - RIter iter(_curves->end() - 1), rend(_curves->begin()); + Path ret(finalPoint()); + if (empty()) return ret; + + ret._curves->pop_back(); // this also deletes the closing segment from ret + + RIter iter(_includesClosingSegment() ? _curves->end() : _curves->end() - 1); + RIter rend(_curves->begin()); + + if (_closed) { + // when the path is closed, there are two cases: + BezierCurve const *iseg = dynamic_cast<BezierCurve const *>(&front()); + if (iseg && iseg->size() == 2) { + // 1. initial segment is linear: it becomes the new closing segment. + rend = RIter(_curves->begin() + 1); + ret._closing_seg = new ClosingSegment(iseg->finalPoint(), iseg->initialPoint()); + } else { + // 2. initial segment is not linear: the closing segment becomes degenerate. + // However, skip it if it's already degenerate. + Point fp = finalPoint(); + ret._closing_seg = new ClosingSegment(fp, fp); + } + } else { + // when the path is open, we reverse all real curves, and add a reversed closing segment. + ret._closing_seg = static_cast<ClosingSegment *>(_closing_seg->reverse()); + } + for (; iter != rend; ++iter) { ret._curves->push_back(iter->reverse()); } - ret._closing_seg = static_cast<ClosingSegment *>(_closing_seg->reverse()); ret._curves->push_back(ret._closing_seg); + ret._closed = _closed; return ret; } @@ -906,6 +930,14 @@ Piecewise<D2<SBasis> > paths_to_pw(PathVector const &paths) return ret; } +std::ostream &operator<<(std::ostream &out, Path const &path) +{ + SVGPathWriter pw; + pw.feed(path); + out << pw.str(); + return out; +} + } // end namespace Geom /* diff --git a/src/2geom/path.h b/src/2geom/path.h index 5a172f598..5340df0c5 100644 --- a/src/2geom/path.h +++ b/src/2geom/path.h @@ -402,6 +402,8 @@ public: * Since the curve always contains at least a degenerate closing segment, * it is always safe to use this method. */ Curve const &front() const { return _curves->front(); } + /// Alias for front(). + Curve const &initialCurve() const { return _curves->front(); } /** @brief Access the last curve in the path. */ Curve const &back() const { return back_default(); } Curve const &back_open() const { @@ -413,7 +415,12 @@ public: ? (*_curves)[_curves->size() - 2] : (*_curves)[_curves->size() - 1]; } - Curve const &back_default() const { return (_closed ? back_closed() : back_open()); } + Curve const &back_default() const { + return _includesClosingSegment() + ? back_closed() + : back_open(); + } + Curve const &finalCurve() const { return back_default(); } const_iterator begin() const { return const_iterator(*this, 0); } const_iterator end() const { return end_default(); } @@ -812,6 +819,8 @@ inline Coord nearest_time(Point const &p, Path const &c) { return pt.curve_index + pt.t; } +std::ostream &operator<<(std::ostream &out, Path const &path); + } // end namespace Geom |
