Chris@16
|
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
|
Chris@16
|
2
|
Chris@101
|
3 // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
|
Chris@101
|
4 // Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
|
Chris@101
|
5 // Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
|
Chris@101
|
6
|
Chris@101
|
7 // This file was modified by Oracle on 2014.
|
Chris@101
|
8 // Modifications copyright (c) 2014, Oracle and/or its affiliates.
|
Chris@101
|
9
|
Chris@101
|
10 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
Chris@16
|
11
|
Chris@16
|
12 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
Chris@16
|
13 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
Chris@16
|
14
|
Chris@16
|
15 // Use, modification and distribution is subject to the Boost Software License,
|
Chris@16
|
16 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
17 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
18
|
Chris@16
|
19
|
Chris@16
|
20 #ifndef BOOST_GEOMETRY_ALGORITHMS_NUM_GEOMETRIES_HPP
|
Chris@16
|
21 #define BOOST_GEOMETRY_ALGORITHMS_NUM_GEOMETRIES_HPP
|
Chris@16
|
22
|
Chris@16
|
23 #include <cstddef>
|
Chris@16
|
24
|
Chris@101
|
25 #include <boost/range.hpp>
|
Chris@101
|
26
|
Chris@101
|
27 #include <boost/variant/apply_visitor.hpp>
|
Chris@101
|
28 #include <boost/variant/static_visitor.hpp>
|
Chris@101
|
29 #include <boost/variant/variant_fwd.hpp>
|
Chris@101
|
30
|
Chris@16
|
31 #include <boost/geometry/algorithms/not_implemented.hpp>
|
Chris@16
|
32
|
Chris@16
|
33 #include <boost/geometry/core/tag.hpp>
|
Chris@16
|
34 #include <boost/geometry/core/tags.hpp>
|
Chris@16
|
35 #include <boost/geometry/core/tag_cast.hpp>
|
Chris@16
|
36
|
Chris@16
|
37 #include <boost/geometry/geometries/concepts/check.hpp>
|
Chris@16
|
38
|
Chris@101
|
39 #include <boost/geometry/algorithms/detail/counting.hpp>
|
Chris@101
|
40
|
Chris@16
|
41
|
Chris@16
|
42 namespace boost { namespace geometry
|
Chris@16
|
43 {
|
Chris@16
|
44
|
Chris@16
|
45
|
Chris@16
|
46 #ifndef DOXYGEN_NO_DISPATCH
|
Chris@16
|
47 namespace dispatch
|
Chris@16
|
48 {
|
Chris@16
|
49
|
Chris@16
|
50
|
Chris@16
|
51 template
|
Chris@16
|
52 <
|
Chris@16
|
53 typename Geometry,
|
Chris@16
|
54 typename Tag = typename tag_cast
|
Chris@16
|
55 <
|
Chris@16
|
56 typename tag<Geometry>::type,
|
Chris@16
|
57 single_tag,
|
Chris@16
|
58 multi_tag
|
Chris@16
|
59 >::type
|
Chris@16
|
60 >
|
Chris@16
|
61 struct num_geometries: not_implemented<Tag>
|
Chris@16
|
62 {};
|
Chris@16
|
63
|
Chris@16
|
64
|
Chris@16
|
65 template <typename Geometry>
|
Chris@16
|
66 struct num_geometries<Geometry, single_tag>
|
Chris@101
|
67 : detail::counting::other_count<1>
|
Chris@101
|
68 {};
|
Chris@101
|
69
|
Chris@101
|
70
|
Chris@101
|
71 template <typename MultiGeometry>
|
Chris@101
|
72 struct num_geometries<MultiGeometry, multi_tag>
|
Chris@16
|
73 {
|
Chris@101
|
74 static inline std::size_t apply(MultiGeometry const& multi_geometry)
|
Chris@16
|
75 {
|
Chris@101
|
76 return boost::size(multi_geometry);
|
Chris@16
|
77 }
|
Chris@16
|
78 };
|
Chris@16
|
79
|
Chris@16
|
80
|
Chris@101
|
81 } // namespace dispatch
|
Chris@101
|
82 #endif // DOXYGEN_NO_DISPATCH
|
Chris@16
|
83
|
Chris@101
|
84
|
Chris@101
|
85 namespace resolve_variant
|
Chris@101
|
86 {
|
Chris@101
|
87
|
Chris@101
|
88 template <typename Geometry>
|
Chris@101
|
89 struct num_geometries
|
Chris@101
|
90 {
|
Chris@101
|
91 static inline std::size_t apply(Geometry const& geometry)
|
Chris@101
|
92 {
|
Chris@101
|
93 concept::check<Geometry const>();
|
Chris@101
|
94
|
Chris@101
|
95 return dispatch::num_geometries<Geometry>::apply(geometry);
|
Chris@101
|
96 }
|
Chris@101
|
97 };
|
Chris@101
|
98
|
Chris@101
|
99 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
|
Chris@101
|
100 struct num_geometries<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
|
Chris@101
|
101 {
|
Chris@101
|
102 struct visitor: boost::static_visitor<std::size_t>
|
Chris@101
|
103 {
|
Chris@101
|
104 template <typename Geometry>
|
Chris@101
|
105 inline std::size_t operator()(Geometry const& geometry) const
|
Chris@101
|
106 {
|
Chris@101
|
107 return num_geometries<Geometry>::apply(geometry);
|
Chris@101
|
108 }
|
Chris@101
|
109 };
|
Chris@101
|
110
|
Chris@101
|
111 static inline std::size_t
|
Chris@101
|
112 apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry)
|
Chris@101
|
113 {
|
Chris@101
|
114 return boost::apply_visitor(visitor(), geometry);
|
Chris@101
|
115 }
|
Chris@101
|
116 };
|
Chris@101
|
117
|
Chris@101
|
118 } // namespace resolve_variant
|
Chris@16
|
119
|
Chris@16
|
120
|
Chris@16
|
121 /*!
|
Chris@16
|
122 \brief \brief_calc{number of geometries}
|
Chris@16
|
123 \ingroup num_geometries
|
Chris@16
|
124 \details \details_calc{num_geometries, number of geometries}.
|
Chris@16
|
125 \tparam Geometry \tparam_geometry
|
Chris@16
|
126 \param geometry \param_geometry
|
Chris@16
|
127 \return \return_calc{number of geometries}
|
Chris@16
|
128
|
Chris@16
|
129 \qbk{[include reference/algorithms/num_geometries.qbk]}
|
Chris@16
|
130 */
|
Chris@16
|
131 template <typename Geometry>
|
Chris@16
|
132 inline std::size_t num_geometries(Geometry const& geometry)
|
Chris@16
|
133 {
|
Chris@101
|
134 return resolve_variant::num_geometries<Geometry>::apply(geometry);
|
Chris@16
|
135 }
|
Chris@16
|
136
|
Chris@16
|
137
|
Chris@16
|
138 }} // namespace boost::geometry
|
Chris@16
|
139
|
Chris@16
|
140
|
Chris@16
|
141 #endif // BOOST_GEOMETRY_ALGORITHMS_NUM_GEOMETRIES_HPP
|