envelope_boxes.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_CARTESIAN_ENVELOPE_BOXES_HPP
  7. #define BOOST_GEOMETRY_STRATEGY_CARTESIAN_ENVELOPE_BOXES_HPP
  8. #include <boost/geometry/algorithms/detail/envelope/initialize.hpp>
  9. #include <boost/geometry/strategy/cartesian/expand_box.hpp>
  10. namespace boost { namespace geometry
  11. {
  12. namespace strategy { namespace envelope
  13. {
  14. class cartesian_boxes
  15. {
  16. public:
  17. template <typename Box>
  18. class state
  19. {
  20. friend cartesian_boxes;
  21. Box m_box;
  22. bool m_initialized = false;
  23. };
  24. template <typename Box>
  25. static void apply(state<Box> & st, Box const& box)
  26. {
  27. if (! st.m_initialized)
  28. {
  29. st.m_box = box;
  30. st.m_initialized = true;
  31. }
  32. else
  33. {
  34. strategy::expand::cartesian_box::apply(st.m_box, box);
  35. }
  36. }
  37. template <typename Box>
  38. static void result(state<Box> const& st, Box & box)
  39. {
  40. if (st.m_initialized)
  41. {
  42. box = st.m_box;
  43. }
  44. else
  45. {
  46. geometry::detail::envelope::initialize<Box, 0, dimension<Box>::value>::apply(box);
  47. }
  48. }
  49. };
  50. }} // namespace strategy::envelope
  51. }} //namepsace boost::geometry
  52. #endif // BOOST_GEOMETRY_STRATEGY_CARTESIAN_ENVELOPE_BOXES_HPP