1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 
3 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
5 // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
6 // Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France.
7 
8 // This file was modified by Oracle on 2015, 2016, 2018.
9 // Modifications copyright (c) 2015-2018, Oracle and/or its affiliates.
10 
11 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
12 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
13 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
14 
15 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
16 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
17 
18 // Distributed under the Boost Software License, Version 1.0.
19 // (See accompanying file LICENSE_1_0.txt or copy at
20 // http://www.boost.org/LICENSE_1_0.txt)
21 
22 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INTERFACE_HPP
23 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INTERFACE_HPP
24 
25 #include <boost/variant/apply_visitor.hpp>
26 #include <boost/variant/static_visitor.hpp>
27 #include <boost/variant/variant_fwd.hpp>
28 
29 #include <boost/geometry/core/coordinate_system.hpp>
30 #include <boost/geometry/core/tag.hpp>
31 #include <boost/geometry/core/tags.hpp>
32 
33 #include <boost/geometry/geometries/concepts/check.hpp>
34 
35 #include <boost/geometry/algorithms/dispatch/expand.hpp>
36 
37 #include <boost/geometry/strategies/default_strategy.hpp>
38 #include <boost/geometry/strategies/expand.hpp>
39 
40 
41 namespace boost { namespace geometry
42 {
43 
44 namespace resolve_strategy
45 {
46 
47 template <typename Geometry>
48 struct expand
49 {
50     template <typename Box, typename Strategy>
applyboost::geometry::resolve_strategy::expand51     static inline void apply(Box& box,
52                              Geometry const& geometry,
53                              Strategy const& strategy)
54     {
55         dispatch::expand<Box, Geometry>::apply(box, geometry, strategy);
56     }
57 
58     template <typename Box>
applyboost::geometry::resolve_strategy::expand59     static inline void apply(Box& box,
60                              Geometry const& geometry,
61                              default_strategy)
62     {
63         typedef typename strategy::expand::services::default_strategy
64             <
65                 typename tag<Geometry>::type,
66                 typename cs_tag<Geometry>::type
67             >::type strategy_type;
68 
69         dispatch::expand<Box, Geometry>::apply(box, geometry, strategy_type());
70     }
71 };
72 
73 } //namespace resolve_strategy
74 
75 
76 namespace resolve_variant
77 {
78 
79 template <typename Geometry>
80 struct expand
81 {
82     template <typename Box, typename Strategy>
applyboost::geometry::resolve_variant::expand83     static inline void apply(Box& box,
84                              Geometry const& geometry,
85                              Strategy const& strategy)
86     {
87         concepts::check<Box>();
88         concepts::check<Geometry const>();
89         concepts::check_concepts_and_equal_dimensions<Box, Geometry const>();
90 
91         resolve_strategy::expand<Geometry>::apply(box, geometry, strategy);
92     }
93 };
94 
95 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
96 struct expand<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
97 {
98     template <typename Box, typename Strategy>
99     struct visitor: boost::static_visitor<void>
100     {
101         Box& m_box;
102         Strategy const& m_strategy;
103 
visitorboost::geometry::resolve_variant::expand::visitor104         visitor(Box& box, Strategy const& strategy)
105             : m_box(box)
106             , m_strategy(strategy)
107         {}
108 
109         template <typename Geometry>
operator ()boost::geometry::resolve_variant::expand::visitor110         void operator()(Geometry const& geometry) const
111         {
112             return expand<Geometry>::apply(m_box, geometry, m_strategy);
113         }
114     };
115 
116     template <class Box, typename Strategy>
117     static inline void
applyboost::geometry::resolve_variant::expand118     apply(Box& box,
119           boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry,
120           Strategy const& strategy)
121     {
122         return boost::apply_visitor(visitor<Box, Strategy>(box, strategy),
123                                     geometry);
124     }
125 };
126 
127 } // namespace resolve_variant
128 
129 
130 /***
131 *!
132 \brief Expands a box using the extend (envelope) of another geometry (box, point)
133 \ingroup expand
134 \tparam Box type of the box
135 \tparam Geometry of second geometry, to be expanded with the box
136 \param box box to expand another geometry with, might be changed
137 \param geometry other geometry
138 \param strategy_less
139 \param strategy_greater
140 \note Strategy is currently ignored
141  *
142 template
143 <
144     typename Box, typename Geometry,
145     typename StrategyLess, typename StrategyGreater
146 >
147 inline void expand(Box& box, Geometry const& geometry,
148             StrategyLess const& strategy_less,
149             StrategyGreater const& strategy_greater)
150 {
151     concepts::check_concepts_and_equal_dimensions<Box, Geometry const>();
152 
153     dispatch::expand<Box, Geometry>::apply(box, geometry);
154 }
155 ***/
156 
157 /*!
158 \brief Expands (with strategy)
159 \ingroup expand
160 \tparam Box type of the box
161 \tparam Geometry \tparam_geometry
162 \tparam Strategy \tparam_strategy{expand}
163 \param box box to be expanded using another geometry, mutable
164 \param geometry \param_geometry geometry which envelope (bounding box)
165 \param strategy \param_strategy{expand}
166 will be added to the box
167 
168 \qbk{distinguish,with strategy}
169 \qbk{[include reference/algorithms/expand.qbk]}
170  */
171 template <typename Box, typename Geometry, typename Strategy>
expand(Box & box,Geometry const & geometry,Strategy const & strategy)172 inline void expand(Box& box, Geometry const& geometry, Strategy const& strategy)
173 {
174 
175     resolve_variant::expand<Geometry>::apply(box, geometry, strategy);
176 }
177 
178 /*!
179 \brief Expands a box using the bounding box (envelope) of another geometry
180 (box, point)
181 \ingroup expand
182 \tparam Box type of the box
183 \tparam Geometry \tparam_geometry
184 \param box box to be expanded using another geometry, mutable
185 \param geometry \param_geometry geometry which envelope (bounding box) will be
186 added to the box
187 
188 \qbk{[include reference/algorithms/expand.qbk]}
189  */
190 template <typename Box, typename Geometry>
expand(Box & box,Geometry const & geometry)191 inline void expand(Box& box, Geometry const& geometry)
192 {
193     resolve_variant::expand<Geometry>::apply(box, geometry, default_strategy());
194 }
195 
196 }} // namespace boost::geometry
197 
198 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INTERFACE_HPP
199