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.
This commit is contained in:
Panagiotis Cheilaris 2014-01-31 14:34:42 +01:00
parent 8f18eb46f9
commit 05138b0802
1 changed files with 5 additions and 4 deletions

View File

@ -24,12 +24,13 @@ ch_graham_anderson( InputIterator first, InputIterator beyond,
typename std::vector< Point_2 >::iterator it = typename std::vector< Point_2 >::iterator it =
std::min_element(V.begin(), V.end(), Less_xy_2()); 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) ); 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; result = CGAL::ch_graham_andrew_scan( V.begin(), V.end(), result, ch_traits);
return result;
} }
return CGAL::ch_graham_andrew_scan( V.begin(), V.end(), result, ch_traits); *result = *(V.rbegin()); ++result;
return result;
} }
int main() int main()