From e9ed5075748c59aa72a15795ea4f0efd2ac47758 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sat, 11 Dec 2010 12:04:48 +0000 Subject: [PATCH] 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 [SVN r67166] --- .../boost_polygon_polygon_interiors.hpp | 81 ++++++++++++++ .../boost_polygon_polygon_iterator.hpp | 67 +++++++++++ .../adapted/boost_polygon_polygon_ring.hpp | 105 ++++++++++++++++++ 3 files changed, 253 insertions(+) create mode 100644 include/boost/geometry/geometries/adapted/boost_polygon_polygon_interiors.hpp create mode 100644 include/boost/geometry/geometries/adapted/boost_polygon_polygon_iterator.hpp create mode 100644 include/boost/geometry/geometries/adapted/boost_polygon_polygon_ring.hpp diff --git a/include/boost/geometry/geometries/adapted/boost_polygon_polygon_interiors.hpp b/include/boost/geometry/geometries/adapted/boost_polygon_polygon_interiors.hpp new file mode 100644 index 000000000..b7d6db70e --- /dev/null +++ b/include/boost/geometry/geometries/adapted/boost_polygon_polygon_interiors.hpp @@ -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 + + +// bp_interiors -> proxy for interior_type, range-of-rings or range-of-ranges +template +struct bp_interiors +{ + typedef typename boost::polygon::polygon_traits::coordinate_type coordinate_type; + typedef boost::polygon::polygon_data Ring; + typedef bp_iterator 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& back() {} + + iterator_type first, second; +}; + + +// 2. iterators, adapt Boost.Polygon to Boost.Range +namespace boost +{ + template + struct range_iterator > + { + typedef typename bp_interiors::iterator_type type; + }; + + template + struct range_const_iterator > + { + typedef typename bp_interiors::iterator_type type; + }; + + +} // namespace 'boost' + + +// 2b. free-standing function for Boost.Range ADP +template +inline typename bp_interiors::iterator_type range_begin(bp_interiors& ring) +{ + return ring.first; +} + +template +inline typename bp_interiors::iterator_type range_begin(bp_interiors const& ring) +{ + return ring.first; +} + +template +inline typename bp_interiors::iterator_type range_end(bp_interiors& ring) +{ + return ring.second; +} + +template +inline typename bp_interiors::iterator_type range_end(bp_interiors const& ring) +{ + return ring.second; +} + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_INTERIORS_HPP + diff --git a/include/boost/geometry/geometries/adapted/boost_polygon_polygon_iterator.hpp b/include/boost/geometry/geometries/adapted/boost_polygon_polygon_iterator.hpp new file mode 100644 index 000000000..521c19575 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/boost_polygon_polygon_iterator.hpp @@ -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 +#include + + + +// ring iterator -> iterating over holes, delivering bp_ring's instead of normal polygon_data +template +class bp_iterator + : public boost::iterator_facade + < + bp_iterator, + 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 const& other) const + { + return this->m_base == other.m_base; + } + + it_type m_base; + +}; + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_ITERATOR_HPP + diff --git a/include/boost/geometry/geometries/adapted/boost_polygon_polygon_ring.hpp b/include/boost/geometry/geometries/adapted/boost_polygon_polygon_ring.hpp new file mode 100644 index 000000000..b68603482 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/boost_polygon_polygon_ring.hpp @@ -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 +#include + + +// 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 +struct bp_ring : public std::pair +{ + typedef boost::polygon::polygon_traits 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 const& p) + { + this->first = boost::polygon::begin_points(p); + this->second = boost::polygon::end_points(p); + } +}; + + +namespace boost { namespace geometry +{ + +namespace traits +{ + +template +struct tag > +{ + typedef ring_tag type; +}; + +} + +}} + +// 2. iterators, adapt Boost.Polygon to Boost.Range +namespace boost +{ + template + struct range_iterator > + { + typedef typename bp_ring::iterator_type type; + }; + + template + struct range_const_iterator > + { + typedef typename bp_ring::iterator_type type; + }; + + +} // namespace 'boost' + + +// 2b. free-standing function for Boost.Range ADP +template +inline typename bp_ring::iterator_type range_begin(bp_ring& ring) +{ + return ring.first; +} + +template +inline typename bp_ring::iterator_type range_begin(bp_ring const& ring) +{ + return ring.first; +} + +template +inline typename bp_ring::iterator_type range_end(bp_ring& ring) +{ + return ring.second; +} + +template +inline typename bp_ring::iterator_type range_end(bp_ring const& ring) +{ + return ring.second; +} + + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_RING_HPP +