|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67042 - sandbox/geometry/boost/geometry/geometries/adapted
From: barend.gehrels_at_[hidden]
Date: 2010-12-05 16:47:15
Author: barendgehrels
Date: 2010-12-05 16:47:08 EST (Sun, 05 Dec 2010)
New Revision: 67042
URL: http://svn.boost.org/trac/boost/changeset/67042
Log:
Added Boost.Polygon support (point, box, ring)
Added:
sandbox/geometry/boost/geometry/geometries/adapted/boost_polygon_box.hpp (contents, props changed)
sandbox/geometry/boost/geometry/geometries/adapted/boost_polygon_point.hpp (contents, props changed)
sandbox/geometry/boost/geometry/geometries/adapted/boost_polygon_ring.hpp (contents, props changed)
Text files modified:
sandbox/geometry/boost/geometry/geometries/adapted/std_as_ring.hpp | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
Added: sandbox/geometry/boost/geometry/geometries/adapted/boost_polygon_box.hpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/boost/geometry/geometries/adapted/boost_polygon_box.hpp 2010-12-05 16:47:08 EST (Sun, 05 Dec 2010)
@@ -0,0 +1,113 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 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_GEOMETRIES_ADAPTED_BOOST_POLYGON_BOX_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_BOX_HPP
+
+
+#include <cstddef>
+
+#include <boost/polygon/polygon.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+#include <boost/polygon/polygon.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+
+
+template <typename CoordinateType>
+struct tag<boost::polygon::rectangle_data<CoordinateType> >
+{
+ typedef box_tag type;
+};
+
+template <typename CoordinateType>
+struct point_type<boost::polygon::rectangle_data<CoordinateType> >
+{
+ // Not sure what to do here. Boost.Polygon's rectangle does NOT define its
+ // point_type (but uses it...)
+ typedef boost::polygon::point_data<CoordinateType> type;
+};
+
+template <typename CoordinateType>
+struct indexed_access<boost::polygon::rectangle_data<CoordinateType>, min_corner, 0>
+{
+ static inline CoordinateType get(boost::polygon::rectangle_data<CoordinateType> const& b)
+ {
+ return boost::polygon::xl(b);
+ }
+
+ static inline void set(boost::polygon::rectangle_data<CoordinateType>& b, CoordinateType const& value)
+ {
+ boost::polygon::xl(b, value);
+ }
+};
+
+
+template <typename CoordinateType>
+struct indexed_access<boost::polygon::rectangle_data<CoordinateType>, min_corner, 1>
+{
+ static inline CoordinateType get(boost::polygon::rectangle_data<CoordinateType> const& b)
+ {
+ return boost::polygon::yl(b);
+ }
+
+ static inline void set(boost::polygon::rectangle_data<CoordinateType>& b, CoordinateType const& value)
+ {
+ boost::polygon::yl(b, value);
+ }
+};
+
+template <typename CoordinateType>
+struct indexed_access<boost::polygon::rectangle_data<CoordinateType>, max_corner, 0>
+{
+ static inline CoordinateType get(boost::polygon::rectangle_data<CoordinateType> const& b)
+ {
+ return boost::polygon::xh(b);
+ }
+
+ static inline void set(boost::polygon::rectangle_data<CoordinateType>& b, CoordinateType const& value)
+ {
+ boost::polygon::xh(b, value);
+ }
+};
+
+template <typename CoordinateType>
+struct indexed_access<boost::polygon::rectangle_data<CoordinateType>, max_corner, 1>
+{
+ static inline CoordinateType get(boost::polygon::rectangle_data<CoordinateType> const& b)
+ {
+ return boost::polygon::yh(b);
+ }
+
+ static inline void set(boost::polygon::rectangle_data<CoordinateType>& b, CoordinateType const& value)
+ {
+ boost::polygon::yh(b, value);
+ }
+};
+
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_BOX_HPP
+
Added: sandbox/geometry/boost/geometry/geometries/adapted/boost_polygon_point.hpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/boost/geometry/geometries/adapted/boost_polygon_point.hpp 2010-12-05 16:47:08 EST (Sun, 05 Dec 2010)
@@ -0,0 +1,97 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 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_GEOMETRIES_ADAPTED_BOOST_POLYGON_POINT_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POINT_HPP
+
+
+#include <cstddef>
+
+#include <boost/polygon/polygon.hpp>
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+#include <boost/polygon/polygon.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+
+
+// Assign the point-tag, preventing arrays of points getting a point-tag
+template <typename CoordinateType>
+struct tag<boost::polygon::point_data<CoordinateType> >
+{
+ typedef point_tag type;
+};
+
+
+template <typename CoordinateType>
+struct coordinate_type<boost::polygon::point_data<CoordinateType> >
+{
+ typedef CoordinateType type;
+};
+
+template <typename CoordinateType>
+struct coordinate_system<boost::polygon::point_data<CoordinateType> >
+{
+ typedef cs::cartesian type;
+};
+
+
+template <typename CoordinateType>
+struct dimension<boost::polygon::point_data<CoordinateType> >: boost::mpl::int_<2> {};
+
+
+template <typename CoordinateType>
+struct access<boost::polygon::point_data<CoordinateType>, 0>
+{
+ static inline CoordinateType get(boost::polygon::point_data<CoordinateType> const& p)
+ {
+ return p.x();
+ }
+
+ static inline void set(boost::polygon::point_data<CoordinateType>& p,
+ CoordinateType const& value)
+ {
+ p.x(value);
+ }
+};
+
+template <typename CoordinateType>
+struct access<boost::polygon::point_data<CoordinateType>, 1>
+{
+ static inline CoordinateType get(boost::polygon::point_data<CoordinateType> const& p)
+ {
+ return p.y();
+ }
+
+ static inline void set(boost::polygon::point_data<CoordinateType>& p,
+ CoordinateType const& value)
+ {
+ p.y(value);
+ }
+};
+
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POINT_HPP
+
Added: sandbox/geometry/boost/geometry/geometries/adapted/boost_polygon_ring.hpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/boost/geometry/geometries/adapted/boost_polygon_ring.hpp 2010-12-05 16:47:08 EST (Sun, 05 Dec 2010)
@@ -0,0 +1,145 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 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_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_HPP
+
+// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
+
+#include <cstddef>
+
+
+#include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/coordinate_dimension.hpp>
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+#include <boost/polygon/polygon.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+template <typename CoordinateType>
+struct tag<boost::polygon::polygon_data<CoordinateType> >
+{
+ typedef ring_tag type;
+};
+
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+
+// ----------------------------------------------------------------------------
+// Boost.Polygon's polygon is not Boost.Range compatible so we have to add support here
+// 1. range_value<...>::type
+// 2. iterators
+// ----------------------------------------------------------------------------
+
+// range_value<...>::type -> avoid this to provide direct support within Boost.Geometry
+namespace core_dispatch
+{
+
+template <typename CoordinateType>
+struct point_type<ring_tag, boost::polygon::polygon_data<CoordinateType> >
+{
+ typedef typename boost::polygon::polygon_traits
+ <
+ boost::polygon::polygon_data<CoordinateType>
+ >::point_type type;
+};
+
+} // namespace core_dispatch
+
+
+}} // namespace boost::geometry
+
+
+// 2. iterators, adapt Boost.Polygon to Boost.Range
+namespace boost
+{
+ template<typename CoordinateType>
+ struct range_iterator<boost::polygon::polygon_data<CoordinateType> >
+ {
+ typedef typename boost::polygon::polygon_traits
+ <
+ boost::polygon::polygon_data<CoordinateType>
+ >::iterator_type type;
+ };
+
+ template<typename CoordinateType>
+ struct range_const_iterator<boost::polygon::polygon_data<CoordinateType> >
+ {
+ typedef typename boost::polygon::polygon_traits
+ <
+ boost::polygon::polygon_data<CoordinateType>
+ >::iterator_type type;
+ };
+
+ // RangeEx
+ template<typename CoordinateType>
+ struct range_size<boost::polygon::polygon_data<CoordinateType> >
+ {
+ typedef std::size_t type;
+ };
+
+} // namespace 'boost'
+
+
+// 2b. free-standing function for Boost.Range ADP
+template<typename CoordinateType>
+inline typename boost::polygon::polygon_traits
+ <
+ boost::polygon::polygon_data<CoordinateType>
+ >::iterator_type range_begin(boost::polygon::polygon_data<CoordinateType>& polygon)
+{
+ return polygon.begin();
+}
+
+template<typename CoordinateType>
+inline typename boost::polygon::polygon_traits
+ <
+ boost::polygon::polygon_data<CoordinateType>
+ >::iterator_type range_begin(boost::polygon::polygon_data<CoordinateType> const& polygon)
+{
+ return polygon.begin();
+}
+
+template<typename CoordinateType>
+inline typename boost::polygon::polygon_traits
+ <
+ boost::polygon::polygon_data<CoordinateType>
+ >::iterator_type range_end(boost::polygon::polygon_data<CoordinateType>& polygon)
+{
+ return polygon.end();
+}
+
+template<typename CoordinateType>
+inline typename boost::polygon::polygon_traits
+ <
+ boost::polygon::polygon_data<CoordinateType>
+ >::iterator_type range_end(boost::polygon::polygon_data<CoordinateType> const& polygon)
+{
+ return polygon.end();
+}
+
+// RangeEx
+template<typename CoordinateType>
+inline std::size_t range_size(boost::polygon::polygon_data<CoordinateType> const& polygon)
+{
+ return polygon.size();
+}
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_HPP
+
Modified: sandbox/geometry/boost/geometry/geometries/adapted/std_as_ring.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/geometries/adapted/std_as_ring.hpp (original)
+++ sandbox/geometry/boost/geometry/geometries/adapted/std_as_ring.hpp 2010-12-05 16:47:08 EST (Sun, 05 Dec 2010)
@@ -23,6 +23,8 @@
#include <list>
#include <utility>
+#include <boost/geometry/core/tags.hpp>
+
namespace boost { namespace geometry
{
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