File indexing completed on 2025-01-18 09:35:07
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_HAS_DUPLICATES_HPP
0012 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_HAS_DUPLICATES_HPP
0013
0014 #include <boost/core/ignore_unused.hpp>
0015 #include <boost/range/begin.hpp>
0016 #include <boost/range/end.hpp>
0017 #include <boost/range/size.hpp>
0018
0019 #include <boost/geometry/core/closure.hpp>
0020
0021 #include <boost/geometry/policies/compare.hpp>
0022 #include <boost/geometry/policies/is_valid/default_policy.hpp>
0023
0024 #include <boost/geometry/views/closeable_view.hpp>
0025 #include <boost/geometry/algorithms/validity_failure_type.hpp>
0026
0027
0028 namespace boost { namespace geometry
0029 {
0030
0031
0032 #ifndef DOXYGEN_NO_DETAIL
0033 namespace detail { namespace is_valid
0034 {
0035
0036 template <typename Range>
0037 struct has_duplicates
0038 {
0039 template <typename VisitPolicy, typename Strategy>
0040 static inline bool apply(Range const& range, VisitPolicy& visitor,
0041 Strategy const& )
0042 {
0043 boost::ignore_unused(visitor);
0044
0045 detail::closed_view<Range const> const view(range);
0046
0047 if ( boost::size(view) < 2 )
0048 {
0049 return ! visitor.template apply<no_failure>();
0050 }
0051
0052 geometry::equal_to
0053 <
0054 typename boost::range_value<Range>::type,
0055 -1,
0056 typename Strategy::cs_tag
0057 > equal;
0058
0059 auto it = boost::begin(view);
0060 auto const end = boost::end(view);
0061 auto next = it;
0062 for (++next; next != end; ++it, ++next)
0063 {
0064 if ( equal(*it, *next) )
0065 {
0066 return ! visitor.template apply<failure_duplicate_points>(*it);
0067 }
0068 }
0069 return ! visitor.template apply<no_failure>();
0070 }
0071 };
0072
0073
0074
0075 }}
0076 #endif
0077
0078
0079 }}
0080
0081
0082
0083 #endif