summaryrefslogtreecommitdiffstats
path: root/src/2geom/path.cpp
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2014-03-31 23:25:06 +0000
committerJohan B. C. Engelen <j.b.c.engelen@alumnus.utwente.nl>2014-03-31 23:25:06 +0000
commit04b06fe3ed0824c37cf65b425bf820d8b6f226a2 (patch)
treeed85a3f16e78220b3e3ae818296e08ee0b59cea4 /src/2geom/path.cpp
parent2geom: silence warning (diff)
downloadinkscape-04b06fe3ed0824c37cf65b425bf820d8b6f226a2.tar.gz
inkscape-04b06fe3ed0824c37cf65b425bf820d8b6f226a2.zip
partial 2geom update:
- main reason for update: better swap for Path (fixes C++11 warning/error) - faster implementation for Path * Translate (~6x), Inkscape's code has to be modified to use it though (bzr r13248)
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;