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.
9 // Modifications copyright (c) 2015, Oracle and/or its affiliates.
10 
11 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
12 
13 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
14 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
15 
16 // Distributed under the Boost Software License, Version 1.0.
17 // (See accompanying file LICENSE_1_0.txt or copy at
18 // http://www.boost.org/LICENSE_1_0.txt)
19 
20 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INTERFACE_HPP
21 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INTERFACE_HPP
22 
23 #include <boost/variant/apply_visitor.hpp>
24 #include <boost/variant/static_visitor.hpp>
25 #include <boost/variant/variant_fwd.hpp>
26 
27 #include <boost/geometry/geometries/concepts/check.hpp>
28 
29 #include <boost/geometry/algorithms/dispatch/expand.hpp>
30 
31 
32 namespace boost { namespace geometry
33 {
34 
35 
36 namespace resolve_variant
37 {
38 
39 template <typename Geometry>
40 struct expand
41 {
42     template <typename Box>
applyboost::geometry::resolve_variant::expand43     static inline void apply(Box& box, Geometry const& geometry)
44     {
45         concept::check<Box>();
46         concept::check<Geometry const>();
47         concept::check_concepts_and_equal_dimensions<Box, Geometry const>();
48 
49         dispatch::expand<Box, Geometry>::apply(box, geometry);
50     }
51 };
52 
53 template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
54 struct expand<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
55 {
56     template <typename Box>
57     struct visitor: boost::static_visitor<void>
58     {
59         Box& m_box;
60 
visitorboost::geometry::resolve_variant::expand::visitor61         visitor(Box& box) : m_box(box) {}
62 
63         template <typename Geometry>
operator ()boost::geometry::resolve_variant::expand::visitor64         void operator()(Geometry const& geometry) const
65         {
66             return expand<Geometry>::apply(m_box, geometry);
67         }
68     };
69 
70     template <class Box>
71     static inline void
applyboost::geometry::resolve_variant::expand72     apply(Box& box,
73           boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry)
74     {
75         return boost::apply_visitor(visitor<Box>(box), geometry);
76     }
77 };
78 
79 } // namespace resolve_variant
80 
81 
82 /***
83 *!
84 \brief Expands a box using the extend (envelope) of another geometry (box, point)
85 \ingroup expand
86 \tparam Box type of the box
87 \tparam Geometry of second geometry, to be expanded with the box
88 \param box box to expand another geometry with, might be changed
89 \param geometry other geometry
90 \param strategy_less
91 \param strategy_greater
92 \note Strategy is currently ignored
93  *
94 template
95 <
96     typename Box, typename Geometry,
97     typename StrategyLess, typename StrategyGreater
98 >
99 inline void expand(Box& box, Geometry const& geometry,
100             StrategyLess const& strategy_less,
101             StrategyGreater const& strategy_greater)
102 {
103     concept::check_concepts_and_equal_dimensions<Box, Geometry const>();
104 
105     dispatch::expand<Box, Geometry>::apply(box, geometry);
106 }
107 ***/
108 
109 
110 /*!
111 \brief Expands a box using the bounding box (envelope) of another geometry (box, point)
112 \ingroup expand
113 \tparam Box type of the box
114 \tparam Geometry \tparam_geometry
115 \param box box to be expanded using another geometry, mutable
116 \param geometry \param_geometry geometry which envelope (bounding box) will be added to the box
117 
118 \qbk{[include reference/algorithms/expand.qbk]}
119  */
120 template <typename Box, typename Geometry>
expand(Box & box,Geometry const & geometry)121 inline void expand(Box& box, Geometry const& geometry)
122 {
123     resolve_variant::expand<Geometry>::apply(box, geometry);
124 }
125 
126 }} // namespace boost::geometry
127 
128 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INTERFACE_HPP
129