]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/geometry/algorithms/detail/overlay/convert_ring.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / overlay / convert_ring.hpp
CommitLineData
7c673cae
FG
1// Boost.Geometry (aka GGL, Generic Geometry Library)
2
3// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
4
92f5a8d4
TL
5// This file was modified by Oracle on 2018.
6// Modifications copyright (c) 2018, Oracle and/or its affiliates.
7
8// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
9
7c673cae
FG
10// Use, modification and distribution is subject to the Boost Software License,
11// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12// http://www.boost.org/LICENSE_1_0.txt)
13
14#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CONVERT_RING_HPP
15#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CONVERT_RING_HPP
16
7c673cae 17#include <boost/mpl/assert.hpp>
7c673cae
FG
18#include <boost/range/algorithm/reverse.hpp>
19
92f5a8d4
TL
20#include <boost/geometry/algorithms/convert.hpp>
21#include <boost/geometry/algorithms/detail/ring_identifier.hpp>
22#include <boost/geometry/algorithms/num_points.hpp>
23
7c673cae
FG
24#include <boost/geometry/core/tags.hpp>
25#include <boost/geometry/core/exterior_ring.hpp>
26#include <boost/geometry/core/interior_rings.hpp>
7c673cae
FG
27
28namespace boost { namespace geometry
29{
30
31
32#ifndef DOXYGEN_NO_DETAIL
33namespace detail { namespace overlay
34{
35
36
37template<typename Tag>
38struct convert_ring
39{
40 BOOST_MPL_ASSERT_MSG
41 (
42 false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TAG
43 , (types<Tag>)
44 );
45};
46
47template<>
48struct convert_ring<ring_tag>
49{
50 template<typename Destination, typename Source>
51 static inline void apply(Destination& destination, Source const& source,
52 bool append, bool reverse)
53 {
54 if (! append)
55 {
56 geometry::convert(source, destination);
57 if (reverse)
58 {
59 boost::reverse(destination);
60 }
61 }
62 }
63};
64
65
66template<>
67struct convert_ring<polygon_tag>
68{
69 template<typename Destination, typename Source>
70 static inline void apply(Destination& destination, Source const& source,
71 bool append, bool reverse)
72 {
73 if (! append)
74 {
75 geometry::convert(source, exterior_ring(destination));
76 if (reverse)
77 {
78 boost::reverse(exterior_ring(destination));
79 }
80 }
81 else
82 {
83 // Avoid adding interior rings which are invalid
84 // because of its number of points:
85 std::size_t const min_num_points
86 = core_detail::closure::minimum_ring_size
87 <
88 geometry::closure<Destination>::value
89 >::value;
90
91 if (geometry::num_points(source) >= min_num_points)
92 {
93 interior_rings(destination).resize(
94 interior_rings(destination).size() + 1);
95 geometry::convert(source, interior_rings(destination).back());
96 if (reverse)
97 {
98 boost::reverse(interior_rings(destination).back());
99 }
100 }
101 }
102 }
103};
104
105
106}} // namespace detail::overlay
107#endif // DOXYGEN_NO_DETAIL
108
109
110}} // namespace boost::geometry
111
112
113#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CONVERT_RING_HPP