range.hpp 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. // This file was modified by Oracle on 2015-2021.
  6. // Modifications copyright (c) 2015-2021, Oracle and/or its affiliates.
  7. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  8. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  9. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  10. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  11. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  12. // Distributed under the Boost Software License, Version 1.0.
  13. // (See accompanying file LICENSE_1_0.txt or copy at
  14. // http://www.boost.org/LICENSE_1_0.txt)
  15. #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_RANGE_HPP
  16. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_RANGE_HPP
  17. #include <iterator>
  18. #include <vector>
  19. #include <boost/range/begin.hpp>
  20. #include <boost/range/end.hpp>
  21. #include <boost/geometry/algorithms/is_empty.hpp>
  22. #include <boost/geometry/algorithms/detail/dummy_geometries.hpp>
  23. #include <boost/geometry/algorithms/detail/envelope/initialize.hpp>
  24. #include <boost/geometry/algorithms/detail/expand/box.hpp>
  25. #include <boost/geometry/algorithms/detail/expand/point.hpp>
  26. #include <boost/geometry/algorithms/detail/expand/segment.hpp>
  27. #include <boost/geometry/core/coordinate_dimension.hpp>
  28. namespace boost { namespace geometry
  29. {
  30. #ifndef DOXYGEN_NO_DETAIL
  31. namespace detail { namespace envelope
  32. {
  33. // implementation for simple ranges
  34. struct envelope_range
  35. {
  36. template <typename Range, typename Box, typename Strategies>
  37. static inline void apply(Range const& range, Box& mbr, Strategies const& strategies)
  38. {
  39. strategies.envelope(range, mbr).apply(range, mbr);
  40. }
  41. };
  42. // implementation for multi-ranges
  43. template <typename EnvelopePolicy>
  44. struct envelope_multi_range
  45. {
  46. template <typename MultiRange, typename Box, typename Strategies>
  47. static inline void apply(MultiRange const& multirange,
  48. Box& mbr,
  49. Strategies const& strategies)
  50. {
  51. using strategy_t = decltype(strategies.envelope(multirange, mbr));
  52. apply<strategy_t>(multirange, mbr, strategies);
  53. }
  54. template <typename Strategy, typename MultiRange, typename Box, typename Strategies>
  55. static inline void apply(MultiRange const& multirange,
  56. Box& mbr,
  57. Strategies const& strategies)
  58. {
  59. typename Strategy::template state<Box> state;
  60. auto const end = boost::end(multirange);
  61. for (auto it = boost::begin(multirange); it != end; ++it)
  62. {
  63. if (! geometry::is_empty(*it))
  64. {
  65. Box helper_mbr;
  66. EnvelopePolicy::apply(*it, helper_mbr, strategies);
  67. Strategy::apply(state, helper_mbr);
  68. }
  69. }
  70. Strategy::result(state, mbr);
  71. }
  72. };
  73. }} // namespace detail::envelope
  74. #endif // DOXYGEN_NO_DETAIL
  75. }} // namespace boost::geometry
  76. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_RANGE_HPP