num_points.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  6. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  7. // Use, modification and distribution is subject to the Boost Software License,
  8. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_NUM_POINTS_HPP
  11. #define BOOST_GEOMETRY_MULTI_ALGORITHMS_NUM_POINTS_HPP
  12. #include <boost/range.hpp>
  13. #include <boost/geometry/multi/core/tags.hpp>
  14. #include <boost/geometry/multi/geometries/concepts/check.hpp>
  15. #include <boost/geometry/algorithms/num_points.hpp>
  16. namespace boost { namespace geometry
  17. {
  18. #ifndef DOXYGEN_NO_DETAIL
  19. namespace detail { namespace num_points
  20. {
  21. struct multi_count
  22. {
  23. template <typename MultiGeometry>
  24. static inline size_t apply(MultiGeometry const& geometry, bool add_for_open)
  25. {
  26. typedef typename boost::range_value<MultiGeometry>::type geometry_type;
  27. typedef typename boost::range_iterator
  28. <
  29. MultiGeometry const
  30. >::type iterator_type;
  31. std::size_t n = 0;
  32. for (iterator_type it = boost::begin(geometry);
  33. it != boost::end(geometry);
  34. ++it)
  35. {
  36. n += dispatch::num_points<geometry_type>::apply(*it, add_for_open);
  37. }
  38. return n;
  39. }
  40. };
  41. }} // namespace detail::num_points
  42. #endif
  43. #ifndef DOXYGEN_NO_DISPATCH
  44. namespace dispatch
  45. {
  46. template <typename Geometry>
  47. struct num_points<Geometry, multi_tag>
  48. : detail::num_points::multi_count {};
  49. } // namespace dispatch
  50. #endif
  51. }} // namespace boost::geometry
  52. #endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_NUM_POINTS_HPP