1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2012-2015 Barend Gehrels, Amsterdam, the Netherlands.
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
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)
13 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFERED_RING
14 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFERED_RING
19 #include <boost/range/size.hpp>
20 #include <boost/range/value_type.hpp>
22 #include <boost/geometry/core/assert.hpp>
23 #include <boost/geometry/core/coordinate_type.hpp>
24 #include <boost/geometry/core/closure.hpp>
25 #include <boost/geometry/core/point_order.hpp>
26 #include <boost/geometry/core/point_type.hpp>
28 #include <boost/geometry/strategies/buffer.hpp>
30 #include <boost/geometry/algorithms/within.hpp>
32 #include <boost/geometry/algorithms/detail/overlay/copy_segments.hpp>
33 #include <boost/geometry/algorithms/detail/overlay/copy_segment_point.hpp>
34 #include <boost/geometry/algorithms/detail/overlay/enrichment_info.hpp>
35 #include <boost/geometry/algorithms/detail/overlay/get_ring.hpp>
36 #include <boost/geometry/algorithms/detail/overlay/traversal_info.hpp>
37 #include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
40 namespace boost { namespace geometry
43 #ifndef DOXYGEN_NO_DETAIL
44 namespace detail { namespace buffer
47 struct buffered_ring_collection_tag : polygonal_tag, multi_tag
51 template <typename Ring>
52 struct buffered_ring : public Ring
55 bool has_accepted_intersections;
56 bool has_discarded_intersections;
57 bool is_untouched_outside_original;
59 inline buffered_ring()
61 , has_accepted_intersections(false)
62 , has_discarded_intersections(false)
63 , is_untouched_outside_original(false)
66 inline bool discarded() const
68 return has_discarded_intersections && ! has_accepted_intersections;
70 inline bool has_intersections() const
72 return has_discarded_intersections || has_accepted_intersections;
76 // This is a collection now special for overlay (needs vector of rings)
77 template <typename Ring>
78 struct buffered_ring_collection : public std::vector<Ring>
82 }} // namespace detail::buffer
85 // Turn off concept checking (for now)
89 template <typename Geometry>
90 struct concept_type<Geometry, geometry::detail::buffer::buffered_ring_collection_tag>
99 #endif // DOXYGEN_NO_DETAIL
103 // Register the types
108 template <typename Ring>
109 struct tag<geometry::detail::buffer::buffered_ring<Ring> >
111 typedef ring_tag type;
115 template <typename Ring>
116 struct point_order<geometry::detail::buffer::buffered_ring<Ring> >
118 static const order_selector value = geometry::point_order<Ring>::value;
122 template <typename Ring>
123 struct closure<geometry::detail::buffer::buffered_ring<Ring> >
125 static const closure_selector value = geometry::closure<Ring>::value;
129 template <typename Ring>
130 struct point_type<geometry::detail::buffer::buffered_ring_collection<Ring> >
132 typedef typename geometry::point_type<Ring>::type type;
135 template <typename Ring>
136 struct tag<geometry::detail::buffer::buffered_ring_collection<Ring> >
138 typedef geometry::detail::buffer::buffered_ring_collection_tag type;
142 } // namespace traits
147 namespace core_dispatch
150 template <typename Ring>
153 detail::buffer::buffered_ring_collection_tag,
154 detail::buffer::buffered_ring_collection<Ring>
161 // There is a specific tag, so this specialization cannot be placed in traits
162 template <typename Ring>
163 struct point_order<detail::buffer::buffered_ring_collection_tag,
164 geometry::detail::buffer::buffered_ring_collection
166 geometry::detail::buffer::buffered_ring<Ring>
169 static const order_selector value
170 = core_dispatch::point_order<ring_tag, Ring>::value;
178 struct single_tag_of<detail::buffer::buffered_ring_collection_tag>
180 typedef ring_tag type;
191 typename SegmentIdentifier,
194 struct copy_segment_point
196 detail::buffer::buffered_ring_collection_tag,
202 : detail::copy_segments::copy_segment_point_multi
207 detail::copy_segments::copy_segment_point_range
209 typename boost::range_value<MultiRing>::type,
218 template<bool Reverse>
221 detail::buffer::buffered_ring_collection_tag,
224 : detail::copy_segments::copy_segments_multi
226 detail::copy_segments::copy_segments_ring<Reverse>
230 template <typename Point, typename MultiGeometry>
236 detail::buffer::buffered_ring_collection_tag
239 template <typename Strategy>
240 static inline bool apply(Point const& point,
241 MultiGeometry const& multi, Strategy const& strategy)
243 return detail::within::point_in_geometry(point, multi, strategy) == 1;
248 template <typename Geometry>
249 struct is_empty<Geometry, detail::buffer::buffered_ring_collection_tag>
250 : detail::is_empty::multi_is_empty<detail::is_empty::range_is_empty>
254 template <typename Geometry>
255 struct envelope<Geometry, detail::buffer::buffered_ring_collection_tag>
256 : detail::envelope::envelope_multi_range
258 detail::envelope::envelope_range
263 } // namespace dispatch
265 namespace detail { namespace overlay
269 struct get_ring<detail::buffer::buffered_ring_collection_tag>
271 template<typename MultiGeometry>
272 static inline typename ring_type<MultiGeometry>::type const& apply(
273 ring_identifier const& id,
274 MultiGeometry const& multi_ring)
276 BOOST_GEOMETRY_ASSERT
279 && id.multi_index < int(boost::size(multi_ring))
281 return get_ring<ring_tag>::apply(id, multi_ring[id.multi_index]);
288 }} // namespace boost::geometry
290 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFERED_RING