|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67166 - sandbox/geometry/boost/geometry/geometries/adapted
From: barend.gehrels_at_[hidden]
Date: 2010-12-11 07:04:49
Author: barendgehrels
Date: 2010-12-11 07:04:48 EST (Sat, 11 Dec 2010)
New Revision: 67166
URL: http://svn.boost.org/trac/boost/changeset/67166
Log:
Committed added files for concept-change to include reference to ring_type and interior_type.
For interior_type.hpp, this is split off from interior_rings.hpp
Changed comment in add_const_if_c
Added:
sandbox/geometry/boost/geometry/geometries/adapted/boost_polygon_polygon_interiors.hpp (contents, props changed)
sandbox/geometry/boost/geometry/geometries/adapted/boost_polygon_polygon_iterator.hpp (contents, props changed)
sandbox/geometry/boost/geometry/geometries/adapted/boost_polygon_polygon_ring.hpp (contents, props changed)
Added: sandbox/geometry/boost/geometry/geometries/adapted/boost_polygon_polygon_interiors.hpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/boost/geometry/geometries/adapted/boost_polygon_polygon_interiors.hpp 2010-12-11 07:04:48 EST (Sat, 11 Dec 2010)
@@ -0,0 +1,81 @@
+// 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_POLYGON_INTERIORS_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_INTERIORS_HPP
+
+#include <boost/polygon/polygon.hpp>
+
+
+// bp_interiors -> proxy for interior_type, range-of-rings or range-of-ranges
+template<typename Polygon>
+struct bp_interiors
+{
+ typedef typename boost::polygon::polygon_traits<Polygon>::coordinate_type coordinate_type;
+ typedef boost::polygon::polygon_data<coordinate_type> Ring;
+ typedef bp_iterator<Polygon, Ring> iterator_type;
+
+
+ inline bp_interiors(Polygon const& p)
+ {
+ this->first = iterator_type(boost::polygon::begin_holes(p));
+ this->second = iterator_type(boost::polygon::end_holes(p));
+ }
+
+ //void resize(int n) {}
+ //bp_ring<Polygon>& back() {}
+
+ iterator_type first, second;
+};
+
+
+// 2. iterators, adapt Boost.Polygon to Boost.Range
+namespace boost
+{
+ template<typename Polygon>
+ struct range_iterator<bp_interiors<Polygon> >
+ {
+ typedef typename bp_interiors<Polygon>::iterator_type type;
+ };
+
+ template<typename Polygon>
+ struct range_const_iterator<bp_interiors<Polygon> >
+ {
+ typedef typename bp_interiors<Polygon>::iterator_type type;
+ };
+
+
+} // namespace 'boost'
+
+
+// 2b. free-standing function for Boost.Range ADP
+template<typename Polygon>
+inline typename bp_interiors<Polygon>::iterator_type range_begin(bp_interiors<Polygon>& ring)
+{
+ return ring.first;
+}
+
+template<typename Polygon>
+inline typename bp_interiors<Polygon>::iterator_type range_begin(bp_interiors<Polygon> const& ring)
+{
+ return ring.first;
+}
+
+template<typename Polygon>
+inline typename bp_interiors<Polygon>::iterator_type range_end(bp_interiors<Polygon>& ring)
+{
+ return ring.second;
+}
+
+template<typename Polygon>
+inline typename bp_interiors<Polygon>::iterator_type range_end(bp_interiors<Polygon> const& ring)
+{
+ return ring.second;
+}
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_INTERIORS_HPP
+
Added: sandbox/geometry/boost/geometry/geometries/adapted/boost_polygon_polygon_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/boost/geometry/geometries/adapted/boost_polygon_polygon_iterator.hpp 2010-12-11 07:04:48 EST (Sat, 11 Dec 2010)
@@ -0,0 +1,67 @@
+// 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_POLYGON_ITERATOR_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_ITERATOR_HPP
+
+#include <boost/iterator.hpp>
+#include <boost/iterator/iterator_facade.hpp>
+
+
+
+// ring iterator -> iterating over holes, delivering bp_ring's instead of normal polygon_data
+template <typename Polygon, typename Ring>
+class bp_iterator
+ : public boost::iterator_facade
+ <
+ bp_iterator<Polygon, Ring>,
+ Ring, // its value type
+ boost::random_access_traversal_tag,
+ Ring // its reference type
+ >
+{
+public :
+ typedef typename boost::polygon::polygon_with_holes_traits
+ <
+ Polygon
+ >::iterator_holes_type it_type;
+
+ explicit inline bp_iterator(it_type& it)
+ : m_base(it)
+ {
+ }
+
+ explicit inline bp_iterator()
+ {
+ //throw std::string("Constructed by default!");
+ }
+
+
+private:
+ friend class boost::iterator_core_access;
+
+ inline Ring dereference() const
+ {
+ return Ring(*this->m_base);
+ }
+
+
+ inline void increment() { ++m_base; }
+ inline void decrement() { --m_base; }
+ inline void advance(difference_type n) { m_base += n; }
+
+ inline bool equal(bp_iterator<Polygon, Ring> const& other) const
+ {
+ return this->m_base == other.m_base;
+ }
+
+ it_type m_base;
+
+};
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_ITERATOR_HPP
+
Added: sandbox/geometry/boost/geometry/geometries/adapted/boost_polygon_polygon_ring.hpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/boost/geometry/geometries/adapted/boost_polygon_polygon_ring.hpp 2010-12-11 07:04:48 EST (Sat, 11 Dec 2010)
@@ -0,0 +1,105 @@
+// 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_POLYGON_RING_HPP
+#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_RING_HPP
+
+// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
+
+#include <boost/range.hpp>
+#include <boost/polygon/polygon.hpp>
+
+
+// bp_ring -> proxy for ring
+// Polygon should be a "polygon_data" here; NOT polygon_with_holes_data
+
+// TODO: there should probably be a namespace here. boost::geometry::bp ?
+
+template<typename Polygon>
+struct bp_ring : public std::pair<typename Polygon::iterator_type, typename Polygon::iterator_type>
+{
+ typedef boost::polygon::polygon_traits<Polygon> traits;
+ typedef typename traits::coordinate_type coordinate_type;
+ typedef typename traits::iterator_type iterator_type;
+
+ inline bp_ring(Polygon const& p)
+ {
+ this->first = boost::polygon::begin_points(p);
+ this->second = boost::polygon::end_points(p);
+ }
+
+ inline bp_ring(boost::polygon::polygon_with_holes_data<coordinate_type> const& p)
+ {
+ this->first = boost::polygon::begin_points(p);
+ this->second = boost::polygon::end_points(p);
+ }
+};
+
+
+namespace boost { namespace geometry
+{
+
+namespace traits
+{
+
+template <typename Polygon>
+struct tag<bp_ring<Polygon> >
+{
+ typedef ring_tag type;
+};
+
+}
+
+}}
+
+// 2. iterators, adapt Boost.Polygon to Boost.Range
+namespace boost
+{
+ template<typename Polygon>
+ struct range_iterator<bp_ring<Polygon> >
+ {
+ typedef typename bp_ring<Polygon>::iterator_type type;
+ };
+
+ template<typename Polygon>
+ struct range_const_iterator<bp_ring<Polygon> >
+ {
+ typedef typename bp_ring<Polygon>::iterator_type type;
+ };
+
+
+} // namespace 'boost'
+
+
+// 2b. free-standing function for Boost.Range ADP
+template<typename Polygon>
+inline typename bp_ring<Polygon>::iterator_type range_begin(bp_ring<Polygon>& ring)
+{
+ return ring.first;
+}
+
+template<typename Polygon>
+inline typename bp_ring<Polygon>::iterator_type range_begin(bp_ring<Polygon> const& ring)
+{
+ return ring.first;
+}
+
+template<typename Polygon>
+inline typename bp_ring<Polygon>::iterator_type range_end(bp_ring<Polygon>& ring)
+{
+ return ring.second;
+}
+
+template<typename Polygon>
+inline typename bp_ring<Polygon>::iterator_type range_end(bp_ring<Polygon> const& ring)
+{
+ return ring.second;
+}
+
+
+#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_RING_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