1 // Boost.Geometry Index
3 // n-dimensional content (hypervolume) - 2d area, 3d volume, ...
5 // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_CONTENT_HPP
12 #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_CONTENT_HPP
14 namespace boost { namespace geometry { namespace index { namespace detail {
16 template <typename Indexable>
17 struct default_content_result
19 typedef typename select_most_precise<
20 typename coordinate_type<Indexable>::type,
27 template <typename Box,
28 std::size_t CurrentDimension = dimension<Box>::value>
31 BOOST_STATIC_ASSERT(0 < CurrentDimension);
33 static inline typename detail::default_content_result<Box>::type apply(Box const& b)
35 return content_box<Box, CurrentDimension - 1>::apply(b) *
36 ( get<max_corner, CurrentDimension - 1>(b) - get<min_corner, CurrentDimension - 1>(b) );
40 template <typename Box>
41 struct content_box<Box, 1>
43 static inline typename detail::default_content_result<Box>::type apply(Box const& b)
45 return get<max_corner, 0>(b) - get<min_corner, 0>(b);
49 template <typename Indexable, typename Tag>
52 BOOST_MPL_ASSERT_MSG(false, NOT_IMPLEMENTED_FOR_THIS_INDEXABLE_AND_TAG, (Indexable, Tag));
55 template <typename Indexable>
56 struct content<Indexable, point_tag>
58 static typename detail::default_content_result<Indexable>::type apply(Indexable const&)
64 template <typename Indexable>
65 struct content<Indexable, box_tag>
67 static typename default_content_result<Indexable>::type apply(Indexable const& b)
69 return dispatch::content_box<Indexable>::apply(b);
73 } // namespace dispatch
75 template <typename Indexable>
76 typename default_content_result<Indexable>::type content(Indexable const& b)
78 return dispatch::content
81 typename tag<Indexable>::type
85 }}}} // namespace boost::geometry::index::detail
87 #endif // BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_CONTENT_HPP