expand_point.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
  5. // Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France.
  6. // This file was modified by Oracle on 2015-2018.
  7. // Modifications copyright (c) 2015-2018, Oracle and/or its affiliates.
  8. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  9. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  10. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  11. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  12. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  13. // Distributed under the Boost Software License, Version 1.0.
  14. // (See accompanying file LICENSE_1_0.txt or copy at
  15. // http://www.boost.org/LICENSE_1_0.txt)
  16. #ifndef BOOST_GEOMETRY_STRATEGY_CARTESIAN_EXPAND_POINT_HPP
  17. #define BOOST_GEOMETRY_STRATEGY_CARTESIAN_EXPAND_POINT_HPP
  18. #include <cstddef>
  19. #include <functional>
  20. #include <boost/geometry/core/access.hpp>
  21. #include <boost/geometry/core/coordinate_dimension.hpp>
  22. #include <boost/geometry/core/coordinate_system.hpp>
  23. #include <boost/geometry/core/coordinate_type.hpp>
  24. #include <boost/geometry/core/tags.hpp>
  25. #include <boost/geometry/util/select_coordinate_type.hpp>
  26. #include <boost/geometry/strategy/expand.hpp>
  27. namespace boost { namespace geometry
  28. {
  29. namespace strategy { namespace expand
  30. {
  31. #ifndef DOXYGEN_NO_DETAIL
  32. namespace detail
  33. {
  34. template <std::size_t Dimension, std::size_t DimensionCount>
  35. struct point_loop
  36. {
  37. template <typename Box, typename Point>
  38. static inline void apply(Box& box, Point const& source)
  39. {
  40. typedef typename select_coordinate_type
  41. <
  42. Point, Box
  43. >::type coordinate_type;
  44. std::less<coordinate_type> less;
  45. std::greater<coordinate_type> greater;
  46. coordinate_type const coord = get<Dimension>(source);
  47. if (less(coord, get<min_corner, Dimension>(box)))
  48. {
  49. set<min_corner, Dimension>(box, coord);
  50. }
  51. if (greater(coord, get<max_corner, Dimension>(box)))
  52. {
  53. set<max_corner, Dimension>(box, coord);
  54. }
  55. point_loop<Dimension + 1, DimensionCount>::apply(box, source);
  56. }
  57. };
  58. template <std::size_t DimensionCount>
  59. struct point_loop<DimensionCount, DimensionCount>
  60. {
  61. template <typename Box, typename Point>
  62. static inline void apply(Box&, Point const&) {}
  63. };
  64. } // namespace detail
  65. #endif // DOXYGEN_NO_DETAIL
  66. struct cartesian_point
  67. {
  68. template <typename Box, typename Point>
  69. static void apply(Box & box, Point const& point)
  70. {
  71. expand::detail::point_loop
  72. <
  73. 0, dimension<Point>::value
  74. >::apply(box, point);
  75. }
  76. };
  77. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  78. namespace services
  79. {
  80. template <typename CalculationType>
  81. struct default_strategy<point_tag, cartesian_tag, CalculationType>
  82. {
  83. typedef cartesian_point type;
  84. };
  85. } // namespace services
  86. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  87. }} // namespace strategy::expand
  88. }} // namespace boost::geometry
  89. #endif // BOOST_GEOMETRY_STRATEGY_CARTESIAN_EXPAND_POINT_HPP