envelope_box.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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-2018.
  6. // Modifications copyright (c) 2015-2018, 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/envelope.hpp>
  25. namespace boost { namespace geometry
  26. {
  27. #ifndef DOXYGEN_NO_DETAIL
  28. namespace detail { namespace envelope
  29. {
  30. template
  31. <
  32. std::size_t Index,
  33. std::size_t Dimension,
  34. std::size_t DimensionCount
  35. >
  36. struct envelope_indexed_box
  37. {
  38. template <typename BoxIn, typename BoxOut>
  39. static inline void apply(BoxIn const& box_in, BoxOut& mbr)
  40. {
  41. detail::indexed_point_view<BoxIn const, Index> box_in_corner(box_in);
  42. detail::indexed_point_view<BoxOut, Index> mbr_corner(mbr);
  43. detail::conversion::point_to_point
  44. <
  45. detail::indexed_point_view<BoxIn const, Index>,
  46. detail::indexed_point_view<BoxOut, Index>,
  47. Dimension,
  48. DimensionCount
  49. >::apply(box_in_corner, mbr_corner);
  50. }
  51. };
  52. }} // namespace detail::envelope
  53. #endif // DOXYGEN_NO_DETAIL
  54. namespace strategy { namespace envelope
  55. {
  56. struct cartesian_box
  57. {
  58. template<typename BoxIn, typename BoxOut>
  59. static inline void apply(BoxIn const& box_in, BoxOut& mbr)
  60. {
  61. geometry::detail::envelope::envelope_indexed_box
  62. <
  63. min_corner, 0, dimension<BoxIn>::value
  64. >::apply(box_in, mbr);
  65. geometry::detail::envelope::envelope_indexed_box
  66. <
  67. max_corner, 0, dimension<BoxIn>::value
  68. >::apply(box_in, mbr);
  69. }
  70. };
  71. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  72. namespace services
  73. {
  74. template <typename CalculationType>
  75. struct default_strategy<box_tag, cartesian_tag, CalculationType>
  76. {
  77. typedef strategy::envelope::cartesian_box type;
  78. };
  79. }
  80. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  81. }} // namespace strategy::envelope
  82. }} // namespace boost::geometry
  83. #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_ENVELOPE_BOX_HPP