1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2012-2014 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_BUFFER_BUFFERED_RING
10 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFERED_RING
15 #include <boost/range.hpp>
17 #include <boost/geometry/core/coordinate_type.hpp>
18 #include <boost/geometry/core/point_type.hpp>
20 #include <boost/geometry/strategies/buffer.hpp>
22 #include <boost/geometry/algorithms/detail/overlay/copy_segments.hpp>
23 #include <boost/geometry/algorithms/detail/overlay/copy_segment_point.hpp>
24 #include <boost/geometry/algorithms/detail/overlay/enrichment_info.hpp>
25 #include <boost/geometry/algorithms/detail/overlay/get_ring.hpp>
26 #include <boost/geometry/algorithms/detail/overlay/traversal_info.hpp>
27 #include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
29 #include <boost/geometry/multi/algorithms/within.hpp>
32 namespace boost { namespace geometry
35 #ifndef DOXYGEN_NO_DETAIL
36 namespace detail { namespace buffer
39 struct buffered_ring_collection_tag : polygonal_tag, multi_tag
43 template <typename Ring>
44 struct buffered_ring : public Ring
46 bool has_accepted_intersections;
47 bool has_discarded_intersections;
49 inline buffered_ring()
50 : has_accepted_intersections(false)
51 , has_discarded_intersections(false)
54 inline bool discarded() const
56 return has_discarded_intersections && ! has_accepted_intersections;
58 inline bool has_intersections() const
60 return has_discarded_intersections || has_accepted_intersections;
64 // This is a collection now special for overlay (needs vector of rings)
65 template <typename Ring>
66 struct buffered_ring_collection : public std::vector<Ring>
70 }} // namespace detail::buffer
73 // Turn off concept checking (for now)
76 template <typename Geometry, bool IsConst>
77 struct check<Geometry, detail::buffer::buffered_ring_collection_tag, IsConst>
84 #endif // DOXYGEN_NO_DETAIL
93 template <typename Ring>
94 struct tag<detail::buffer::buffered_ring<Ring> >
96 typedef ring_tag type;
100 template <typename Ring>
101 struct point_order<detail::buffer::buffered_ring<Ring> >
103 static const order_selector value = geometry::point_order<Ring>::value;
107 template <typename Ring>
108 struct closure<detail::buffer::buffered_ring<Ring> >
110 static const closure_selector value = geometry::closure<Ring>::value;
114 template <typename Ring>
115 struct point_type<detail::buffer::buffered_ring_collection<Ring> >
117 typedef typename geometry::point_type<Ring>::type type;
120 template <typename Ring>
121 struct tag<detail::buffer::buffered_ring_collection<Ring> >
123 typedef detail::buffer::buffered_ring_collection_tag type;
127 } // namespace traits
132 namespace core_dispatch
135 template <typename Ring>
138 detail::buffer::buffered_ring_collection_tag,
139 detail::buffer::buffered_ring_collection<Ring>
154 typename SegmentIdentifier,
157 struct copy_segment_point
159 detail::buffer::buffered_ring_collection_tag,
165 : detail::copy_segments::copy_segment_point_multi
170 detail::copy_segments::copy_segment_point_range
172 typename boost::range_value<MultiRing>::type,
181 template<bool Reverse>
184 detail::buffer::buffered_ring_collection_tag,
187 : detail::copy_segments::copy_segments_multi
189 detail::copy_segments::copy_segments_ring<Reverse>
193 template <typename Point, typename MultiGeometry>
199 detail::buffer::buffered_ring_collection_tag
202 template <typename Strategy>
203 static inline bool apply(Point const& point,
204 MultiGeometry const& multi, Strategy const& strategy)
206 return detail::within::point_in_geometry(point, multi, strategy) == 1;
211 } // namespace dispatch
213 namespace detail { namespace overlay
217 struct get_ring<detail::buffer::buffered_ring_collection_tag>
219 template<typename MultiGeometry>
220 static inline typename ring_type<MultiGeometry>::type const& apply(
221 ring_identifier const& id,
222 MultiGeometry const& multi_ring)
227 && id.multi_index < int(boost::size(multi_ring))
229 return get_ring<ring_tag>::apply(id, multi_ring[id.multi_index]);
236 }} // namespace boost::geometry
238 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFERED_RING