From 77969d41945123778eac90909ab97eb52794e7f7 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 4 Jun 2014 13:30:45 +0200 Subject: [PATCH] [buffer] merged implementations of side_on_convex_range --- .../buffer/side_on_convex_range.hpp | 51 ++++--------------- 1 file changed, 10 insertions(+), 41 deletions(-) diff --git a/include/boost/geometry/extensions/algorithms/buffer/side_on_convex_range.hpp b/include/boost/geometry/extensions/algorithms/buffer/side_on_convex_range.hpp index 9c58054b6..e8ff9e267 100644 --- a/include/boost/geometry/extensions/algorithms/buffer/side_on_convex_range.hpp +++ b/include/boost/geometry/extensions/algorithms/buffer/side_on_convex_range.hpp @@ -52,47 +52,6 @@ inline bool collinear_point_on_segment(P0 const& subject, P1 const& p1, P2 const } -template -inline int side_on_convex_range(Point const& subject, Range const& range) -{ - // TODO merge this implementation with next function with same name - if (boost::empty(range)) - { - return 1; - } - - bool has_collinear = false; - - typedef typename boost::range_iterator::type iterator_type; - - iterator_type it = boost::begin(range); - - Point previous = *it; - - for (++it; it != boost::end(range); ++it) - { - Point current = *it; - int const side = SideStrategy::apply(subject, previous, current); - switch(side) - { - case 1 : - return 1; - case 0 : - // Check if it is really on the segment. - // If not, it is either on the left (because polygon is convex) - // or it is still on one of the other segments (if segments are collinear) - if (collinear_point_on_segment(subject, previous, current)) - { - return 0; - } - has_collinear = true; - break; - } - previous = current; - } - return has_collinear ? 1 : -1; -} - template static inline int side_on_convex_range(Point const& subject, Iterator first, Iterator last, @@ -134,6 +93,16 @@ static inline int side_on_convex_range(Point const& subject, return has_collinear ? 1 : -1; } +template +inline int side_on_convex_range(Point const& subject, Range const& range) +{ + segment_identifier dummy; + return side_on_convex_range(subject, + boost::begin(range), boost::end(range), + dummy, dummy); +} + + }} // namespace detail::buffer #endif // DOXYGEN_NO_DETAIL