interface.hpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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, 2016, 2018.
  7. // Modifications copyright (c) 2015-2018, 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/variant/apply_visitor.hpp>
  19. #include <boost/variant/static_visitor.hpp>
  20. #include <boost/variant/variant_fwd.hpp>
  21. #include <boost/geometry/core/coordinate_system.hpp>
  22. #include <boost/geometry/core/tag.hpp>
  23. #include <boost/geometry/core/tags.hpp>
  24. #include <boost/geometry/geometries/concepts/check.hpp>
  25. #include <boost/geometry/algorithms/dispatch/expand.hpp>
  26. #include <boost/geometry/strategies/default_strategy.hpp>
  27. #include <boost/geometry/strategies/expand.hpp>
  28. namespace boost { namespace geometry
  29. {
  30. namespace resolve_strategy
  31. {
  32. template <typename Geometry>
  33. struct expand
  34. {
  35. template <typename Box, typename Strategy>
  36. static inline void apply(Box& box,
  37. Geometry const& geometry,
  38. Strategy const& strategy)
  39. {
  40. dispatch::expand<Box, Geometry>::apply(box, geometry, strategy);
  41. }
  42. template <typename Box>
  43. static inline void apply(Box& box,
  44. Geometry const& geometry,
  45. default_strategy)
  46. {
  47. typedef typename strategy::expand::services::default_strategy
  48. <
  49. typename tag<Geometry>::type,
  50. typename cs_tag<Geometry>::type
  51. >::type strategy_type;
  52. dispatch::expand<Box, Geometry>::apply(box, geometry, strategy_type());
  53. }
  54. };
  55. } //namespace resolve_strategy
  56. namespace resolve_variant
  57. {
  58. template <typename Geometry>
  59. struct expand
  60. {
  61. template <typename Box, typename Strategy>
  62. static inline void apply(Box& box,
  63. Geometry const& geometry,
  64. Strategy const& strategy)
  65. {
  66. concepts::check<Box>();
  67. concepts::check<Geometry const>();
  68. concepts::check_concepts_and_equal_dimensions<Box, Geometry const>();
  69. resolve_strategy::expand<Geometry>::apply(box, geometry, strategy);
  70. }
  71. };
  72. template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
  73. struct expand<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
  74. {
  75. template <typename Box, typename Strategy>
  76. struct visitor: boost::static_visitor<void>
  77. {
  78. Box& m_box;
  79. Strategy const& m_strategy;
  80. visitor(Box& box, Strategy const& strategy)
  81. : m_box(box)
  82. , m_strategy(strategy)
  83. {}
  84. template <typename Geometry>
  85. void operator()(Geometry const& geometry) const
  86. {
  87. return expand<Geometry>::apply(m_box, geometry, m_strategy);
  88. }
  89. };
  90. template <class Box, typename Strategy>
  91. static inline void
  92. apply(Box& box,
  93. boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry,
  94. Strategy const& strategy)
  95. {
  96. return boost::apply_visitor(visitor<Box, Strategy>(box, strategy),
  97. geometry);
  98. }
  99. };
  100. } // namespace resolve_variant
  101. /***
  102. *!
  103. \brief Expands a box using the extend (envelope) of another geometry (box, point)
  104. \ingroup expand
  105. \tparam Box type of the box
  106. \tparam Geometry of second geometry, to be expanded with the box
  107. \param box box to expand another geometry with, might be changed
  108. \param geometry other geometry
  109. \param strategy_less
  110. \param strategy_greater
  111. \note Strategy is currently ignored
  112. *
  113. template
  114. <
  115. typename Box, typename Geometry,
  116. typename StrategyLess, typename StrategyGreater
  117. >
  118. inline void expand(Box& box, Geometry const& geometry,
  119. StrategyLess const& strategy_less,
  120. StrategyGreater const& strategy_greater)
  121. {
  122. concepts::check_concepts_and_equal_dimensions<Box, Geometry const>();
  123. dispatch::expand<Box, Geometry>::apply(box, geometry);
  124. }
  125. ***/
  126. /*!
  127. \brief Expands (with strategy)
  128. \ingroup expand
  129. \tparam Box type of the box
  130. \tparam Geometry \tparam_geometry
  131. \tparam Strategy \tparam_strategy{expand}
  132. \param box box to be expanded using another geometry, mutable
  133. \param geometry \param_geometry geometry which envelope (bounding box)
  134. \param strategy \param_strategy{expand}
  135. will be added to the box
  136. \qbk{distinguish,with strategy}
  137. \qbk{[include reference/algorithms/expand.qbk]}
  138. */
  139. template <typename Box, typename Geometry, typename Strategy>
  140. inline void expand(Box& box, Geometry const& geometry, Strategy const& strategy)
  141. {
  142. resolve_variant::expand<Geometry>::apply(box, geometry, strategy);
  143. }
  144. /*!
  145. \brief Expands a box using the bounding box (envelope) of another geometry
  146. (box, point)
  147. \ingroup expand
  148. \tparam Box type of the box
  149. \tparam Geometry \tparam_geometry
  150. \param box box to be expanded using another geometry, mutable
  151. \param geometry \param_geometry geometry which envelope (bounding box) will be
  152. added to the box
  153. \qbk{[include reference/algorithms/expand.qbk]}
  154. */
  155. template <typename Box, typename Geometry>
  156. inline void expand(Box& box, Geometry const& geometry)
  157. {
  158. resolve_variant::expand<Geometry>::apply(box, geometry, default_strategy());
  159. }
  160. }} // namespace boost::geometry
  161. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INTERFACE_HPP