123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- #ifndef BOOST_GEOMETRY_ALGORITHMS_NUM_INTERIOR_RINGS_HPP
- #define BOOST_GEOMETRY_ALGORITHMS_NUM_INTERIOR_RINGS_HPP
- #include <cstddef>
- #include <boost/range/size.hpp>
- #include <boost/range/value_type.hpp>
- #include <boost/variant/apply_visitor.hpp>
- #include <boost/variant/static_visitor.hpp>
- #include <boost/variant/variant_fwd.hpp>
- #include <boost/geometry/core/tag.hpp>
- #include <boost/geometry/core/tags.hpp>
- #include <boost/geometry/core/interior_rings.hpp>
- #include <boost/geometry/algorithms/detail/counting.hpp>
- #include <boost/geometry/geometries/concepts/check.hpp>
- namespace boost { namespace geometry
- {
- #ifndef DOXYGEN_NO_DISPATCH
- namespace dispatch
- {
- template <typename Geometry, typename Tag = typename tag<Geometry>::type>
- struct num_interior_rings
- : detail::counting::other_count<0>
- {};
- template <typename Polygon>
- struct num_interior_rings<Polygon, polygon_tag>
- {
- static inline std::size_t apply(Polygon const& polygon)
- {
- return boost::size(geometry::interior_rings(polygon));
- }
- };
- template <typename MultiPolygon>
- struct num_interior_rings<MultiPolygon, multi_polygon_tag>
- : detail::counting::multi_count
- <
- num_interior_rings
- <
- typename boost::range_value<MultiPolygon const>::type
- >
- >
- {};
- }
- #endif
- namespace resolve_variant
- {
- template <typename Geometry>
- struct num_interior_rings
- {
- static inline std::size_t apply(Geometry const& geometry)
- {
- concepts::check<Geometry const>();
- return dispatch::num_interior_rings<Geometry>::apply(geometry);
- }
- };
- template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
- struct num_interior_rings<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
- {
- struct visitor: boost::static_visitor<std::size_t>
- {
- template <typename Geometry>
- inline std::size_t operator()(Geometry const& geometry) const
- {
- return num_interior_rings<Geometry>::apply(geometry);
- }
- };
- static inline std::size_t
- apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry)
- {
- return boost::apply_visitor(visitor(), geometry);
- }
- };
- }
- template <typename Geometry>
- inline std::size_t num_interior_rings(Geometry const& geometry)
- {
- return resolve_variant::num_interior_rings<Geometry>::apply(geometry);
- }
- }}
- #endif
|