summaryrefslogtreecommitdiffstats
path: root/src/2geom/path.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2014-04-01 12:07:41 +0000
committerJabiertxof <jtx@jtx.marker.es>2014-04-01 12:07:41 +0000
commiteb773546cca0bdcd51039a5cc78826e3548c5a07 (patch)
treee9f0e1051de53958c6f4c317202ebf21adcdac7b /src/2geom/path.cpp
parentA refactor for fixing some issues. Pending how to handle static functions (diff)
parentpartial 2geom update: (diff)
downloadinkscape-eb773546cca0bdcd51039a5cc78826e3548c5a07.tar.gz
inkscape-eb773546cca0bdcd51039a5cc78826e3548c5a07.zip
update to trunk
(bzr r11950.1.324)
Diffstat (limited to 'src/2geom/path.cpp')
-rw-r--r--src/2geom/path.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/2geom/path.cpp b/src/2geom/path.cpp
index 93def6c55..5797f475c 100644
--- a/src/2geom/path.cpp
+++ b/src/2geom/path.cpp
@@ -35,9 +35,10 @@
#include <2geom/path.h>
+#include <2geom/transforms.h>
#include <algorithm>
-
+using std::swap;
using namespace Geom::PathInternal;
namespace Geom
@@ -102,10 +103,35 @@ Path &Path::operator*=(Affine const &m) {
return *this;
}
+Path &Path::operator*=(Translate const &m) {
+ unshare();
+ Sequence::iterator last = get_curves().end() - 1;
+ Sequence::iterator it;
+ Point prev;
+ for (it = get_curves().begin() ; it != last ; ++it) {
+ *(const_cast<Curve*>(&**it)) *= m;
+ if ( it != get_curves().begin() && (*it)->initialPoint() != prev ) {
+ THROW_CONTINUITYERROR();
+ }
+ prev = (*it)->finalPoint();
+ }
+ for ( int i = 0 ; i < 2 ; ++i ) {
+ final_->setPoint(i, (*final_)[i] + m.vector());
+ }
+ if (get_curves().size() > 1) {
+ if ( front().initialPoint() != initialPoint() || back().finalPoint() != finalPoint() ) {
+ THROW_CONTINUITYERROR();
+ }
+ }
+ return *this;
+}
+
std::vector<double>
Path::allNearestPoints(Point const& _point, double from, double to) const
{
- if ( from > to ) std::swap(from, to);
+ using std::swap;
+
+ if ( from > to ) swap(from, to);
const Path& _path = *this;
unsigned int sz = _path.size();
if ( _path.closed() ) ++sz;
@@ -215,7 +241,9 @@ Path::nearestPointPerCurve(Point const& _point) const
double Path::nearestPoint(Point const &_point, double from, double to, double *distance_squared) const
{
- if ( from > to ) std::swap(from, to);
+ using std::swap;
+
+ if ( from > to ) swap(from, to);
const Path& _path = *this;
unsigned int sz = _path.size();
if ( _path.closed() ) ++sz;