convert_indexed_to_indexed.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  6. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  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. #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CONVERT_INDEXED_TO_INDEXED_HPP
  11. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CONVERT_INDEXED_TO_INDEXED_HPP
  12. #include <cstddef>
  13. #include <boost/geometry/core/access.hpp>
  14. #include <boost/geometry/core/coordinate_dimension.hpp>
  15. #include <boost/geometry/core/coordinate_type.hpp>
  16. #include <boost/geometry/util/numeric_cast.hpp>
  17. namespace boost { namespace geometry
  18. {
  19. #ifndef DOXYGEN_NO_DETAIL
  20. namespace detail { namespace conversion
  21. {
  22. template
  23. <
  24. typename Source,
  25. typename Destination,
  26. std::size_t Dimension,
  27. std::size_t DimensionCount
  28. >
  29. struct indexed_to_indexed
  30. {
  31. static inline void apply(Source const& source, Destination& destination)
  32. {
  33. typedef typename coordinate_type<Destination>::type coordinate_type;
  34. geometry::set<min_corner, Dimension>(destination,
  35. util::numeric_cast<coordinate_type>(
  36. geometry::get<min_corner, Dimension>(source)));
  37. geometry::set<max_corner, Dimension>(destination,
  38. util::numeric_cast<coordinate_type>(
  39. geometry::get<max_corner, Dimension>(source)));
  40. indexed_to_indexed
  41. <
  42. Source, Destination,
  43. Dimension + 1, DimensionCount
  44. >::apply(source, destination);
  45. }
  46. };
  47. template
  48. <
  49. typename Source,
  50. typename Destination,
  51. std::size_t DimensionCount
  52. >
  53. struct indexed_to_indexed<Source, Destination, DimensionCount, DimensionCount>
  54. {
  55. static inline void apply(Source const& , Destination& )
  56. {}
  57. };
  58. }} // namespace detail::conversion
  59. #endif // DOXYGEN_NO_DETAIL
  60. }} // namespace boost::geometry
  61. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CONVERT_INDEXED_TO_INDEXED_HPP