annotate DEPENDENCIES/generic/include/boost/geometry/index/detail/algorithms/content.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 // Boost.Geometry Index
Chris@16 2 //
Chris@16 3 // n-dimensional content (hypervolume) - 2d area, 3d volume, ...
Chris@16 4 //
Chris@101 5 // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
Chris@16 6 //
Chris@16 7 // Use, modification and distribution is subject to the Boost Software License,
Chris@16 8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 9 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 10
Chris@16 11 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_CONTENT_HPP
Chris@16 12 #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_CONTENT_HPP
Chris@16 13
Chris@16 14 namespace boost { namespace geometry { namespace index { namespace detail {
Chris@16 15
Chris@16 16 template <typename Indexable>
Chris@16 17 struct default_content_result
Chris@16 18 {
Chris@16 19 typedef typename select_most_precise<
Chris@16 20 typename coordinate_type<Indexable>::type,
Chris@16 21 long double
Chris@16 22 >::type type;
Chris@16 23 };
Chris@16 24
Chris@16 25 namespace dispatch {
Chris@16 26
Chris@101 27 template <typename Box,
Chris@101 28 std::size_t CurrentDimension = dimension<Box>::value>
Chris@16 29 struct content_box
Chris@16 30 {
Chris@16 31 BOOST_STATIC_ASSERT(0 < CurrentDimension);
Chris@16 32
Chris@16 33 static inline typename detail::default_content_result<Box>::type apply(Box const& b)
Chris@16 34 {
Chris@16 35 return content_box<Box, CurrentDimension - 1>::apply(b) *
Chris@16 36 ( get<max_corner, CurrentDimension - 1>(b) - get<min_corner, CurrentDimension - 1>(b) );
Chris@16 37 }
Chris@16 38 };
Chris@16 39
Chris@16 40 template <typename Box>
Chris@16 41 struct content_box<Box, 1>
Chris@16 42 {
Chris@16 43 static inline typename detail::default_content_result<Box>::type apply(Box const& b)
Chris@16 44 {
Chris@16 45 return get<max_corner, 0>(b) - get<min_corner, 0>(b);
Chris@16 46 }
Chris@16 47 };
Chris@16 48
Chris@16 49 template <typename Indexable, typename Tag>
Chris@16 50 struct content
Chris@16 51 {
Chris@16 52 BOOST_MPL_ASSERT_MSG(false, NOT_IMPLEMENTED_FOR_THIS_INDEXABLE_AND_TAG, (Indexable, Tag));
Chris@16 53 };
Chris@16 54
Chris@16 55 template <typename Indexable>
Chris@16 56 struct content<Indexable, point_tag>
Chris@16 57 {
Chris@16 58 static typename detail::default_content_result<Indexable>::type apply(Indexable const&)
Chris@16 59 {
Chris@16 60 return 0;
Chris@16 61 }
Chris@16 62 };
Chris@16 63
Chris@16 64 template <typename Indexable>
Chris@16 65 struct content<Indexable, box_tag>
Chris@16 66 {
Chris@16 67 static typename default_content_result<Indexable>::type apply(Indexable const& b)
Chris@16 68 {
Chris@101 69 return dispatch::content_box<Indexable>::apply(b);
Chris@16 70 }
Chris@16 71 };
Chris@16 72
Chris@16 73 } // namespace dispatch
Chris@16 74
Chris@16 75 template <typename Indexable>
Chris@16 76 typename default_content_result<Indexable>::type content(Indexable const& b)
Chris@16 77 {
Chris@101 78 return dispatch::content
Chris@101 79 <
Chris@101 80 Indexable,
Chris@101 81 typename tag<Indexable>::type
Chris@101 82 >::apply(b);
Chris@16 83 }
Chris@16 84
Chris@16 85 }}}} // namespace boost::geometry::index::detail
Chris@16 86
Chris@16 87 #endif // BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_CONTENT_HPP