Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 08:35:24

0001 // Boost.Geometry Index
0002 //
0003 // n-dimensional bounds
0004 //
0005 // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
0006 //
0007 // This file was modified by Oracle on 2019-2021.
0008 // Modifications copyright (c) 2019-2021 Oracle and/or its affiliates.
0009 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0010 //
0011 // Use, modification and distribution is subject to the Boost Software License,
0012 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0013 // http://www.boost.org/LICENSE_1_0.txt)
0014 
0015 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_BOUNDS_HPP
0016 #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_BOUNDS_HPP
0017 
0018 #include <boost/geometry/algorithms/convert.hpp>
0019 #include <boost/geometry/algorithms/detail/covered_by/interface.hpp>
0020 #include <boost/geometry/algorithms/detail/envelope/interface.hpp>
0021 #include <boost/geometry/algorithms/detail/expand/interface.hpp>
0022 
0023 #include <boost/geometry/index/detail/bounded_view.hpp>
0024 
0025 namespace boost { namespace geometry { namespace index { namespace detail
0026 {
0027 
0028 namespace dispatch
0029 {
0030 
0031 template
0032 <
0033     typename Geometry,
0034     typename Bounds,
0035     typename TagGeometry = geometry::tag_t<Geometry>,
0036     typename TagBounds = geometry::tag_t<Bounds>
0037 >
0038 struct bounds
0039 {
0040     template <typename Strategy>
0041     static inline void apply(Geometry const& g, Bounds & b, Strategy const& )
0042     {
0043         geometry::convert(g, b);
0044     }
0045 };
0046 
0047 template <typename Geometry, typename Bounds>
0048 struct bounds<Geometry, Bounds, segment_tag, box_tag>
0049 {
0050     template <typename Strategy>
0051     static inline void apply(Geometry const& g, Bounds & b, Strategy const& s)
0052     {
0053         index::detail::bounded_view<Geometry, Bounds, Strategy> v(g, s);
0054         geometry::convert(v, b);
0055     }
0056 };
0057 
0058 
0059 } // namespace dispatch
0060 
0061 
0062 template <typename Geometry, typename Bounds, typename Strategy>
0063 inline void bounds(Geometry const& g, Bounds & b, Strategy const& s)
0064 {
0065     concepts::check_concepts_and_equal_dimensions<Geometry const, Bounds>();
0066     dispatch::bounds<Geometry, Bounds>::apply(g, b, s);
0067 }
0068 
0069 
0070 namespace dispatch
0071 {
0072 
0073 template
0074 <
0075     typename Bounds,
0076     typename Geometry,
0077     typename TagBounds = geometry::tag_t<Bounds>,
0078     typename TagGeometry = geometry::tag_t<Geometry>
0079 >
0080 struct expand
0081 {
0082     // STATIC ASSERT
0083 };
0084 
0085 template <typename Bounds, typename Geometry>
0086 struct expand<Bounds, Geometry, box_tag, point_tag>
0087 {
0088     static inline void apply(Bounds & b, Geometry const& g)
0089     {
0090         geometry::expand(b, g);
0091     }
0092 
0093     template <typename Strategy>
0094     static inline void apply(Bounds & b, Geometry const& g, Strategy const& s)
0095     {
0096         geometry::expand(b, g, s);
0097     }
0098 };
0099 
0100 template <typename Bounds, typename Geometry>
0101 struct expand<Bounds, Geometry, box_tag, box_tag>
0102 {
0103     static inline void apply(Bounds & b, Geometry const& g)
0104     {
0105         geometry::expand(b, g);
0106     }
0107 
0108     template <typename Strategy>
0109     static inline void apply(Bounds & b, Geometry const& g, Strategy const& s)
0110     {
0111         geometry::expand(b, g, s);
0112     }
0113 };
0114 
0115 template <typename Bounds, typename Geometry>
0116 struct expand<Bounds, Geometry, box_tag, segment_tag>
0117 {
0118     static inline void apply(Bounds & b, Geometry const& g)
0119     {
0120         geometry::expand(b, g);
0121     }
0122 
0123     template <typename Strategy>
0124     static inline void apply(Bounds & b, Geometry const& g, Strategy const& s)
0125     {
0126         geometry::expand(b, geometry::return_envelope<Bounds>(g, s), s);
0127         // requires additional strategy
0128         //geometry::expand(b, g, s);
0129     }
0130 };
0131 
0132 
0133 } // namespace dispatch
0134 
0135 
0136 template <typename Bounds, typename Geometry, typename Strategy>
0137 inline void expand(Bounds & b, Geometry const& g, Strategy const& s)
0138 {
0139     dispatch::expand<Bounds, Geometry>::apply(b, g, s);
0140 }
0141 
0142 template <typename Bounds, typename Geometry>
0143 inline void expand(Bounds & b, Geometry const& g, default_strategy const& )
0144 {
0145     dispatch::expand<Bounds, Geometry>::apply(b, g);
0146 }
0147 
0148 
0149 namespace dispatch
0150 {
0151 
0152 
0153 template
0154 <
0155     typename Geometry,
0156     typename Bounds,
0157     typename TagGeometry = geometry::tag_t<Geometry>,
0158     typename TagBounds = geometry::tag_t<Bounds>
0159 >
0160 struct covered_by_bounds
0161 {};
0162 
0163 template <typename Geometry, typename Bounds>
0164 struct covered_by_bounds<Geometry, Bounds, point_tag, box_tag>
0165 {
0166     static inline bool apply(Geometry const& g, Bounds & b)
0167     {
0168         return geometry::covered_by(g, b);
0169     }
0170 
0171     template <typename Strategy>
0172     static inline bool apply(Geometry const& g, Bounds & b, Strategy const& s)
0173     {
0174         return geometry::covered_by(g, b, s);
0175     }
0176 };
0177 
0178 template <typename Geometry, typename Bounds>
0179 struct covered_by_bounds<Geometry, Bounds, box_tag, box_tag>
0180 {
0181     static inline bool apply(Geometry const& g, Bounds & b)
0182     {
0183         return geometry::covered_by(g, b);
0184     }
0185 
0186     template <typename Strategy>
0187     static inline bool apply(Geometry const& g, Bounds & b, Strategy const& s)
0188     {
0189         return geometry::covered_by(g, b, s);
0190     }
0191 };
0192 
0193 template <typename Geometry, typename Bounds>
0194 struct covered_by_bounds<Geometry, Bounds, segment_tag, box_tag>
0195 {
0196     static inline bool apply(Geometry const& g, Bounds & b)
0197     {
0198         using point_type = point_type_t<Geometry>;
0199         using bounds_type = geometry::model::box<point_type>;
0200         using view_type = index::detail::bounded_view<Geometry, bounds_type, default_strategy>;
0201 
0202         return geometry::covered_by(view_type(g, default_strategy()), b);
0203     }
0204 
0205     template <typename Strategy>
0206     static inline bool apply(Geometry const& g, Bounds & b, Strategy const& strategy)
0207     {
0208         using point_type = point_type_t<Geometry>;
0209         using bounds_type = geometry::model::box<point_type>;
0210         using view_type = index::detail::bounded_view<Geometry, bounds_type, Strategy>;
0211 
0212         return geometry::covered_by(view_type(g, strategy), b, strategy);
0213     }
0214 };
0215 
0216 
0217 } // namespace dispatch
0218 
0219 
0220 template <typename Geometry, typename Bounds, typename Strategy>
0221 inline bool covered_by_bounds(Geometry const& g, Bounds & b, Strategy const& s)
0222 {
0223     return dispatch::covered_by_bounds<Geometry, Bounds>::apply(g, b, s);
0224 }
0225 
0226 template <typename Geometry, typename Bounds>
0227 inline bool covered_by_bounds(Geometry const& g, Bounds & b, default_strategy const& )
0228 {
0229     return dispatch::covered_by_bounds<Geometry, Bounds>::apply(g, b);
0230 }
0231 
0232 
0233 }}}} // namespace boost::geometry::index::detail
0234 
0235 
0236 #endif // BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_BOUNDS_HPP