• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-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_STRATEGIES_CARTESIAN_EXPAND_POINT_HPP
23 #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_EXPAND_POINT_HPP
24 
25 #include <cstddef>
26 #include <functional>
27 
28 #include <boost/geometry/core/access.hpp>
29 #include <boost/geometry/core/coordinate_dimension.hpp>
30 #include <boost/geometry/core/coordinate_system.hpp>
31 #include <boost/geometry/core/coordinate_type.hpp>
32 #include <boost/geometry/core/tags.hpp>
33 
34 #include <boost/geometry/util/select_coordinate_type.hpp>
35 
36 #include <boost/geometry/strategies/expand.hpp>
37 
38 namespace boost { namespace geometry
39 {
40 
41 namespace strategy { namespace expand
42 {
43 
44 #ifndef DOXYGEN_NO_DETAIL
45 namespace detail
46 {
47 
48 template <std::size_t Dimension, std::size_t DimensionCount>
49 struct point_loop
50 {
51     template <typename Box, typename Point>
applyboost::geometry::strategy::expand::detail::point_loop52     static inline void apply(Box& box, Point const& source)
53     {
54         typedef typename select_coordinate_type
55             <
56                 Point, Box
57             >::type coordinate_type;
58 
59         std::less<coordinate_type> less;
60         std::greater<coordinate_type> greater;
61 
62         coordinate_type const coord = get<Dimension>(source);
63 
64         if (less(coord, get<min_corner, Dimension>(box)))
65         {
66             set<min_corner, Dimension>(box, coord);
67         }
68 
69         if (greater(coord, get<max_corner, Dimension>(box)))
70         {
71             set<max_corner, Dimension>(box, coord);
72         }
73 
74         point_loop<Dimension + 1, DimensionCount>::apply(box, source);
75     }
76 };
77 
78 
79 template <std::size_t DimensionCount>
80 struct point_loop<DimensionCount, DimensionCount>
81 {
82     template <typename Box, typename Point>
applyboost::geometry::strategy::expand::detail::point_loop83     static inline void apply(Box&, Point const&) {}
84 };
85 
86 
87 } // namespace detail
88 #endif // DOXYGEN_NO_DETAIL
89 
90 
91 struct cartesian_point
92 {
93     template <typename Box, typename Point>
applyboost::geometry::strategy::expand::cartesian_point94     static void apply(Box & box, Point const& point)
95     {
96         expand::detail::point_loop
97             <
98                 0, dimension<Point>::value
99             >::apply(box, point);
100     }
101 };
102 
103 
104 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
105 
106 namespace services
107 {
108 
109 template <typename CalculationType>
110 struct default_strategy<point_tag, cartesian_tag, CalculationType>
111 {
112     typedef cartesian_point type;
113 };
114 
115 
116 } // namespace services
117 
118 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
119 
120 
121 }} // namespace strategy::expand
122 
123 }} // namespace boost::geometry
124 
125 #endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_EXPAND_POINT_HPP
126