From 4289e1281e707090b4195dcb879cf1532d9ef03a Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 14 Jun 2008 15:01:19 +0000 Subject: update 2geom (bzr r5931) --- src/2geom/path.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) (limited to 'src/2geom/path.cpp') 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); -- cgit v1.2.3