]>
Commit | Line | Data |
---|---|---|
1 | // Boost.Geometry Index | |
2 | // | |
3 | // n-dimensional bounds | |
4 | // | |
5 | // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. | |
6 | // | |
7 | // Use, modification and distribution is subject to the Boost Software License, | |
8 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
9 | // http://www.boost.org/LICENSE_1_0.txt) | |
10 | ||
11 | #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_BOUNDS_HPP | |
12 | #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_BOUNDS_HPP | |
13 | ||
14 | #include <boost/geometry/index/detail/bounded_view.hpp> | |
15 | ||
16 | namespace boost { namespace geometry { namespace index { namespace detail { | |
17 | ||
18 | namespace dispatch { | |
19 | ||
20 | template <typename Geometry, | |
21 | typename Bounds, | |
22 | typename TagGeometry = typename geometry::tag<Geometry>::type, | |
23 | typename TagBounds = typename geometry::tag<Bounds>::type> | |
24 | struct bounds | |
25 | { | |
26 | static inline void apply(Geometry const& g, Bounds & b) | |
27 | { | |
28 | geometry::convert(g, b); | |
29 | } | |
30 | }; | |
31 | ||
32 | template <typename Geometry, typename Bounds> | |
33 | struct bounds<Geometry, Bounds, segment_tag, box_tag> | |
34 | { | |
35 | static inline void apply(Geometry const& g, Bounds & b) | |
36 | { | |
37 | index::detail::bounded_view<Geometry, Bounds> v(g); | |
38 | geometry::convert(v, b); | |
39 | } | |
40 | }; | |
41 | ||
42 | } // namespace dispatch | |
43 | ||
44 | template <typename Geometry, typename Bounds> | |
45 | inline void bounds(Geometry const& g, Bounds & b) | |
46 | { | |
47 | concepts::check_concepts_and_equal_dimensions<Geometry const, Bounds>(); | |
48 | dispatch::bounds<Geometry, Bounds>::apply(g, b); | |
49 | } | |
50 | ||
51 | namespace dispatch { | |
52 | ||
53 | template <typename Geometry, | |
54 | typename TagGeometry = typename geometry::tag<Geometry>::type> | |
55 | struct return_ref_or_bounds | |
56 | { | |
57 | typedef Geometry const& result_type; | |
58 | ||
59 | static inline result_type apply(Geometry const& g) | |
60 | { | |
61 | return g; | |
62 | } | |
63 | }; | |
64 | ||
65 | template <typename Geometry> | |
66 | struct return_ref_or_bounds<Geometry, segment_tag> | |
67 | { | |
68 | typedef typename point_type<Geometry>::type point_type; | |
69 | typedef geometry::model::box<point_type> bounds_type; | |
70 | typedef index::detail::bounded_view<Geometry, bounds_type> result_type; | |
71 | ||
72 | static inline result_type apply(Geometry const& g) | |
73 | { | |
74 | return result_type(g); | |
75 | } | |
76 | }; | |
77 | ||
78 | } // namespace dispatch | |
79 | ||
80 | template <typename Geometry> | |
81 | inline | |
82 | typename dispatch::return_ref_or_bounds<Geometry>::result_type | |
83 | return_ref_or_bounds(Geometry const& g) | |
84 | { | |
85 | return dispatch::return_ref_or_bounds<Geometry>::apply(g); | |
86 | } | |
87 | ||
88 | }}}} // namespace boost::geometry::index::detail | |
89 | ||
90 | #endif // BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_BOUNDS_HPP |