From 4e432e5960cb8bc9feb6648087b54788c774d773 Mon Sep 17 00:00:00 2001 From: MenTaLguY Date: Sun, 11 Mar 2007 21:23:04 +0000 Subject: Eliminate remaining sources of empty NR::Rects (bzr r2605) --- src/selection.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'src/selection.cpp') 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 Selection::getSnapPoints() const { std::vector Selection::getSnapPointsConvexHull() const { GSList const *items = const_cast(this)->itemList(); + std::vector p; for (GSList const *iter = items; iter != NULL; iter = iter->next) { sp_item_snappoints(SP_ITEM(iter->data), SnapPointsIter(p)); } - std::vector::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 pHull; + if (!p.empty()) { + std::vector::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 pHull(4); - pHull[0] = rHull.corner(0); - pHull[1] = rHull.corner(1); - pHull[2] = rHull.corner(2); - pHull[3] = rHull.corner(3); + NR::Maybe rHull = cvh.bounds(); + if (rHull) { + for ( unsigned i = 0 ; i < 4 ; ++i ) { + pHull.push_back(rHull->corner(i)); + } + } + } return pHull; } -- cgit v1.2.3