File indexing completed on 2025-01-18 09:35:28
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_CONTENT_HPP
0017 #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_CONTENT_HPP
0018
0019 #include <boost/geometry/core/access.hpp>
0020 #include <boost/geometry/core/coordinate_dimension.hpp>
0021 #include <boost/geometry/core/coordinate_type.hpp>
0022 #include <boost/geometry/core/static_assert.hpp>
0023 #include <boost/geometry/core/tag.hpp>
0024 #include <boost/geometry/core/tags.hpp>
0025 #include <boost/geometry/util/select_most_precise.hpp>
0026
0027 namespace boost { namespace geometry { namespace index { namespace detail {
0028
0029 template <typename Indexable>
0030 struct default_content_result
0031 {
0032 using type = typename select_most_precise
0033 <
0034 typename coordinate_type<Indexable>::type,
0035 double
0036 >::type;
0037 };
0038
0039 namespace dispatch {
0040
0041 template <typename Box,
0042 std::size_t CurrentDimension = dimension<Box>::value>
0043 struct content_box
0044 {
0045 BOOST_STATIC_ASSERT(0 < CurrentDimension);
0046
0047 static inline typename detail::default_content_result<Box>::type apply(Box const& b)
0048 {
0049 return content_box<Box, CurrentDimension - 1>::apply(b) *
0050 ( get<max_corner, CurrentDimension - 1>(b) - get<min_corner, CurrentDimension - 1>(b) );
0051 }
0052 };
0053
0054 template <typename Box>
0055 struct content_box<Box, 1>
0056 {
0057 static inline typename detail::default_content_result<Box>::type apply(Box const& b)
0058 {
0059 return get<max_corner, 0>(b) - get<min_corner, 0>(b);
0060 }
0061 };
0062
0063 template <typename Indexable, typename Tag>
0064 struct content
0065 {
0066 BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
0067 "Not implemented for this Indexable and Tag.",
0068 Indexable, Tag);
0069 };
0070
0071 template <typename Indexable>
0072 struct content<Indexable, point_tag>
0073 {
0074 static typename detail::default_content_result<Indexable>::type apply(Indexable const&)
0075 {
0076 return 0;
0077 }
0078 };
0079
0080 template <typename Indexable>
0081 struct content<Indexable, box_tag>
0082 {
0083 static typename default_content_result<Indexable>::type apply(Indexable const& b)
0084 {
0085 return dispatch::content_box<Indexable>::apply(b);
0086 }
0087 };
0088
0089 }
0090
0091 template <typename Indexable>
0092 typename default_content_result<Indexable>::type content(Indexable const& b)
0093 {
0094 return dispatch::content
0095 <
0096 Indexable,
0097 typename tag<Indexable>::type
0098 >::apply(b);
0099 }
0100
0101 }}}}
0102
0103 #endif