envelope_boxes.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Boost.Geometry
  2. // Copyright (c) 2021, Oracle and/or its affiliates.
  3. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  4. // Licensed under the Boost Software License version 1.0.
  5. // http://www.boost.org/users/license.html
  6. #ifndef BOOST_GEOMETRY_STRATEGY_SPHERICAL_ENVELOPE_BOXES_HPP
  7. #define BOOST_GEOMETRY_STRATEGY_SPHERICAL_ENVELOPE_BOXES_HPP
  8. #include <vector>
  9. #include <boost/geometry/algorithms/detail/envelope/initialize.hpp>
  10. #include <boost/geometry/algorithms/detail/envelope/range_of_boxes.hpp>
  11. namespace boost { namespace geometry
  12. {
  13. namespace strategy { namespace envelope
  14. {
  15. class spherical_boxes
  16. {
  17. public:
  18. template <typename Box>
  19. class state
  20. {
  21. friend spherical_boxes;
  22. std::vector<Box> m_boxes;
  23. };
  24. template <typename Box>
  25. static void apply(state<Box> & st, Box const& box)
  26. {
  27. st.m_boxes.push_back(box);
  28. }
  29. template <typename Box>
  30. static void result(state<Box> const& st, Box & box)
  31. {
  32. if (! st.m_boxes.empty())
  33. {
  34. geometry::detail::envelope::envelope_range_of_boxes::apply(st.m_boxes, box);
  35. }
  36. else
  37. {
  38. geometry::detail::envelope::initialize<Box, 0, dimension<Box>::value>::apply(box);
  39. }
  40. }
  41. };
  42. }} // namespace strategy::envelope
  43. }} //namepsace boost::geometry
  44. #endif // BOOST_GEOMETRY_STRATEGY_SPHERICAL_ENVELOPE_BOXES_HPP