envelope_box.hpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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-2019.
  6. // Modifications copyright (c) 2015-2019, 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. // Distributed under the Boost Software License, Version 1.0.
  11. // (See accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. #ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_BOX_HPP
  14. #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_BOX_HPP
  15. #include <cstddef>
  16. #include <boost/geometry/core/access.hpp>
  17. #include <boost/geometry/core/coordinate_dimension.hpp>
  18. #include <boost/geometry/core/tags.hpp>
  19. #include <boost/geometry/views/detail/indexed_point_view.hpp>
  20. #include <boost/geometry/algorithms/detail/convert_point_to_point.hpp>
  21. #include <boost/geometry/algorithms/detail/normalize.hpp>
  22. #include <boost/geometry/algorithms/detail/envelope/transform_units.hpp>
  23. #include <boost/geometry/algorithms/dispatch/envelope.hpp>
  24. #include <boost/geometry/strategies/cartesian/expand_box.hpp>
  25. #include <boost/geometry/strategies/envelope.hpp>
  26. namespace boost { namespace geometry
  27. {
  28. #ifndef DOXYGEN_NO_DETAIL
  29. namespace detail { namespace envelope
  30. {
  31. template
  32. <
  33. std::size_t Index,
  34. std::size_t Dimension,
  35. std::size_t DimensionCount
  36. >
  37. struct envelope_indexed_box
  38. {
  39. template <typename BoxIn, typename BoxOut>
  40. static inline void apply(BoxIn const& box_in, BoxOut& mbr)
  41. {
  42. detail::indexed_point_view<BoxIn const, Index> box_in_corner(box_in);
  43. detail::indexed_point_view<BoxOut, Index> mbr_corner(mbr);
  44. detail::conversion::point_to_point
  45. <
  46. detail::indexed_point_view<BoxIn const, Index>,
  47. detail::indexed_point_view<BoxOut, Index>,
  48. Dimension,
  49. DimensionCount
  50. >::apply(box_in_corner, mbr_corner);
  51. }
  52. };
  53. }} // namespace detail::envelope
  54. #endif // DOXYGEN_NO_DETAIL
  55. namespace strategy { namespace envelope
  56. {
  57. struct cartesian_box
  58. {
  59. typedef cartesian_tag cs_tag;
  60. typedef strategy::expand::cartesian_box box_expand_strategy_type;
  61. static inline box_expand_strategy_type get_box_expand_strategy()
  62. {
  63. return box_expand_strategy_type();
  64. }
  65. template<typename BoxIn, typename BoxOut>
  66. static inline void apply(BoxIn const& box_in, BoxOut& mbr)
  67. {
  68. geometry::detail::envelope::envelope_indexed_box
  69. <
  70. min_corner, 0, dimension<BoxIn>::value
  71. >::apply(box_in, mbr);
  72. geometry::detail::envelope::envelope_indexed_box
  73. <
  74. max_corner, 0, dimension<BoxIn>::value
  75. >::apply(box_in, mbr);
  76. }
  77. };
  78. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  79. namespace services
  80. {
  81. template <typename CalculationType>
  82. struct default_strategy<box_tag, cartesian_tag, CalculationType>
  83. {
  84. typedef strategy::envelope::cartesian_box type;
  85. };
  86. }
  87. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  88. }} // namespace strategy::envelope
  89. }} // namespace boost::geometry
  90. #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_BOX_HPP