]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | ||
3 | // Copyright (c) 2017-2017 Barend Gehrels, Amsterdam, the Netherlands. | |
4 | ||
20effc67 TL |
5 | // This file was modified by Oracle on 2020. |
6 | // Modifications copyright (c) 2020 Oracle and/or its affiliates. | |
7 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle | |
8 | ||
b32b8144 FG |
9 | // Use, modification and distribution is subject to the Boost Software License, |
10 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
11 | // http://www.boost.org/LICENSE_1_0.txt) | |
12 | ||
13 | #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_NEEDS_SELF_TURNS_HPP | |
14 | #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_NEEDS_SELF_TURNS_HPP | |
15 | ||
20effc67 TL |
16 | #include <boost/range/begin.hpp> |
17 | #include <boost/range/size.hpp> | |
b32b8144 FG |
18 | |
19 | #include <boost/geometry/core/tags.hpp> | |
20 | #include <boost/geometry/algorithms/num_interior_rings.hpp> | |
21 | ||
22 | ||
23 | namespace boost { namespace geometry | |
24 | { | |
25 | ||
26 | ||
27 | #ifndef DOXYGEN_NO_DETAIL | |
28 | namespace detail { namespace overlay | |
29 | { | |
30 | ||
31 | template | |
32 | < | |
33 | typename Geometry, | |
34 | typename Tag = typename tag<Geometry>::type | |
35 | > | |
36 | struct needs_self_turns | |
37 | { | |
38 | }; | |
39 | ||
40 | template <typename Geometry> | |
41 | struct needs_self_turns<Geometry, box_tag> | |
42 | { | |
43 | static inline bool apply(Geometry const&) | |
44 | { | |
45 | return false; | |
46 | } | |
47 | }; | |
48 | ||
49 | template <typename Geometry> | |
50 | struct needs_self_turns<Geometry, ring_tag> | |
51 | { | |
52 | static inline bool apply(Geometry const&) | |
53 | { | |
54 | return false; | |
55 | } | |
56 | }; | |
57 | ||
58 | template <typename Geometry> | |
59 | struct needs_self_turns<Geometry, polygon_tag> | |
60 | { | |
61 | static inline bool apply(Geometry const& polygon) | |
62 | { | |
63 | return geometry::num_interior_rings(polygon) > 0; | |
64 | } | |
65 | }; | |
66 | ||
67 | template <typename Geometry> | |
68 | struct needs_self_turns<Geometry, multi_polygon_tag> | |
69 | { | |
70 | static inline bool apply(Geometry const& multi) | |
71 | { | |
72 | typedef typename boost::range_value<Geometry>::type polygon_type; | |
73 | std::size_t const n = boost::size(multi); | |
74 | return n > 1 || (n == 1 | |
75 | && needs_self_turns<polygon_type> | |
76 | ::apply(*boost::begin(multi))); | |
77 | } | |
78 | }; | |
79 | ||
80 | ||
81 | }} // namespace detail::overlay | |
82 | #endif // DOXYGEN_NO_DETAIL | |
83 | ||
84 | ||
85 | }} // namespace boost::geometry | |
86 | ||
87 | ||
88 | #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_NEEDS_SELF_TURNS_HPP |