From 05138b08023eba970974aaff97a8238ae8f6b8d9 Mon Sep 17 00:00:00 2001 From: Panagiotis Cheilaris Date: Fri, 31 Jan 2014 14:34:42 +0100 Subject: [PATCH] bug fix for convex hull Anderson variant example The previous version did not output the last point of the convex hull to the result iterator. As a result, ch_graham_anderson.cpp did not output a correct convex hull in some cases. --- .../examples/Convex_hull_2/ch_graham_anderson.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Convex_hull_2/examples/Convex_hull_2/ch_graham_anderson.cpp b/Convex_hull_2/examples/Convex_hull_2/ch_graham_anderson.cpp index a63e5c63865..53b1ea97b5e 100644 --- a/Convex_hull_2/examples/Convex_hull_2/ch_graham_anderson.cpp +++ b/Convex_hull_2/examples/Convex_hull_2/ch_graham_anderson.cpp @@ -24,12 +24,13 @@ ch_graham_anderson( InputIterator first, InputIterator beyond, typename std::vector< Point_2 >::iterator it = std::min_element(V.begin(), V.end(), Less_xy_2()); std::sort( V.begin(), V.end(), boost::bind(Less_rotate_ccw_2(), *it, _1, _2) ); - if ( *(V.begin()) == *(V.rbegin()) ) + if ( *(V.begin()) != *(V.rbegin()) ) { - *result = *(V.begin()); ++result; - return result; + result = CGAL::ch_graham_andrew_scan( V.begin(), V.end(), result, ch_traits); } - return CGAL::ch_graham_andrew_scan( V.begin(), V.end(), result, ch_traits); + *result = *(V.rbegin()); ++result; + return result; + } int main()