[io] Drop TypeOf dependency. Add detail::interior_ring_iterator<>.

This commit is contained in:
Adam Wulkiewicz
2014-06-08 13:05:44 +02:00
parent 4626d53ead
commit e52a297c98
4 changed files with 50 additions and 15 deletions

View File

@@ -9,8 +9,12 @@
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERIOR_ITERATOR_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERIOR_ITERATOR_HPP
#include <boost/geometry/core/interior_type.hpp>
#include <boost/mpl/if.hpp>
#include <boost/range/iterator.hpp>
#include <boost/range/value_type.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/geometry/core/interior_type.hpp>
namespace boost { namespace geometry
{
@@ -33,6 +37,33 @@ struct interior_iterator
>::type type;
};
template <typename BaseT, typename T>
struct const_conformant
{
typedef typename boost::mpl::if_
<
boost::is_const<BaseT>,
T const,
T
>::type type;
};
template <typename Geometry>
struct interior_ring_iterator
{
typedef typename boost::range_iterator
<
typename const_conformant
<
typename geometry::interior_type<Geometry>::type,
typename boost::range_value
<
typename geometry::interior_type<Geometry>::type
>::type
>::type
>::type type;
};
} // namespace detail
#endif // DOXYGEN_NO_DETAIL

View File

@@ -20,7 +20,8 @@
#include <boost/concept_check.hpp>
#include <boost/range.hpp>
#include <boost/typeof/typeof.hpp>
#include <boost/geometry/algorithms/detail/interior_iterator.hpp>
#include <boost/geometry/core/exterior_ring.hpp>
#include <boost/geometry/core/interior_rings.hpp>
@@ -210,9 +211,10 @@ struct dsv_poly
dsv_range<ring>::apply(os, exterior_ring(poly), settings);
typename interior_return_type<Polygon const>::type rings
= interior_rings(poly);
for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
typename interior_return_type<Polygon const>::type
rings = interior_rings(poly);
for (typename detail::interior_iterator<Polygon const>::type
it = boost::begin(rings); it != boost::end(rings); ++it)
{
os << settings.list_separator;
dsv_range<ring>::apply(os, *it, settings);

View File

@@ -18,8 +18,8 @@
#include <boost/config.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/range.hpp>
#include <boost/typeof/typeof.hpp>
#include <boost/geometry/algorithms/detail/interior_iterator.hpp>
#include <boost/geometry/core/exterior_ring.hpp>
#include <boost/geometry/core/interior_rings.hpp>
@@ -135,13 +135,14 @@ struct svg_poly
// Inner rings:
{
typename interior_return_type<Polygon const>::type rings
= interior_rings(polygon);
for (BOOST_AUTO_TPL(rit, boost::begin(rings));
rit != boost::end(rings); ++rit)
typename interior_return_type<Polygon const>::type
rings = interior_rings(polygon);
for (typename detail::interior_iterator<Polygon const>::type
rit = boost::begin(rings); rit != boost::end(rings); ++rit)
{
first = true;
for (BOOST_AUTO_TPL(it, boost::begin(*rit)); it != boost::end(*rit);
for (typename detail::interior_ring_iterator<Polygon const>::type
it = boost::begin(*rit); it != boost::end(*rit);
++it, first = false)
{
os << (first ? "M" : " L") << " "

View File

@@ -19,11 +19,11 @@
#include <boost/array.hpp>
#include <boost/range.hpp>
#include <boost/typeof/typeof.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/variant_fwd.hpp>
#include <boost/geometry/algorithms/detail/interior_iterator.hpp>
#include <boost/geometry/algorithms/assign.hpp>
#include <boost/geometry/algorithms/convert.hpp>
#include <boost/geometry/algorithms/disjoint.hpp>
@@ -197,9 +197,10 @@ struct wkt_poly
os << "(";
wkt_sequence<ring>::apply(os, exterior_ring(poly), force_closed);
typename interior_return_type<Polygon const>::type rings
= interior_rings(poly);
for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
typename interior_return_type<Polygon const>::type
rings = interior_rings(poly);
for (typename detail::interior_iterator<Polygon const>::type
it = boost::begin(rings); it != boost::end(rings); ++it)
{
os << ",";
wkt_sequence<ring>::apply(os, *it, force_closed);