Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:49:47

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2012-2015 Barend Gehrels, Amsterdam, the Netherlands.
0004 
0005 // This file was modified by Oracle on 2020.
0006 // Modifications copyright (c) 2020 Oracle and/or its affiliates.
0007 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0008 
0009 // Use, modification and distribution is subject to the Boost Software License,
0010 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0011 // http://www.boost.org/LICENSE_1_0.txt)
0012 
0013 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFERED_RING
0014 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFERED_RING
0015 
0016 
0017 #include <cstddef>
0018 
0019 #include <boost/range/size.hpp>
0020 #include <boost/range/value_type.hpp>
0021 
0022 #include <boost/geometry/core/assert.hpp>
0023 #include <boost/geometry/core/coordinate_type.hpp>
0024 #include <boost/geometry/core/closure.hpp>
0025 #include <boost/geometry/core/point_order.hpp>
0026 #include <boost/geometry/core/point_type.hpp>
0027 
0028 #include <boost/geometry/strategies/buffer.hpp>
0029 
0030 #include <boost/geometry/algorithms/within.hpp>
0031 
0032 #include <boost/geometry/algorithms/detail/overlay/copy_segments.hpp>
0033 #include <boost/geometry/algorithms/detail/overlay/copy_segment_point.hpp>
0034 #include <boost/geometry/algorithms/detail/overlay/enrichment_info.hpp>
0035 #include <boost/geometry/algorithms/detail/overlay/get_ring.hpp>
0036 #include <boost/geometry/algorithms/detail/overlay/traversal_info.hpp>
0037 #include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
0038 
0039 
0040 namespace boost { namespace geometry
0041 {
0042 
0043 #ifndef DOXYGEN_NO_DETAIL
0044 namespace detail { namespace buffer
0045 {
0046 
0047 struct buffered_ring_collection_tag : polygonal_tag, multi_tag
0048 {};
0049 
0050 
0051 template <typename Ring>
0052 struct buffered_ring : public Ring
0053 {
0054     bool has_concave;
0055     bool has_accepted_intersections;
0056     bool has_discarded_intersections;
0057     bool is_untouched_outside_original;
0058 
0059     inline buffered_ring()
0060         : has_concave(false)
0061         , has_accepted_intersections(false)
0062         , has_discarded_intersections(false)
0063         , is_untouched_outside_original(false)
0064     {}
0065 
0066     inline bool discarded() const
0067     {
0068         return has_discarded_intersections && ! has_accepted_intersections;
0069     }
0070     inline bool has_intersections() const
0071     {
0072         return has_discarded_intersections || has_accepted_intersections;
0073     }
0074 };
0075 
0076 // This is a collection now special for overlay (needs vector of rings)
0077 template <typename Ring>
0078 struct buffered_ring_collection : public std::vector<Ring>
0079 {
0080 };
0081 
0082 }} // namespace detail::buffer
0083 
0084 
0085 // Turn off concept checking (for now)
0086 namespace concepts
0087 {
0088 
0089 template <typename Geometry>
0090 struct concept_type<Geometry, geometry::detail::buffer::buffered_ring_collection_tag>
0091 {
0092     struct dummy {};
0093     using type = dummy;
0094 };
0095 
0096 }
0097 
0098 
0099 #endif // DOXYGEN_NO_DETAIL
0100 
0101 
0102 
0103 // Register the types
0104 namespace traits
0105 {
0106 
0107 
0108 template <typename Ring>
0109 struct tag<geometry::detail::buffer::buffered_ring<Ring> >
0110 {
0111     using type = ring_tag;
0112 };
0113 
0114 
0115 template <typename Ring>
0116 struct point_order<geometry::detail::buffer::buffered_ring<Ring> >
0117 {
0118     static const order_selector value = geometry::point_order<Ring>::value;
0119 };
0120 
0121 
0122 template <typename Ring>
0123 struct closure<geometry::detail::buffer::buffered_ring<Ring> >
0124 {
0125     static const closure_selector value = geometry::closure<Ring>::value;
0126 };
0127 
0128 
0129 template <typename Ring>
0130 struct point_type<geometry::detail::buffer::buffered_ring_collection<Ring> >
0131 {
0132     using type = geometry::point_type_t<Ring>;
0133 };
0134 
0135 template <typename Ring>
0136 struct tag<geometry::detail::buffer::buffered_ring_collection<Ring> >
0137 {
0138     using type = geometry::detail::buffer::buffered_ring_collection_tag;
0139 };
0140 
0141 
0142 } // namespace traits
0143 
0144 
0145 
0146 
0147 namespace core_dispatch
0148 {
0149 
0150 template <typename Ring>
0151 struct ring_type
0152 <
0153     detail::buffer::buffered_ring_collection_tag,
0154     detail::buffer::buffered_ring_collection<Ring>
0155 >
0156 {
0157     using type = Ring;
0158 };
0159 
0160 
0161 // There is a specific tag, so this specialization cannot be placed in traits
0162 template <typename Ring>
0163 struct point_order<detail::buffer::buffered_ring_collection_tag,
0164         geometry::detail::buffer::buffered_ring_collection
0165         <
0166             geometry::detail::buffer::buffered_ring<Ring>
0167         > >
0168 {
0169     static const order_selector value
0170         = core_dispatch::point_order<ring_tag, Ring>::value;
0171 };
0172 
0173 
0174 }
0175 
0176 
0177 template <>
0178 struct single_tag_of<detail::buffer::buffered_ring_collection_tag>
0179 {
0180     using type = ring_tag;
0181 };
0182 
0183 
0184 namespace dispatch
0185 {
0186 
0187 template
0188 <
0189     typename MultiRing,
0190     bool Reverse,
0191     typename SegmentIdentifier,
0192     typename PointOut
0193 >
0194 struct copy_segment_point
0195     <
0196         detail::buffer::buffered_ring_collection_tag,
0197         MultiRing,
0198         Reverse,
0199         SegmentIdentifier,
0200         PointOut
0201     >
0202     : detail::copy_segments::copy_segment_point_multi
0203         <
0204             MultiRing,
0205             SegmentIdentifier,
0206             PointOut,
0207             detail::copy_segments::copy_segment_point_range
0208                 <
0209                     typename boost::range_value<MultiRing>::type,
0210                     Reverse,
0211                     SegmentIdentifier,
0212                     PointOut
0213                 >
0214         >
0215 {};
0216 
0217 
0218 template<bool Reverse>
0219 struct copy_segments
0220     <
0221         detail::buffer::buffered_ring_collection_tag,
0222         Reverse
0223     >
0224     : detail::copy_segments::copy_segments_multi
0225         <
0226             detail::copy_segments::copy_segments_ring<Reverse>
0227         >
0228 {};
0229 
0230 template <typename Point, typename MultiGeometry>
0231 struct within
0232 <
0233     Point,
0234     MultiGeometry,
0235     point_tag,
0236     detail::buffer::buffered_ring_collection_tag
0237 >
0238 {
0239     template <typename Strategy>
0240     static inline bool apply(Point const& point,
0241                 MultiGeometry const& multi, Strategy const& strategy)
0242     {
0243         return detail::within::point_in_geometry(point, multi, strategy) == 1;
0244     }
0245 };
0246 
0247 
0248 template <typename Geometry>
0249 struct is_empty<Geometry, detail::buffer::buffered_ring_collection_tag>
0250     : detail::is_empty::multi_is_empty<detail::is_empty::range_is_empty>
0251 {};
0252 
0253 
0254 template <typename Geometry>
0255 struct envelope<Geometry, detail::buffer::buffered_ring_collection_tag>
0256     : detail::envelope::envelope_multi_range
0257         <
0258             detail::envelope::envelope_range
0259         >
0260 {};
0261 
0262 
0263 } // namespace dispatch
0264 
0265 namespace detail { namespace overlay
0266 {
0267 
0268 template<>
0269 struct get_ring<detail::buffer::buffered_ring_collection_tag>
0270 {
0271     template<typename MultiGeometry>
0272     static inline ring_type_t<MultiGeometry> const& apply(
0273                 ring_identifier const& id,
0274                 MultiGeometry const& multi_ring)
0275     {
0276         BOOST_GEOMETRY_ASSERT
0277             (
0278                 id.multi_index >= 0
0279                 && id.multi_index < int(boost::size(multi_ring))
0280             );
0281         return get_ring<ring_tag>::apply(id, multi_ring[id.multi_index]);
0282     }
0283 };
0284 
0285 }}
0286 
0287 
0288 }} // namespace boost::geometry
0289 
0290 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_BUFFER_BUFFERED_RING