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_VALID_BOX_HPP
0012 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_BOX_HPP
0013
0014 #include <cstddef>
0015
0016 #include <boost/core/ignore_unused.hpp>
0017
0018 #include <boost/geometry/core/access.hpp>
0019 #include <boost/geometry/core/tags.hpp>
0020 #include <boost/geometry/core/coordinate_dimension.hpp>
0021
0022 #include <boost/geometry/algorithms/validity_failure_type.hpp>
0023 #include <boost/geometry/algorithms/detail/is_valid/has_invalid_coordinate.hpp>
0024 #include <boost/geometry/algorithms/dispatch/is_valid.hpp>
0025
0026
0027 namespace boost { namespace geometry
0028 {
0029
0030
0031 #ifndef DOXYGEN_NO_DETAIL
0032 namespace detail { namespace is_valid
0033 {
0034
0035 template <typename Box, std::size_t I>
0036 struct has_valid_corners
0037 {
0038 template <typename VisitPolicy>
0039 static inline bool apply(Box const& box, VisitPolicy& visitor)
0040 {
0041 if (math::equals(geometry::get<geometry::min_corner, I-1>(box),
0042 geometry::get<geometry::max_corner, I-1>(box)))
0043 {
0044 return
0045 visitor.template apply<failure_wrong_topological_dimension>();
0046 }
0047 else if (geometry::get<geometry::min_corner, I-1>(box)
0048 >
0049 geometry::get<geometry::max_corner, I-1>(box))
0050 {
0051 return visitor.template apply<failure_wrong_corner_order>();
0052 }
0053 return has_valid_corners<Box, I-1>::apply(box, visitor);
0054 }
0055 };
0056
0057
0058 template <typename Box>
0059 struct has_valid_corners<Box, 0>
0060 {
0061 template <typename VisitPolicy>
0062 static inline bool apply(Box const&, VisitPolicy& visitor)
0063 {
0064 boost::ignore_unused(visitor);
0065
0066 return visitor.template apply<no_failure>();
0067 }
0068 };
0069
0070
0071 template <typename Box>
0072 struct is_valid_box
0073 {
0074 template <typename VisitPolicy, typename Strategy>
0075 static inline bool apply(Box const& box, VisitPolicy& visitor, Strategy const&)
0076 {
0077 return
0078 ! has_invalid_coordinate<Box>::apply(box, visitor)
0079 &&
0080 has_valid_corners<Box, dimension<Box>::value>::apply(box, visitor);
0081 }
0082 };
0083
0084 }}
0085 #endif
0086
0087
0088
0089 #ifndef DOXYGEN_NO_DISPATCH
0090 namespace dispatch
0091 {
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101 template <typename Box>
0102 struct is_valid<Box, box_tag>
0103 : detail::is_valid::is_valid_box<Box>
0104 {};
0105
0106
0107 }
0108 #endif
0109
0110
0111
0112 }}
0113
0114
0115 #endif