File indexing completed on 2025-01-18 09:35:06
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_AREAL_HPP
0012 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_AREAL_HPP
0013
0014 #include <boost/range/begin.hpp>
0015 #include <boost/range/empty.hpp>
0016 #include <boost/range/end.hpp>
0017 #include <boost/range/value_type.hpp>
0018
0019 #include <boost/geometry/core/closure.hpp>
0020 #include <boost/geometry/core/exterior_ring.hpp>
0021 #include <boost/geometry/core/interior_rings.hpp>
0022 #include <boost/geometry/core/ring_type.hpp>
0023 #include <boost/geometry/core/tags.hpp>
0024
0025 #include <boost/geometry/algorithms/detail/is_simple/failure_policy.hpp>
0026 #include <boost/geometry/algorithms/detail/is_valid/has_duplicates.hpp>
0027
0028 #include <boost/geometry/algorithms/dispatch/is_simple.hpp>
0029
0030
0031 namespace boost { namespace geometry
0032 {
0033
0034
0035 #ifndef DOXYGEN_NO_DETAIL
0036 namespace detail { namespace is_simple
0037 {
0038
0039
0040 template <typename Ring, typename Strategy>
0041 inline bool is_simple_ring(Ring const& ring, Strategy const& strategy)
0042 {
0043 simplicity_failure_policy policy;
0044 return ! boost::empty(ring)
0045 && ! detail::is_valid::has_duplicates<Ring>::apply(ring, policy, strategy);
0046 }
0047
0048 template <typename InteriorRings, typename Strategy>
0049 inline bool are_simple_interior_rings(InteriorRings const& interior_rings,
0050 Strategy const& strategy)
0051 {
0052 return std::all_of(boost::begin(interior_rings),
0053 boost::end(interior_rings),
0054 [&](auto const& r)
0055 {
0056 return is_simple_ring(r, strategy);
0057 });
0058
0059 }
0060
0061 template <typename Polygon, typename Strategy>
0062 inline bool is_simple_polygon(Polygon const& polygon, Strategy const& strategy)
0063 {
0064 return is_simple_ring(geometry::exterior_ring(polygon), strategy)
0065 && are_simple_interior_rings(geometry::interior_rings(polygon), strategy);
0066 }
0067
0068
0069 }}
0070 #endif
0071
0072
0073
0074
0075 #ifndef DOXYGEN_NO_DISPATCH
0076 namespace dispatch
0077 {
0078
0079
0080
0081
0082
0083
0084 template <typename Ring>
0085 struct is_simple<Ring, ring_tag>
0086 {
0087 template <typename Strategy>
0088 static inline bool apply(Ring const& ring, Strategy const& strategy)
0089 {
0090 return detail::is_simple::is_simple_ring(ring, strategy);
0091 }
0092 };
0093
0094
0095
0096
0097
0098 template <typename Polygon>
0099 struct is_simple<Polygon, polygon_tag>
0100 {
0101 template <typename Strategy>
0102 static inline bool apply(Polygon const& polygon, Strategy const& strategy)
0103 {
0104 return detail::is_simple::is_simple_polygon(polygon, strategy);
0105 }
0106 };
0107
0108
0109
0110
0111
0112
0113 template <typename MultiPolygon>
0114 struct is_simple<MultiPolygon, multi_polygon_tag>
0115 {
0116 template <typename Strategy>
0117 static inline bool apply(MultiPolygon const& multipolygon, Strategy const& strategy)
0118 {
0119 return std::none_of(boost::begin(multipolygon), boost::end(multipolygon),
0120 [&](auto const& po) {
0121 return ! detail::is_simple::is_simple_polygon(po, strategy);
0122 });
0123
0124 }
0125 };
0126
0127
0128 }
0129 #endif
0130
0131
0132 }}
0133
0134 #endif