diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-07-24 23:26:11 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-07-24 23:26:11 +0000 |
| commit | 7b6ffd82650ee1e20a53b0631d5c2dddef58e8d5 (patch) | |
| tree | 48cae26bf789b11d79f72efc16a6676f960eaaa6 /src/display/curve.cpp | |
| parent | update to trunk (diff) | |
| parent | 3D box tool: the shift key must not prevent snapping of the vanishing point. ... (diff) | |
| download | inkscape-7b6ffd82650ee1e20a53b0631d5c2dddef58e8d5.tar.gz inkscape-7b6ffd82650ee1e20a53b0631d5c2dddef58e8d5.zip | |
update to trunk
(bzr r12588.1.45)
Diffstat (limited to 'src/display/curve.cpp')
| -rw-r--r-- | src/display/curve.cpp | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/src/display/curve.cpp b/src/display/curve.cpp index 54a62939d..3024d1276 100644 --- a/src/display/curve.cpp +++ b/src/display/curve.cpp @@ -31,14 +31,12 @@ SPCurve::SPCurve() : _refcount(1), _pathv() -{ -} +{} SPCurve::SPCurve(Geom::PathVector const& pathv) : _refcount(1), _pathv(pathv) -{ -} +{} SPCurve * SPCurve::new_from_rect(Geom::Rect const &rect, bool all_four_sides) @@ -90,13 +88,7 @@ SPCurve::get_pathvector() const size_t SPCurve::get_segment_count() const { - size_t nr = 0; - for(Geom::PathVector::const_iterator it = _pathv.begin(); it != _pathv.end(); ++it) { - nr += (*it).size(); - - if (it->closed()) nr += 1; - } - return nr; + return _pathv.curveCount(); } /** @@ -211,8 +203,9 @@ SPCurve::moveto(double x, double y) void SPCurve::moveto(Geom::Point const &p) { - _pathv.push_back( Geom::Path() ); // for some reason Geom::Path(p) does not work... - _pathv.back().start(p); + Geom::Path path(p); + path.setStitching(true); + _pathv.push_back(path); } /** @@ -476,7 +469,7 @@ SPCurve::last_point() const SPCurve * SPCurve::create_reverse() const { - SPCurve *new_curve = new SPCurve(Geom::reverse_paths_and_order(_pathv)); + SPCurve *new_curve = new SPCurve(_pathv.reversed()); return new_curve; } @@ -635,20 +628,10 @@ SPCurve::nodes_in_path() const { size_t nr = 0; for(Geom::PathVector::const_iterator it = _pathv.begin(); it != _pathv.end(); ++it) { - nr += (*it).size(); - - nr++; // count last node (this works also for closed paths because although they don't have a 'last node', they do have an extra segment - - // do not count closing knot double for zero-length closing line segments - // however, if the path is only a moveto, and is closed, do not subtract 1 (otherwise the result will be zero nodes) - if ( it->closed() - && ((*it).size() != 0) ) - { - Geom::Curve const &c = it->back_closed(); - if (are_near(c.initialPoint(), c.finalPoint())) { - nr--; - } - } + // if the path does not have any segments, it is a naked moveto, + // and therefore any path has at least one valid node + size_t psize = std::max<size_t>(1, it->size_closed()); + nr += psize; } return nr; |
