envelope_box.hpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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-2020.
  6. // Modifications copyright (c) 2015-2020, 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_STRATEGY_CARTESIAN_ENVELOPE_BOX_HPP
  14. #define BOOST_GEOMETRY_STRATEGY_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/strategy/cartesian/expand_box.hpp>
  25. #include <boost/geometry/strategy/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. template<typename BoxIn, typename BoxOut>
  61. static inline void apply(BoxIn const& box_in, BoxOut& mbr)
  62. {
  63. geometry::detail::envelope::envelope_indexed_box
  64. <
  65. min_corner, 0, dimension<BoxIn>::value
  66. >::apply(box_in, mbr);
  67. geometry::detail::envelope::envelope_indexed_box
  68. <
  69. max_corner, 0, dimension<BoxIn>::value
  70. >::apply(box_in, mbr);
  71. }
  72. };
  73. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  74. namespace services
  75. {
  76. template <typename CalculationType>
  77. struct default_strategy<box_tag, cartesian_tag, CalculationType>
  78. {
  79. typedef strategy::envelope::cartesian_box type;
  80. };
  81. }
  82. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  83. }} // namespace strategy::envelope
  84. }} // namespace boost::geometry
  85. #endif // BOOST_GEOMETRY_STRATEGY_CARTESIAN_ENVELOPE_BOX_HPP