Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75686 - in trunk/boost/geometry/algorithms: . detail
From: barend.gehrels_at_[hidden]
Date: 2011-11-27 06:06:48


Author: barendgehrels
Date: 2011-11-27 06:06:47 EST (Sun, 27 Nov 2011)
New Revision: 75686
URL: http://svn.boost.org/trac/boost/changeset/75686

Log:
Added box-to-box conversion
Added:
   trunk/boost/geometry/algorithms/detail/convert_box_to_box.hpp (contents, props changed)
Text files modified:
   trunk/boost/geometry/algorithms/convert.hpp | 12 ++++++++++++
   1 files changed, 12 insertions(+), 0 deletions(-)

Modified: trunk/boost/geometry/algorithms/convert.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/convert.hpp (original)
+++ trunk/boost/geometry/algorithms/convert.hpp 2011-11-27 06:06:47 EST (Sun, 27 Nov 2011)
@@ -29,6 +29,7 @@
 #include <boost/geometry/algorithms/detail/assign_box_corners.hpp>
 #include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
 #include <boost/geometry/algorithms/detail/convert_point_to_point.hpp>
+#include <boost/geometry/algorithms/detail/convert_box_to_box.hpp>
 
 #include <boost/geometry/views/closeable_view.hpp>
 #include <boost/geometry/views/reversible_view.hpp>
@@ -252,6 +253,17 @@
     : detail::conversion::point_to_point<Geometry1, Geometry2, 0, DimensionCount>
 {};
 
+
+template
+<
+ std::size_t DimensionCount,
+ typename Box1, typename Box2
+>
+struct convert<false, box_tag, box_tag, DimensionCount, Box1, Box2>
+ : detail::conversion::box_to_box<Box1, Box2, 0, DimensionCount>
+{};
+
+
 template <std::size_t DimensionCount, typename Segment, typename LineString>
 struct convert<false, segment_tag, linestring_tag, DimensionCount, Segment, LineString>
     : detail::conversion::segment_to_range<Segment, LineString>

Added: trunk/boost/geometry/algorithms/detail/convert_box_to_box.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/geometry/algorithms/detail/convert_box_to_box.hpp 2011-11-27 06:06:47 EST (Sun, 27 Nov 2011)
@@ -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 <cstddef>
+
+#include <boost/numeric/conversion/cast.hpp>
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+
+
+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<Destination>::type coordinate_type;
+
+ geometry::set<Dimension, min_corner>(destination,
+ boost::numeric_cast<coordinate_type>(
+ geometry::get<Dimension, min_corner>(source)));
+ geometry::set<Dimension, max_corner>(destination,
+ boost::numeric_cast<coordinate_type>(
+ geometry::get<Dimension, max_corner>(source)));
+ box_to_box<Source, Destination, Dimension + 1, DimensionCount>::apply(
+ source, destination);
+ }
+};
+
+template <typename Source, typename Destination, std::size_t DimensionCount>
+struct box_to_box<Source, Destination, DimensionCount, DimensionCount>
+{
+ static inline void apply(Source const& , Destination& )
+ {}
+};
+
+
+template <typename Source, typename Destination>
+inline void convert_box_to_box(Source const& source, Destination& destination)
+{
+ box_to_box<Source, Destination, 0, dimension<Destination>::value>::apply(
+ source, destination);
+}
+
+
+
+}} // namespace detail::conversion
+#endif // DOXYGEN_NO_DETAIL
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CONVERT_BOX_TO_BOX_HPP


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk