/usr/include/boost/geometry/geometries/adapted/boost_polygon
Edit: /usr/include/boost/geometry/geometries/adapted/boost_polygon/ring.hpp (5449B)
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2010-2012 Barend Gehrels, 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
// boost::polygon::polygon_data -> boost::geometry::ring
#include
#include
#include
#include
#include
#include
#include
#include
#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
namespace boost { namespace geometry
{
namespace traits
{
template
struct tag >
{
typedef ring_tag type;
};
template
struct clear >
{
static inline void apply(boost::polygon::polygon_data& data)
{
// There is no "clear" function but we can assign
// a newly (and therefore empty) constructed polygon
boost::polygon::assign(data, boost::polygon::polygon_data());
}
};
template
struct push_back >
{
typedef boost::polygon::point_data point_type;
static inline void apply(boost::polygon::polygon_data& data,
point_type const& point)
{
// Boost.Polygon's polygons are not appendable. So create a temporary vector,
// add a record and set it to the original. Of course: this is not efficient.
// But there seems no other way (without using a wrapper)
std::vector temporary_vector
(
boost::polygon::begin_points(data),
boost::polygon::end_points(data)
);
temporary_vector.push_back(point);
data.set(temporary_vector.begin(), temporary_vector.end());
}
};
template
struct resize >
{
typedef boost::polygon::point_data point_type;
static inline void apply(boost::polygon::polygon_data& data,
std::size_t new_size)
{
// Boost.Polygon's polygons are not resizable. So create a temporary vector,
// resize it and set it to the original. Of course: this is not efficient.
// But there seems no other way (without using a wrapper)
std::vector temporary_vector
(
boost::polygon::begin_points(data),
boost::polygon::end_points(data)
);
temporary_vector.resize(new_size);
data.set(temporary_vector.begin(), temporary_vector.end());
}
};
} // namespace traits
}} // namespace boost::geometry
// Adapt Boost.Polygon's polygon_data to Boost.Range
// This just translates to
// polygon_data.begin() and polygon_data.end()
namespace boost
{
template
struct range_mutable_iterator >
{
typedef typename boost::polygon::polygon_traits
<
boost::polygon::polygon_data
>::iterator_type type;
};
template
struct range_const_iterator >
{
typedef typename boost::polygon::polygon_traits
<
boost::polygon::polygon_data
>::iterator_type type;
};
template
struct range_size >
{
typedef std::size_t type;
};
} // namespace boost
// Support Boost.Polygon's polygon_data for Boost.Range ADP
namespace boost { namespace polygon
{
template
inline typename polygon_traits
<
polygon_data
>::iterator_type range_begin(polygon_data& polygon)
{
return polygon.begin();
}
template
inline typename polygon_traits
<
polygon_data
>::iterator_type range_begin(polygon_data const& polygon)
{
return polygon.begin();
}
template
inline typename polygon_traits
<
polygon_data
>::iterator_type range_end(polygon_data& polygon)
{
return polygon.end();
}
template
inline typename polygon_traits
<
polygon_data
>::iterator_type range_end(polygon_data const& polygon)
{
return polygon.end();
}
template
inline std::size_t range_calculate_size(polygon_data const& polygon)
{
return polygon.size();
}
}}
#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_HPP