initialize.hpp 2.3 KB

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