summaryrefslogtreecommitdiffstats
path: root/src/2geom/path.cpp
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2008-06-14 15:01:19 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2008-06-14 15:01:19 +0000
commit4289e1281e707090b4195dcb879cf1532d9ef03a (patch)
tree6128d36f89e544e0670a6197f91715dd99e92391 /src/2geom/path.cpp
parentfixed another typo (diff)
downloadinkscape-4289e1281e707090b4195dcb879cf1532d9ef03a.tar.gz
inkscape-4289e1281e707090b4195dcb879cf1532d9ef03a.zip
update 2geom
(bzr r5931)
Diffstat (limited to 'src/2geom/path.cpp')
-rw-r--r--src/2geom/path.cpp57
1 files changed, 55 insertions, 2 deletions
diff --git a/src/2geom/path.cpp b/src/2geom/path.cpp
index 35c7b76bc..0ff1f3b0c 100644
--- a/src/2geom/path.cpp
+++ b/src/2geom/path.cpp
@@ -50,8 +50,11 @@ void Path::swap(Path &other) {
Rect Path::boundsFast() const {
Rect bounds=front().boundsFast();
- for ( const_iterator iter=++begin(); iter != end() ; ++iter ) {
- bounds.unionWith(iter->boundsFast());
+ const_iterator iter = begin();
+ if ( iter != end() ) {
+ for ( ++iter; iter != end() ; ++iter ) {
+ bounds.unionWith(iter->boundsFast());
+ }
}
return bounds;
}
@@ -236,6 +239,56 @@ double Path::nearestPoint(Point const& _point, double from, double to) const
return ni + nearest;
}
+Rect Path::boundsFast()
+{
+ Rect bound;
+ if (empty()) return bound;
+
+ bound = begin()->boundsFast();
+ double top = bound.top();
+ double bottom = bound.bottom();
+ double left = bound.left();
+ double right = bound.right();
+ for (iterator it = ++begin(); it != end(); ++it)
+ {
+ bound = it->boundsFast();
+ if ( top > bound.top() ) top = bound.top();
+ if ( bottom < bound.bottom() ) bottom = bound.bottom();
+ if ( left > bound.left() ) left = bound.left();
+ if ( right < bound.right() ) right = bound.right();
+ }
+ bound[0][0] = left;
+ bound[0][1] = right;
+ bound[1][0] = top;
+ bound[1][1] = bottom;
+ return bound;
+}
+
+Rect Path::boundsExact()
+{
+ Rect bound;
+ if (empty()) return bound;
+
+ bound = begin()->boundsExact();
+ double top = bound.top();
+ double bottom = bound.bottom();
+ double left = bound.left();
+ double right = bound.right();
+ for (iterator it = ++begin(); it != end(); ++it)
+ {
+ bound = it->boundsExact();
+ if ( top > bound.top() ) top = bound.top();
+ if ( bottom < bound.bottom() ) bottom = bound.bottom();
+ if ( left > bound.left() ) left = bound.left();
+ if ( right < bound.right() ) right = bound.right();
+ }
+ bound[0][0] = left;
+ bound[0][1] = right;
+ bound[1][0] = top;
+ bound[1][1] = bottom;
+ return bound;
+}
+
//This assumes that you can't be perfect in your t-vals, and as such, tweaks the start
void Path::appendPortionTo(Path &ret, double from, double to) const {
assert(from >= 0 && to >= 0);