1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | |
3 | // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. |
4 | // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. |
5 | // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. |
6 | |
7 | // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library |
8 | // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. |
9 | |
10 | // Use, modification and distribution is subject to the Boost Software License, |
11 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
12 | // http://www.boost.org/LICENSE_1_0.txt) |
13 | |
14 | #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CONVERT_INDEXED_TO_INDEXED_HPP |
15 | #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CONVERT_INDEXED_TO_INDEXED_HPP |
16 | |
17 | |
18 | #include <cstddef> |
19 | |
20 | #include <boost/numeric/conversion/cast.hpp> |
21 | #include <boost/geometry/core/access.hpp> |
22 | #include <boost/geometry/core/coordinate_dimension.hpp> |
23 | #include <boost/geometry/core/coordinate_type.hpp> |
24 | |
25 | |
26 | namespace boost { namespace geometry |
27 | { |
28 | |
29 | #ifndef DOXYGEN_NO_DETAIL |
30 | namespace detail { namespace conversion |
31 | { |
32 | |
33 | |
34 | template |
35 | < |
36 | typename Source, |
37 | typename Destination, |
38 | std::size_t Dimension, |
39 | std::size_t DimensionCount |
40 | > |
41 | struct indexed_to_indexed |
42 | { |
43 | static inline void apply(Source const& source, Destination& destination) |
44 | { |
45 | typedef typename coordinate_type<Destination>::type coordinate_type; |
46 | |
47 | geometry::set<min_corner, Dimension>(destination, |
48 | boost::numeric_cast<coordinate_type>( |
49 | geometry::get<min_corner, Dimension>(source))); |
50 | geometry::set<max_corner, Dimension>(destination, |
51 | boost::numeric_cast<coordinate_type>( |
52 | geometry::get<max_corner, Dimension>(source))); |
53 | |
54 | indexed_to_indexed |
55 | < |
56 | Source, Destination, |
57 | Dimension + 1, DimensionCount |
58 | >::apply(source, destination); |
59 | } |
60 | }; |
61 | |
62 | template |
63 | < |
64 | typename Source, |
65 | typename Destination, |
66 | std::size_t DimensionCount |
67 | > |
68 | struct indexed_to_indexed<Source, Destination, DimensionCount, DimensionCount> |
69 | { |
70 | static inline void apply(Source const& , Destination& ) |
71 | {} |
72 | }; |
73 | |
74 | |
75 | }} // namespace detail::conversion |
76 | #endif // DOXYGEN_NO_DETAIL |
77 | |
78 | }} // namespace boost::geometry |
79 | |
80 | #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CONVERT_INDEXED_TO_INDEXED_HPP |
81 | |