diff options
| author | MenTaLguY <mental@rydia.net> | 2007-03-11 21:23:04 +0000 |
|---|---|---|
| committer | mental <mental@users.sourceforge.net> | 2007-03-11 21:23:04 +0000 |
| commit | 4e432e5960cb8bc9feb6648087b54788c774d773 (patch) | |
| tree | f83b7730dfb4ff96d45fb96e83367ab3dc28e56f /src/selection.cpp | |
| parent | Switch selection bounds and center to use NR::Maybe, addressing most of the (diff) | |
| download | inkscape-4e432e5960cb8bc9feb6648087b54788c774d773.tar.gz inkscape-4e432e5960cb8bc9feb6648087b54788c774d773.zip | |
Eliminate remaining sources of empty NR::Rects
(bzr r2605)
Diffstat (limited to 'src/selection.cpp')
| -rw-r--r-- | src/selection.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/selection.cpp b/src/selection.cpp index c6b307c3b..201661eec 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -380,24 +380,28 @@ std::vector<NR::Point> Selection::getSnapPoints() const { std::vector<NR::Point> Selection::getSnapPointsConvexHull() const { GSList const *items = const_cast<Selection *>(this)->itemList(); + std::vector<NR::Point> p; for (GSList const *iter = items; iter != NULL; iter = iter->next) { sp_item_snappoints(SP_ITEM(iter->data), SnapPointsIter(p)); } - std::vector<NR::Point>::iterator i; - NR::ConvexHull cvh(*(p.begin())); - for (i = p.begin(); i != p.end(); i++) { - // these are the points we get back - cvh.add(*i); - } + std::vector<NR::Point> pHull; + if (!p.empty()) { + std::vector<NR::Point>::iterator i; + NR::ConvexHull cvh(p.front()); + for (i = p.begin(); i != p.end(); i++) { + // these are the points we get back + cvh.add(*i); + } - NR::Rect rHull = cvh.bounds(); - std::vector<NR::Point> pHull(4); - pHull[0] = rHull.corner(0); - pHull[1] = rHull.corner(1); - pHull[2] = rHull.corner(2); - pHull[3] = rHull.corner(3); + NR::Maybe<NR::Rect> rHull = cvh.bounds(); + if (rHull) { + for ( unsigned i = 0 ; i < 4 ; ++i ) { + pHull.push_back(rHull->corner(i)); + } + } + } return pHull; } |
