interface.hpp 6.1 KB

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