Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:28

0001 // Boost.Geometry Index
0002 //
0003 // n-dimensional content (hypervolume) - 2d area, 3d volume, ...
0004 //
0005 // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
0006 //
0007 // This file was modified by Oracle on 2020-2023.
0008 // Modifications copyright (c) 2020-2023 Oracle and/or its affiliates.
0009 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
0010 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0011 //
0012 // Use, modification and distribution is subject to the Boost Software License,
0013 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0014 // http://www.boost.org/LICENSE_1_0.txt)
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 } // namespace dispatch
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 }}}} // namespace boost::geometry::index::detail
0102 
0103 #endif // BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_CONTENT_HPP