From 2eadb6247aa3f390e0466a79b4ebbd06b40e62b0 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sun, 27 Nov 2011 11:06:47 +0000 Subject: [PATCH] Added box-to-box conversion [SVN r75686] --- include/boost/geometry/algorithms/convert.hpp | 12 +++ .../algorithms/detail/convert_box_to_box.hpp | 80 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 include/boost/geometry/algorithms/detail/convert_box_to_box.hpp diff --git a/include/boost/geometry/algorithms/convert.hpp b/include/boost/geometry/algorithms/convert.hpp index e6f16a77f..827bff228 100644 --- a/include/boost/geometry/algorithms/convert.hpp +++ b/include/boost/geometry/algorithms/convert.hpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -252,6 +253,17 @@ struct convert {}; + +template +< + std::size_t DimensionCount, + typename Box1, typename Box2 +> +struct convert + : detail::conversion::box_to_box +{}; + + template struct convert : detail::conversion::segment_to_range diff --git a/include/boost/geometry/algorithms/detail/convert_box_to_box.hpp b/include/boost/geometry/algorithms/detail/convert_box_to_box.hpp new file mode 100644 index 000000000..3d18d526c --- /dev/null +++ b/include/boost/geometry/algorithms/detail/convert_box_to_box.hpp @@ -0,0 +1,80 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CONVERT_BOX_TO_BOX_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CONVERT_BOX_TO_BOX_HPP + + +#include + +#include +#include +#include +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace conversion +{ + + +template +< + typename Source, + typename Destination, + std::size_t Dimension, + std::size_t DimensionCount +> +struct box_to_box +{ + static inline void apply(Source const& source, Destination& destination) + { + typedef typename coordinate_type::type coordinate_type; + + geometry::set(destination, + boost::numeric_cast( + geometry::get(source))); + geometry::set(destination, + boost::numeric_cast( + geometry::get(source))); + box_to_box::apply( + source, destination); + } +}; + +template +struct box_to_box +{ + static inline void apply(Source const& , Destination& ) + {} +}; + + +template +inline void convert_box_to_box(Source const& source, Destination& destination) +{ + box_to_box::value>::apply( + source, destination); +} + + + +}} // namespace detail::conversion +#endif // DOXYGEN_NO_DETAIL + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CONVERT_BOX_TO_BOX_HPP