Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/geometry/index/detail/algorithms/content.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 // Boost.Geometry Index | |
2 // | |
3 // n-dimensional content (hypervolume) - 2d area, 3d volume, ... | |
4 // | |
5 // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. | |
6 // | |
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) | |
10 | |
11 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_CONTENT_HPP | |
12 #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_CONTENT_HPP | |
13 | |
14 namespace boost { namespace geometry { namespace index { namespace detail { | |
15 | |
16 template <typename Indexable> | |
17 struct default_content_result | |
18 { | |
19 typedef typename select_most_precise< | |
20 typename coordinate_type<Indexable>::type, | |
21 long double | |
22 >::type type; | |
23 }; | |
24 | |
25 namespace dispatch { | |
26 | |
27 template <typename Box, size_t CurrentDimension> | |
28 struct content_box | |
29 { | |
30 BOOST_STATIC_ASSERT(0 < CurrentDimension); | |
31 //BOOST_STATIC_ASSERT(CurrentDimension <= traits::dimension<Box>::value); | |
32 | |
33 static inline typename detail::default_content_result<Box>::type apply(Box const& b) | |
34 { | |
35 return content_box<Box, CurrentDimension - 1>::apply(b) * | |
36 ( get<max_corner, CurrentDimension - 1>(b) - get<min_corner, CurrentDimension - 1>(b) ); | |
37 } | |
38 }; | |
39 | |
40 template <typename Box> | |
41 struct content_box<Box, 1> | |
42 { | |
43 static inline typename detail::default_content_result<Box>::type apply(Box const& b) | |
44 { | |
45 return get<max_corner, 0>(b) - get<min_corner, 0>(b); | |
46 } | |
47 }; | |
48 | |
49 template <typename Indexable, typename Tag> | |
50 struct content | |
51 { | |
52 BOOST_MPL_ASSERT_MSG(false, NOT_IMPLEMENTED_FOR_THIS_INDEXABLE_AND_TAG, (Indexable, Tag)); | |
53 }; | |
54 | |
55 template <typename Indexable> | |
56 struct content<Indexable, point_tag> | |
57 { | |
58 static typename detail::default_content_result<Indexable>::type apply(Indexable const&) | |
59 { | |
60 return 0; | |
61 } | |
62 }; | |
63 | |
64 template <typename Indexable> | |
65 struct content<Indexable, box_tag> | |
66 { | |
67 static typename default_content_result<Indexable>::type apply(Indexable const& b) | |
68 { | |
69 return dispatch::content_box<Indexable, dimension<Indexable>::value>::apply(b); | |
70 } | |
71 }; | |
72 | |
73 } // namespace dispatch | |
74 | |
75 template <typename Indexable> | |
76 typename default_content_result<Indexable>::type content(Indexable const& b) | |
77 { | |
78 return dispatch::content<Indexable, | |
79 typename tag<Indexable>::type | |
80 >::apply(b); | |
81 } | |
82 | |
83 }}}} // namespace boost::geometry::index::detail | |
84 | |
85 #endif // BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_CONTENT_HPP |