1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2017-2017 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_NEEDS_SELF_TURNS_HPP
10 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_NEEDS_SELF_TURNS_HPP
12 #include <boost/range.hpp>
14 #include <boost/geometry/core/tags.hpp>
15 #include <boost/geometry/algorithms/num_interior_rings.hpp>
18 namespace boost { namespace geometry
22 #ifndef DOXYGEN_NO_DETAIL
23 namespace detail { namespace overlay
29 typename Tag = typename tag<Geometry>::type
31 struct needs_self_turns
35 template <typename Geometry>
36 struct needs_self_turns<Geometry, box_tag>
38 static inline bool apply(Geometry const&)
44 template <typename Geometry>
45 struct needs_self_turns<Geometry, ring_tag>
47 static inline bool apply(Geometry const&)
53 template <typename Geometry>
54 struct needs_self_turns<Geometry, polygon_tag>
56 static inline bool apply(Geometry const& polygon)
58 return geometry::num_interior_rings(polygon) > 0;
62 template <typename Geometry>
63 struct needs_self_turns<Geometry, multi_polygon_tag>
65 static inline bool apply(Geometry const& multi)
67 typedef typename boost::range_value<Geometry>::type polygon_type;
68 std::size_t const n = boost::size(multi);
69 return n > 1 || (n == 1
70 && needs_self_turns<polygon_type>
71 ::apply(*boost::begin(multi)));
76 }} // namespace detail::overlay
77 #endif // DOXYGEN_NO_DETAIL
80 }} // namespace boost::geometry
83 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_NEEDS_SELF_TURNS_HPP