summaryrefslogtreecommitdiffstats
path: root/src/display/curve.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-07-24 19:53:33 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-07-24 19:53:33 +0000
commit5a37f06c70e0e4e2519812564f4dcdced7c0246a (patch)
treef959f73813cb6f968072aee1100323b24e294136 /src/display/curve.cpp
parentupdate to trunk (diff)
parentFix a bug continuing a bezier path whith a LPE one like spiro or bspline on a... (diff)
downloadinkscape-5a37f06c70e0e4e2519812564f4dcdced7c0246a.tar.gz
inkscape-5a37f06c70e0e4e2519812564f4dcdced7c0246a.zip
update to trunk
(bzr r13879.1.17)
Diffstat (limited to 'src/display/curve.cpp')
-rw-r--r--src/display/curve.cpp39
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;