1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 3 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. 4 // Copyright (c) 2008-2015 Bruno Lalande, Paris, France. 5 // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. 6 // Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France. 7 8 // This file was modified by Oracle on 2015, 2016. 9 // Modifications copyright (c) 2015-2016, Oracle and/or its affiliates. 10 11 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle 12 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle 13 14 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library 15 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. 16 17 // Distributed under the Boost Software License, Version 1.0. 18 // (See accompanying file LICENSE_1_0.txt or copy at 19 // http://www.boost.org/LICENSE_1_0.txt) 20 21 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INDEXED_HPP 22 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INDEXED_HPP 23 24 #include <cstddef> 25 26 #include <boost/geometry/core/access.hpp> 27 #include <boost/geometry/core/tags.hpp> 28 29 #include <boost/geometry/util/select_coordinate_type.hpp> 30 31 #include <boost/geometry/strategies/compare.hpp> 32 #include <boost/geometry/policies/compare.hpp> 33 34 #include <boost/geometry/algorithms/dispatch/expand.hpp> 35 36 37 namespace boost { namespace geometry 38 { 39 40 #ifndef DOXYGEN_NO_DETAIL 41 namespace detail { namespace expand 42 { 43 44 45 template 46 < 47 typename StrategyLess, typename StrategyGreater, 48 std::size_t Index, 49 std::size_t Dimension, std::size_t DimensionCount 50 > 51 struct indexed_loop 52 { 53 template <typename Box, typename Geometry, typename Strategy> applyboost::geometry::detail::expand::indexed_loop54 static inline void apply(Box& box, Geometry const& source, Strategy const& strategy) 55 { 56 typedef typename strategy::compare::detail::select_strategy 57 < 58 StrategyLess, 1, Box, Dimension 59 >::type less_type; 60 61 typedef typename strategy::compare::detail::select_strategy 62 < 63 StrategyGreater, -1, Box, Dimension 64 >::type greater_type; 65 66 typedef typename select_coordinate_type 67 < 68 Box, 69 Geometry 70 >::type coordinate_type; 71 72 less_type less; 73 greater_type greater; 74 75 coordinate_type const coord = get<Index, Dimension>(source); 76 77 if (less(coord, get<min_corner, Dimension>(box))) 78 { 79 set<min_corner, Dimension>(box, coord); 80 } 81 82 if (greater(coord, get<max_corner, Dimension>(box))) 83 { 84 set<max_corner, Dimension>(box, coord); 85 } 86 87 indexed_loop 88 < 89 StrategyLess, StrategyGreater, 90 Index, Dimension + 1, DimensionCount 91 >::apply(box, source, strategy); 92 } 93 }; 94 95 96 template 97 < 98 typename StrategyLess, typename StrategyGreater, 99 std::size_t Index, std::size_t DimensionCount 100 > 101 struct indexed_loop 102 < 103 StrategyLess, StrategyGreater, 104 Index, DimensionCount, DimensionCount 105 > 106 { 107 template <typename Box, typename Geometry, typename Strategy> applyboost::geometry::detail::expand::indexed_loop108 static inline void apply(Box&, Geometry const&, Strategy const&) {} 109 }; 110 111 112 113 // Changes a box such that the other box is also contained by the box 114 template 115 < 116 std::size_t Dimension, std::size_t DimensionCount, 117 typename StrategyLess, typename StrategyGreater 118 > 119 struct expand_indexed 120 { 121 template <typename Box, typename Geometry, typename Strategy> applyboost::geometry::detail::expand::expand_indexed122 static inline void apply(Box& box, 123 Geometry const& geometry, 124 Strategy const& strategy) 125 { 126 indexed_loop 127 < 128 StrategyLess, StrategyGreater, 129 0, Dimension, DimensionCount 130 >::apply(box, geometry, strategy); 131 132 indexed_loop 133 < 134 StrategyLess, StrategyGreater, 135 1, Dimension, DimensionCount 136 >::apply(box, geometry, strategy); 137 } 138 }; 139 140 141 }} // namespace detail::expand 142 #endif // DOXYGEN_NO_DETAIL 143 144 145 }} // namespace boost::geometry 146 147 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INDEXED_HPP 148