Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:10:39

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
0004 // Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
0005 // Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
0006 
0007 // This file was modified by Oracle on 2014-2020.
0008 // Modifications copyright (c) 2014-2020, Oracle and/or its affiliates.
0009 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
0010 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0011 
0012 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
0013 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
0014 
0015 // Use, modification and distribution is subject to the Boost Software License,
0016 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0017 // http://www.boost.org/LICENSE_1_0.txt)
0018 
0019 
0020 #ifndef BOOST_GEOMETRY_ALGORITHMS_NUM_GEOMETRIES_HPP
0021 #define BOOST_GEOMETRY_ALGORITHMS_NUM_GEOMETRIES_HPP
0022 
0023 #include <cstddef>
0024 
0025 #include <boost/range/size.hpp>
0026 
0027 #include <boost/variant/apply_visitor.hpp>
0028 #include <boost/variant/static_visitor.hpp>
0029 #include <boost/variant/variant_fwd.hpp>
0030 
0031 #include <boost/geometry/algorithms/not_implemented.hpp>
0032 
0033 #include <boost/geometry/core/tag.hpp>
0034 #include <boost/geometry/core/tags.hpp>
0035 #include <boost/geometry/core/tag_cast.hpp>
0036 
0037 #include <boost/geometry/geometries/concepts/check.hpp>
0038 
0039 #include <boost/geometry/algorithms/detail/counting.hpp>
0040 
0041 
0042 namespace boost { namespace geometry
0043 {
0044 
0045 
0046 #ifndef DOXYGEN_NO_DISPATCH
0047 namespace dispatch
0048 {
0049 
0050 
0051 template
0052 <
0053     typename Geometry,
0054     typename Tag = typename tag_cast
0055                             <
0056                                 typename tag<Geometry>::type,
0057                                 single_tag,
0058                                 multi_tag
0059                             >::type
0060 >
0061 struct num_geometries: not_implemented<Tag>
0062 {};
0063 
0064 
0065 template <typename Geometry>
0066 struct num_geometries<Geometry, single_tag>
0067     : detail::counting::other_count<1>
0068 {};
0069 
0070 
0071 template <typename MultiGeometry>
0072 struct num_geometries<MultiGeometry, multi_tag>
0073 {
0074     static inline std::size_t apply(MultiGeometry const& multi_geometry)
0075     {
0076         return boost::size(multi_geometry);
0077     }
0078 };
0079 
0080 
0081 } // namespace dispatch
0082 #endif // DOXYGEN_NO_DISPATCH
0083 
0084 
0085 namespace resolve_variant
0086 {
0087 
0088 template <typename Geometry>
0089 struct num_geometries
0090 {
0091     static inline std::size_t apply(Geometry const& geometry)
0092     {
0093         concepts::check<Geometry const>();
0094 
0095         return dispatch::num_geometries<Geometry>::apply(geometry);
0096     }
0097 };
0098 
0099 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
0100 struct num_geometries<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
0101 {
0102     struct visitor: boost::static_visitor<std::size_t>
0103     {
0104         template <typename Geometry>
0105         inline std::size_t operator()(Geometry const& geometry) const
0106         {
0107             return num_geometries<Geometry>::apply(geometry);
0108         }
0109     };
0110 
0111     static inline std::size_t
0112     apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry)
0113     {
0114         return boost::apply_visitor(visitor(), geometry);
0115     }
0116 };
0117 
0118 } // namespace resolve_variant
0119 
0120 
0121 /*!
0122 \brief \brief_calc{number of geometries}
0123 \ingroup num_geometries
0124 \details \details_calc{num_geometries, number of geometries}.
0125 \tparam Geometry \tparam_geometry
0126 \param geometry \param_geometry
0127 \return \return_calc{number of geometries}
0128 
0129 \qbk{[include reference/algorithms/num_geometries.qbk]}
0130 */
0131 template <typename Geometry>
0132 inline std::size_t num_geometries(Geometry const& geometry)
0133 {
0134     return resolve_variant::num_geometries<Geometry>::apply(geometry);
0135 }
0136 
0137 
0138 }} // namespace boost::geometry
0139 
0140 
0141 #endif // BOOST_GEOMETRY_ALGORITHMS_NUM_GEOMETRIES_HPP