1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 3 // Copyright (c) 2015, Oracle and/or its affiliates. 4 5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle 6 7 // Distributed under the Boost Software License, Version 1.0. 8 // (See accompanying file LICENSE_1_0.txt or copy at 9 // http://www.boost.org/LICENSE_1_0.txt) 10 11 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_INITIALIZE_HPP 12 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_INITIALIZE_HPP 13 14 #include <cstddef> 15 16 #include <boost/numeric/conversion/bounds.hpp> 17 18 #include <boost/geometry/core/access.hpp> 19 #include <boost/geometry/core/coordinate_dimension.hpp> 20 #include <boost/geometry/core/coordinate_type.hpp> 21 22 23 namespace boost { namespace geometry 24 { 25 26 #ifndef DOXYGEN_NO_DETAIL 27 namespace detail { namespace envelope 28 { 29 30 template <std::size_t Dimension, std::size_t DimensionCount> 31 struct initialize_loop 32 { 33 template <typename Box, typename CoordinateType> applyboost::geometry::detail::envelope::initialize_loop34 static inline void apply(Box& box, 35 CoordinateType min_value, 36 CoordinateType max_value) 37 { 38 geometry::set<min_corner, Dimension>(box, min_value); 39 geometry::set<max_corner, Dimension>(box, max_value); 40 41 initialize_loop 42 < 43 Dimension + 1, DimensionCount 44 >::apply(box, min_value, max_value); 45 } 46 }; 47 48 template <std::size_t DimensionCount> 49 struct initialize_loop<DimensionCount, DimensionCount> 50 { 51 template <typename Box, typename CoordinateType> applyboost::geometry::detail::envelope::initialize_loop52 static inline void apply(Box&, CoordinateType, CoordinateType) 53 { 54 } 55 }; 56 57 58 template 59 < 60 typename Box, 61 std::size_t Dimension = 0, 62 std::size_t DimensionCount = dimension<Box>::value 63 > 64 struct initialize 65 { 66 typedef typename coordinate_type<Box>::type coordinate_type; 67 applyboost::geometry::detail::envelope::initialize68 static inline void apply(Box& box, 69 coordinate_type min_value 70 = boost::numeric::bounds<coordinate_type>::highest(), 71 coordinate_type max_value 72 = boost::numeric::bounds<coordinate_type>::lowest()) 73 { 74 initialize_loop 75 < 76 Dimension, DimensionCount 77 >::apply(box, min_value, max_value); 78 } 79 }; 80 81 }} // namespace detail::envelope 82 #endif // DOXYGEN_NO_DETAIL 83 84 }} // namespace boost::geometry 85 86 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_INITIALIZE_HPP 87