From 7be65c1fbca9b81324f392cd5fb73dbcd300a385 Mon Sep 17 00:00:00 2001 From: Bruno Lalande Date: Sun, 28 Oct 2012 19:08:35 +0000 Subject: [PATCH] Made dispatch::num_points able to find the tag by itself + used not_implemented. [SVN r81075] --- .../boost/geometry/algorithms/num_points.hpp | 65 +++++++++---------- .../geometry/multi/algorithms/num_points.hpp | 12 ++-- 2 files changed, 34 insertions(+), 43 deletions(-) diff --git a/include/boost/geometry/algorithms/num_points.hpp b/include/boost/geometry/algorithms/num_points.hpp index c480068f4..e5a7aef6d 100644 --- a/include/boost/geometry/algorithms/num_points.hpp +++ b/include/boost/geometry/algorithms/num_points.hpp @@ -16,7 +16,6 @@ #include -#include #include #include @@ -27,6 +26,7 @@ #include #include +#include #include @@ -38,9 +38,9 @@ namespace detail { namespace num_points { -template struct range_count { + template static inline std::size_t apply(Range const& range, bool add_for_open) { std::size_t n = boost::size(range); @@ -60,30 +60,31 @@ struct range_count } }; -template +template struct other_count { + template static inline std::size_t apply(Geometry const&, bool) { return D; } }; -template -struct polygon_count +struct polygon_count: private range_count { + template static inline std::size_t apply(Polygon const& poly, bool add_for_open) { typedef typename geometry::ring_type::type ring_type; - std::size_t n = range_count::apply( + std::size_t n = range_count::apply( exterior_ring(poly), add_for_open); typename interior_return_type::type rings = interior_rings(poly); for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it) { - n += range_count::apply(*it, add_for_open); + n += range_count::apply(*it, add_for_open); } return n; @@ -98,44 +99,42 @@ struct polygon_count namespace dispatch { -template -struct num_points -{ - BOOST_MPL_ASSERT_MSG - ( - false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE - , (types) - ); -}; - -template -struct num_points - : detail::num_points::other_count +template +< + typename Geometry, + typename Tag = typename tag_cast::type, multi_tag>::type +> +struct num_points: not_implemented {}; template -struct num_points - : detail::num_points::other_count +struct num_points + : detail::num_points::other_count<1> {}; template -struct num_points - : detail::num_points::other_count +struct num_points + : detail::num_points::other_count<4> {}; template -struct num_points - : detail::num_points::range_count +struct num_points + : detail::num_points::other_count<2> {}; template -struct num_points - : detail::num_points::range_count +struct num_points + : detail::num_points::range_count {}; template -struct num_points - : detail::num_points::polygon_count +struct num_points + : detail::num_points::range_count +{}; + +template +struct num_points + : detail::num_points::polygon_count {}; } // namespace dispatch @@ -158,11 +157,7 @@ inline std::size_t num_points(Geometry const& geometry, bool add_for_open = fals { concept::check(); - return dispatch::num_points - < - typename tag_cast::type, multi_tag>::type, - Geometry - >::apply(geometry, add_for_open); + return dispatch::num_points::apply(geometry, add_for_open); } }} // namespace boost::geometry diff --git a/include/boost/geometry/multi/algorithms/num_points.hpp b/include/boost/geometry/multi/algorithms/num_points.hpp index 5ea53854e..1cc82b2f0 100644 --- a/include/boost/geometry/multi/algorithms/num_points.hpp +++ b/include/boost/geometry/multi/algorithms/num_points.hpp @@ -30,9 +30,9 @@ namespace detail { namespace num_points { -template struct multi_count { + template static inline size_t apply(MultiGeometry const& geometry, bool add_for_open) { typedef typename boost::range_value::type geometry_type; @@ -46,11 +46,7 @@ struct multi_count it != boost::end(geometry); ++it) { - n += dispatch::num_points - < - typename tag::type, - geometry_type - >::apply(*it, add_for_open); + n += dispatch::num_points::apply(*it, add_for_open); } return n; } @@ -67,8 +63,8 @@ namespace dispatch template -struct num_points - : detail::num_points::multi_count {}; +struct num_points + : detail::num_points::multi_count {}; } // namespace dispatch