interface.hpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. // Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France.
  6. // This file was modified by Oracle on 2015-2021.
  7. // Modifications copyright (c) 2015-2021, Oracle and/or its affiliates.
  8. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  9. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  10. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  11. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  12. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  13. // Distributed under the Boost Software License, Version 1.0.
  14. // (See accompanying file LICENSE_1_0.txt or copy at
  15. // http://www.boost.org/LICENSE_1_0.txt)
  16. #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INTERFACE_HPP
  17. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INTERFACE_HPP
  18. #include <boost/geometry/algorithms/dispatch/expand.hpp>
  19. #include <boost/geometry/core/coordinate_system.hpp>
  20. #include <boost/geometry/core/tag.hpp>
  21. #include <boost/geometry/core/tags.hpp>
  22. #include <boost/geometry/core/visit.hpp>
  23. #include <boost/geometry/geometries/adapted/boost_variant.hpp> // For backward compatibility
  24. #include <boost/geometry/geometries/concepts/check.hpp>
  25. #include <boost/geometry/strategies/default_strategy.hpp>
  26. #include <boost/geometry/strategies/detail.hpp>
  27. #include <boost/geometry/strategies/expand/services.hpp>
  28. #include <boost/geometry/util/type_traits_std.hpp>
  29. namespace boost { namespace geometry
  30. {
  31. namespace resolve_strategy
  32. {
  33. template
  34. <
  35. typename Strategy,
  36. bool IsUmbrella = strategies::detail::is_umbrella_strategy<Strategy>::value
  37. >
  38. struct expand
  39. {
  40. template <typename Box, typename Geometry>
  41. static inline void apply(Box& box,
  42. Geometry const& geometry,
  43. Strategy const& strategy)
  44. {
  45. dispatch::expand<Box, Geometry>::apply(box, geometry, strategy);
  46. }
  47. };
  48. template <typename Strategy>
  49. struct expand<Strategy, false>
  50. {
  51. template <typename Box, typename Geometry>
  52. static inline void apply(Box& box,
  53. Geometry const& geometry,
  54. Strategy const& strategy)
  55. {
  56. using strategies::expand::services::strategy_converter;
  57. dispatch::expand
  58. <
  59. Box, Geometry
  60. >::apply(box, geometry, strategy_converter<Strategy>::get(strategy));
  61. }
  62. };
  63. template <>
  64. struct expand<default_strategy, false>
  65. {
  66. template <typename Box, typename Geometry>
  67. static inline void apply(Box& box,
  68. Geometry const& geometry,
  69. default_strategy)
  70. {
  71. typedef typename strategies::expand::services::default_strategy
  72. <
  73. Box, Geometry
  74. >::type strategy_type;
  75. dispatch::expand<Box, Geometry>::apply(box, geometry, strategy_type());
  76. }
  77. };
  78. } //namespace resolve_strategy
  79. namespace resolve_dynamic
  80. {
  81. template <typename Geometry, typename Tag = typename tag<Geometry>::type>
  82. struct expand
  83. {
  84. template <typename Box, typename Strategy>
  85. static inline void apply(Box& box,
  86. Geometry const& geometry,
  87. Strategy const& strategy)
  88. {
  89. concepts::check<Box>();
  90. concepts::check<Geometry const>();
  91. concepts::check_concepts_and_equal_dimensions<Box, Geometry const>();
  92. resolve_strategy::expand<Strategy>::apply(box, geometry, strategy);
  93. }
  94. };
  95. template <typename Geometry>
  96. struct expand<Geometry, dynamic_geometry_tag>
  97. {
  98. template <class Box, typename Strategy>
  99. static inline void apply(Box& box,
  100. Geometry const& geometry,
  101. Strategy const& strategy)
  102. {
  103. traits::visit<Geometry>::apply([&](auto const& g)
  104. {
  105. expand<util::remove_cref_t<decltype(g)>>::apply(box, g, strategy);
  106. }, geometry);
  107. }
  108. };
  109. } // namespace resolve_dynamic
  110. /*!
  111. \brief Expands (with strategy)
  112. \ingroup expand
  113. \tparam Box type of the box
  114. \tparam Geometry \tparam_geometry
  115. \tparam Strategy \tparam_strategy{expand}
  116. \param box box to be expanded using another geometry, mutable
  117. \param geometry \param_geometry geometry which envelope (bounding box)
  118. \param strategy \param_strategy{expand}
  119. will be added to the box
  120. \qbk{distinguish,with strategy}
  121. \qbk{[include reference/algorithms/expand.qbk]}
  122. */
  123. template <typename Box, typename Geometry, typename Strategy>
  124. inline void expand(Box& box, Geometry const& geometry, Strategy const& strategy)
  125. {
  126. resolve_dynamic::expand<Geometry>::apply(box, geometry, strategy);
  127. }
  128. /*!
  129. \brief Expands a box using the bounding box (envelope) of another geometry
  130. (box, point)
  131. \ingroup expand
  132. \tparam Box type of the box
  133. \tparam Geometry \tparam_geometry
  134. \param box box to be expanded using another geometry, mutable
  135. \param geometry \param_geometry geometry which envelope (bounding box) will be
  136. added to the box
  137. \qbk{[include reference/algorithms/expand.qbk]}
  138. */
  139. template <typename Box, typename Geometry>
  140. inline void expand(Box& box, Geometry const& geometry)
  141. {
  142. resolve_dynamic::expand<Geometry>::apply(box, geometry, default_strategy());
  143. }
  144. }} // namespace boost::geometry
  145. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INTERFACE_HPP