1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Use, modification and distribution is subject to the Boost Software License,
6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CONVERT_RING_HPP
10 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CONVERT_RING_HPP
13 #include <boost/mpl/assert.hpp>
14 #include <boost/range.hpp>
15 #include <boost/range/algorithm/reverse.hpp>
17 #include <boost/geometry/core/tags.hpp>
18 #include <boost/geometry/core/exterior_ring.hpp>
19 #include <boost/geometry/core/interior_rings.hpp>
20 #include <boost/geometry/algorithms/detail/ring_identifier.hpp>
22 #include <boost/geometry/algorithms/convert.hpp>
25 namespace boost { namespace geometry
29 #ifndef DOXYGEN_NO_DETAIL
30 namespace detail { namespace overlay
34 template<typename Tag>
39 false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TAG
45 struct convert_ring<ring_tag>
47 template<typename Destination, typename Source>
48 static inline void apply(Destination& destination, Source const& source,
49 bool append, bool reverse)
53 geometry::convert(source, destination);
56 boost::reverse(destination);
64 struct convert_ring<polygon_tag>
66 template<typename Destination, typename Source>
67 static inline void apply(Destination& destination, Source const& source,
68 bool append, bool reverse)
72 geometry::convert(source, exterior_ring(destination));
75 boost::reverse(exterior_ring(destination));
80 // Avoid adding interior rings which are invalid
81 // because of its number of points:
82 std::size_t const min_num_points
83 = core_detail::closure::minimum_ring_size
85 geometry::closure<Destination>::value
88 if (geometry::num_points(source) >= min_num_points)
90 interior_rings(destination).resize(
91 interior_rings(destination).size() + 1);
92 geometry::convert(source, interior_rings(destination).back());
95 boost::reverse(interior_rings(destination).back());
103 }} // namespace detail::overlay
104 #endif // DOXYGEN_NO_DETAIL
107 }} // namespace boost::geometry
110 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CONVERT_RING_HPP