123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_COUNTING_HPP
- #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_COUNTING_HPP
- #include <cstddef>
- #include <boost/range/begin.hpp>
- #include <boost/range/end.hpp>
- #include <boost/geometry/core/exterior_ring.hpp>
- #include <boost/geometry/core/interior_rings.hpp>
- #include <boost/geometry/util/range.hpp>
- namespace boost { namespace geometry
- {
- #ifndef DOXYGEN_NO_DETAIL
- namespace detail { namespace counting
- {
- template <std::size_t D>
- struct other_count
- {
- template <typename Geometry>
- static inline std::size_t apply(Geometry const&)
- {
- return D;
- }
- template <typename Geometry>
- static inline std::size_t apply(Geometry const&, bool)
- {
- return D;
- }
- };
- template <typename RangeCount>
- struct polygon_count
- {
- template <typename Polygon>
- static inline std::size_t apply(Polygon const& poly)
- {
- std::size_t n = RangeCount::apply(exterior_ring(poly));
- auto const& rings = interior_rings(poly);
- for (auto it = boost::begin(rings); it != boost::end(rings); ++it)
- {
- n += RangeCount::apply(*it);
- }
- return n;
- }
- };
- template <typename SingleCount>
- struct multi_count
- {
- template <typename MultiGeometry>
- static inline std::size_t apply(MultiGeometry const& multi)
- {
- std::size_t n = 0;
- for (auto it = boost::begin(multi); it != boost::end(multi); ++it)
- {
- n += SingleCount::apply(*it);
- }
- return n;
- }
- };
- }}
- #endif
- }}
- #endif
|