File indexing completed on 2025-01-18 09:35:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_RANGE_BY_SECTION_HPP
0019 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_RANGE_BY_SECTION_HPP
0020
0021 #include <boost/range/size.hpp>
0022 #include <boost/range/value_type.hpp>
0023
0024 #include <boost/geometry/core/assert.hpp>
0025 #include <boost/geometry/core/closure.hpp>
0026 #include <boost/geometry/core/exterior_ring.hpp>
0027 #include <boost/geometry/core/interior_rings.hpp>
0028 #include <boost/geometry/core/ring_type.hpp>
0029 #include <boost/geometry/core/static_assert.hpp>
0030 #include <boost/geometry/core/tags.hpp>
0031 #include <boost/geometry/geometries/concepts/check.hpp>
0032 #include <boost/geometry/util/range.hpp>
0033
0034
0035 namespace boost { namespace geometry
0036 {
0037
0038 #ifndef DOXYGEN_NO_DETAIL
0039 namespace detail { namespace section
0040 {
0041
0042
0043 template <typename Range, typename Section>
0044 struct full_section_range
0045 {
0046 static inline Range const& apply(Range const& range, Section const& )
0047 {
0048 return range;
0049 }
0050 };
0051
0052
0053 template <typename Polygon, typename Section>
0054 struct full_section_polygon
0055 {
0056 static inline typename ring_return_type<Polygon const>::type apply(Polygon const& polygon, Section const& section)
0057 {
0058 return section.ring_id.ring_index < 0
0059 ? geometry::exterior_ring(polygon)
0060 : range::at(geometry::interior_rings(polygon),
0061 static_cast<std::size_t>(section.ring_id.ring_index));
0062 }
0063 };
0064
0065
0066 template
0067 <
0068 typename MultiGeometry,
0069 typename Section,
0070 typename Policy
0071 >
0072 struct full_section_multi
0073 {
0074 static inline typename ring_return_type<MultiGeometry const>::type apply(
0075 MultiGeometry const& multi, Section const& section)
0076 {
0077 typedef typename boost::range_size<MultiGeometry>::type size_type;
0078
0079 BOOST_GEOMETRY_ASSERT
0080 (
0081 section.ring_id.multi_index >= 0
0082 && size_type(section.ring_id.multi_index) < boost::size(multi)
0083 );
0084
0085 return Policy::apply(range::at(multi, size_type(section.ring_id.multi_index)), section);
0086 }
0087 };
0088
0089
0090 }}
0091 #endif
0092
0093
0094 #ifndef DOXYGEN_NO_DISPATCH
0095 namespace dispatch
0096 {
0097
0098
0099 template
0100 <
0101 typename Tag,
0102 typename Geometry,
0103 typename Section
0104 >
0105 struct range_by_section
0106 {
0107 BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
0108 "Not or not yet implemented for this Geometry type.",
0109 Tag, Geometry, Section);
0110 };
0111
0112
0113 template <typename LineString, typename Section>
0114 struct range_by_section<linestring_tag, LineString, Section>
0115 : detail::section::full_section_range<LineString, Section>
0116 {};
0117
0118
0119 template <typename Ring, typename Section>
0120 struct range_by_section<ring_tag, Ring, Section>
0121 : detail::section::full_section_range<Ring, Section>
0122 {};
0123
0124
0125 template <typename Polygon, typename Section>
0126 struct range_by_section<polygon_tag, Polygon, Section>
0127 : detail::section::full_section_polygon<Polygon, Section>
0128 {};
0129
0130
0131 template <typename MultiPolygon, typename Section>
0132 struct range_by_section<multi_polygon_tag, MultiPolygon, Section>
0133 : detail::section::full_section_multi
0134 <
0135 MultiPolygon,
0136 Section,
0137 detail::section::full_section_polygon
0138 <
0139 typename boost::range_value<MultiPolygon>::type,
0140 Section
0141 >
0142 >
0143 {};
0144
0145 template <typename MultiLinestring, typename Section>
0146 struct range_by_section<multi_linestring_tag, MultiLinestring, Section>
0147 : detail::section::full_section_multi
0148 <
0149 MultiLinestring,
0150 Section,
0151 detail::section::full_section_range
0152 <
0153 typename boost::range_value<MultiLinestring>::type,
0154 Section
0155 >
0156 >
0157 {};
0158
0159
0160 }
0161 #endif
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173 template <typename Geometry, typename Section>
0174 inline typename ring_return_type<Geometry const>::type
0175 range_by_section(Geometry const& geometry, Section const& section)
0176 {
0177 concepts::check<Geometry const>();
0178
0179 return dispatch::range_by_section
0180 <
0181 typename tag<Geometry>::type,
0182 Geometry,
0183 Section
0184 >::apply(geometry, section);
0185 }
0186
0187
0188 }}
0189
0190 #endif