Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:16

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
0004 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
0005 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
0006 
0007 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
0008 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
0009 
0010 // This file was modified by Oracle on 2013-2020.
0011 // Modifications copyright (c) 2013-2020, Oracle and/or its affiliates.
0012 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0013 
0014 // Use, modification and distribution is subject to the Boost Software License,
0015 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0016 // http://www.boost.org/LICENSE_1_0.txt)
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 }} // namespace detail::section
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 } // namespace dispatch
0161 #endif
0162 
0163 
0164 /*!
0165     \brief Get full ring (exterior, one of interiors, one from multi)
0166         indicated by the specified section
0167     \ingroup sectionalize
0168     \tparam Geometry type
0169     \tparam Section type of section to get from
0170     \param geometry geometry to take section of
0171     \param section structure with section
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 }} // namespace boost::geometry
0189 
0190 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_RANGE_BY_SECTION_HPP