diff --git a/include/boost/geometry/strategies/agnostic/hull_graham_andrew.hpp b/include/boost/geometry/strategies/agnostic/hull_graham_andrew.hpp index df72c21d7..79909906f 100644 --- a/include/boost/geometry/strategies/agnostic/hull_graham_andrew.hpp +++ b/include/boost/geometry/strategies/agnostic/hull_graham_andrew.hpp @@ -24,6 +24,7 @@ #include #include +#include // Temporary, comparing sorting, this can be removed in the end @@ -323,13 +324,13 @@ public: { if (clockwise) { - get_range_forward(state.m_upper_hull, out); - get_range_reverse(state.m_lower_hull, out); + output_range(state.m_upper_hull, out, false); + output_range(state.m_lower_hull, out, true); } else { - get_range_forward(state.m_lower_hull, out); - get_range_reverse(state.m_upper_hull, out); + output_range(state.m_lower_hull, out, false); + output_range(state.m_upper_hull, out, true); } } @@ -380,29 +381,24 @@ private: } - template - static inline void get_range_forward(container_type const& range, OutputIterator out) + template + static inline void output_range(container_type const& range, + OutputIterator out, bool skip_first) { - for (iterator it = boost::begin(range); - it != boost::end(range); - ++it, ++out) + typedef typename reversible_view::type view_type; + view_type view(range); + bool first = true; + for (typename boost::range_iterator::type it = boost::begin(view); + it != boost::end(view); ++it) { - *out = *it; - } - } - - - template - static inline void get_range_reverse(container_type const& range, OutputIterator out) - { - // STL Port does not accept iterating from rbegin+1 to rend - std::size_t size = range.size(); - if (size > 0) - { - rev_iterator it = range.rbegin() + 1; - for (std::size_t i = 1; i < size; ++i, ++it, ++out) + if (first && skip_first) + { + first = false; + } + else { *out = *it; + ++out; } } }